Only make parts of the initial filesystem writable
This prevents overwriting the program binary or other sentitive paths like /Data/Static.ini from Lua.
This commit is contained in:
+1
-1
@@ -1006,7 +1006,7 @@ int sm_main(int argc, char* argv[])
|
||||
FILEMAN = new RageFileManager( argv[0] );
|
||||
FILEMAN->MountInitialFilesystems();
|
||||
|
||||
bool bPortable = DoesFileExist("Portable.ini");
|
||||
bool bPortable = DoesFileExist("/Portable.ini");
|
||||
if( !bPortable )
|
||||
FILEMAN->MountUserFilesystems();
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
#include "ProductInfo.h"
|
||||
#include <CoreServices/CoreServices.h>
|
||||
#include <ApplicationServices/ApplicationServices.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <mach/mach.h>
|
||||
@@ -318,9 +317,28 @@ static void PathForFolderType( char dir[PATH_MAX], OSType folderType )
|
||||
|
||||
void ArchHooks::MountInitialFilesystems( const RString &sDirOfExecutable )
|
||||
{
|
||||
struct stat st;
|
||||
bool portable = !stat(sDirOfExecutable + "/Portable.ini", &st);
|
||||
FILEMAN->Mount(portable ? "dir" : "dirro", sDirOfExecutable, "/");
|
||||
FILEMAN->Mount("dirro", sDirOfExecutable, "/");
|
||||
|
||||
bool portable = DoesFileExist("/Portable.ini");
|
||||
if (portable)
|
||||
{
|
||||
FILEMAN->Mount("dir", sDirOfExecutable + "/Announcers", "/Announcers");
|
||||
FILEMAN->Mount("dir", sDirOfExecutable + "/BGAnimations", "/BGAnimations");
|
||||
FILEMAN->Mount("dir", sDirOfExecutable + "/BackgroundEffects", "/BackgroundEffects");
|
||||
FILEMAN->Mount("dir", sDirOfExecutable + "/BackgroundTransitions", "/BackgroundTransitions");
|
||||
FILEMAN->Mount("dir", sDirOfExecutable + "/Cache", "/Cache");
|
||||
FILEMAN->Mount("dir", sDirOfExecutable + "/CDTitles", "/CDTitles");
|
||||
FILEMAN->Mount("dir", sDirOfExecutable + "/Characters", "/Characters");
|
||||
FILEMAN->Mount("dir", sDirOfExecutable + "/Courses", "/Courses");
|
||||
FILEMAN->Mount("dir", sDirOfExecutable + "/Logs", "/Logs");
|
||||
FILEMAN->Mount("dir", sDirOfExecutable + "/NoteSkins", "/NoteSkins");
|
||||
FILEMAN->Mount("dir", sDirOfExecutable + "/Packages", "/Packages");
|
||||
FILEMAN->Mount("dir", sDirOfExecutable + "/Save", "/Save");
|
||||
FILEMAN->Mount("dir", sDirOfExecutable + "/Screenshots", "/Screenshots");
|
||||
FILEMAN->Mount("dir", sDirOfExecutable + "/Songs", "/Songs");
|
||||
FILEMAN->Mount("dir", sDirOfExecutable + "/RandomMovies", "/RandomMovies");
|
||||
FILEMAN->Mount("dir", sDirOfExecutable + "/Themes", "/Themes");
|
||||
}
|
||||
|
||||
CFURLRef dataUrl = CFBundleCopyResourceURL( CFBundleGetMainBundle(), CFSTR("StepMania"), CFSTR("smzip"), nil);
|
||||
if( dataUrl )
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <sys/time.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
@@ -383,9 +382,28 @@ RString ArchHooks_Unix::GetClipboard()
|
||||
|
||||
void ArchHooks::MountInitialFilesystems( const RString &sDirOfExecutable )
|
||||
{
|
||||
struct stat st;
|
||||
bool portable = !stat(sDirOfExecutable + "/Portable.ini", &st);
|
||||
FILEMAN->Mount(portable ? "dir" : "dirro", sDirOfExecutable, "/");
|
||||
FILEMAN->Mount("dirro", sDirOfExecutable, "/");
|
||||
|
||||
bool portable = DoesFileExist("/Portable.ini");
|
||||
if (portable)
|
||||
{
|
||||
FILEMAN->Mount("dir", sDirOfExecutable + "/Announcers", "/Announcers");
|
||||
FILEMAN->Mount("dir", sDirOfExecutable + "/BGAnimations", "/BGAnimations");
|
||||
FILEMAN->Mount("dir", sDirOfExecutable + "/BackgroundEffects", "/BackgroundEffects");
|
||||
FILEMAN->Mount("dir", sDirOfExecutable + "/BackgroundTransitions", "/BackgroundTransitions");
|
||||
FILEMAN->Mount("dir", sDirOfExecutable + "/Cache", "/Cache");
|
||||
FILEMAN->Mount("dir", sDirOfExecutable + "/CDTitles", "/CDTitles");
|
||||
FILEMAN->Mount("dir", sDirOfExecutable + "/Characters", "/Characters");
|
||||
FILEMAN->Mount("dir", sDirOfExecutable + "/Courses", "/Courses");
|
||||
FILEMAN->Mount("dir", sDirOfExecutable + "/Logs", "/Logs");
|
||||
FILEMAN->Mount("dir", sDirOfExecutable + "/NoteSkins", "/NoteSkins");
|
||||
FILEMAN->Mount("dir", sDirOfExecutable + "/Packages", "/Packages");
|
||||
FILEMAN->Mount("dir", sDirOfExecutable + "/Save", "/Save");
|
||||
FILEMAN->Mount("dir", sDirOfExecutable + "/Screenshots", "/Screenshots");
|
||||
FILEMAN->Mount("dir", sDirOfExecutable + "/Songs", "/Songs");
|
||||
FILEMAN->Mount("dir", sDirOfExecutable + "/RandomMovies", "/RandomMovies");
|
||||
FILEMAN->Mount("dir", sDirOfExecutable + "/Themes", "/Themes");
|
||||
}
|
||||
}
|
||||
|
||||
void ArchHooks::MountUserFilesystems( const RString &sDirOfExecutable )
|
||||
|
||||
@@ -55,9 +55,28 @@ static RString GetMountDir( const RString &sDirOfExecutable )
|
||||
void ArchHooks::MountInitialFilesystems( const RString &sDirOfExecutable )
|
||||
{
|
||||
RString sDir = GetMountDir( sDirOfExecutable );
|
||||
FILEMAN->Mount("dirro", sDir, "/");
|
||||
|
||||
bool portable = GetFileAttributes(sDir + "/Portable.ini", &st) != INVALID_FILE_ATTRIBUTES;
|
||||
FILEMAN->Mount(portable ? "dir" : "dirro", sDir, "/");
|
||||
bool portable = DoesFileExist("/Portable.ini");
|
||||
if (portable)
|
||||
{
|
||||
FILEMAN->Mount("dir", sDir + "/Announcers", "/Announcers");
|
||||
FILEMAN->Mount("dir", sDir + "/BGAnimations", "/BGAnimations");
|
||||
FILEMAN->Mount("dir", sDir + "/BackgroundEffects", "/BackgroundEffects");
|
||||
FILEMAN->Mount("dir", sDir + "/BackgroundTransitions", "/BackgroundTransitions");
|
||||
FILEMAN->Mount("dir", sDir + "/Cache", "/Cache");
|
||||
FILEMAN->Mount("dir", sDir + "/CDTitles", "/CDTitles");
|
||||
FILEMAN->Mount("dir", sDir + "/Characters", "/Characters");
|
||||
FILEMAN->Mount("dir", sDir + "/Courses", "/Courses");
|
||||
FILEMAN->Mount("dir", sDir + "/Logs", "/Logs");
|
||||
FILEMAN->Mount("dir", sDir + "/NoteSkins", "/NoteSkins");
|
||||
FILEMAN->Mount("dir", sDir + "/Packages", "/Packages");
|
||||
FILEMAN->Mount("dir", sDir + "/Save", "/Save");
|
||||
FILEMAN->Mount("dir", sDir + "/Screenshots", "/Screenshots");
|
||||
FILEMAN->Mount("dir", sDir + "/Songs", "/Songs");
|
||||
FILEMAN->Mount("dir", sDir + "/RandomMovies", "/RandomMovies");
|
||||
FILEMAN->Mount("dir", sDir + "/Themes", "/Themes");
|
||||
}
|
||||
}
|
||||
|
||||
void ArchHooks::MountUserFilesystems( const RString &sDirOfExecutable )
|
||||
|
||||
Reference in New Issue
Block a user