Merge pull request #15 from natano/remove-rootfs
Remove access to the root FS from lua
This commit is contained in:
@@ -107,7 +107,7 @@ IniFile =
|
||||
local file = RageFileUtil.CreateRageFile()
|
||||
|
||||
if not file:Open(file_path, RageFile.WRITE) then
|
||||
Warn( string.format("WriteFile(%s): %s",file_path.file:GetError()) )
|
||||
Warn( string.format("WriteFile(%s): %s",file_path,file:GetError()) )
|
||||
file:destroy()
|
||||
return false
|
||||
end
|
||||
|
||||
@@ -386,16 +386,6 @@ RString ArchHooks_Unix::GetClipboard()
|
||||
static LocalizedString COULDNT_FIND_SONGS( "ArchHooks_Unix", "Couldn't find 'Songs'" );
|
||||
void ArchHooks::MountInitialFilesystems( const RString &sDirOfExecutable )
|
||||
{
|
||||
#if defined(UNIX)
|
||||
/* Mount the root filesystem, so we can read files in /proc, /etc, and so on.
|
||||
* This is /rootfs, not /root, to avoid confusion with root's home directory. */
|
||||
FILEMAN->Mount( "dir", "/", "/rootfs" );
|
||||
|
||||
/* Mount /proc, so Alsa9Buf::GetSoundCardDebugInfo() and others can access it.
|
||||
* (Deprecated; use rootfs.) */
|
||||
FILEMAN->Mount( "dir", "/proc", "/proc" );
|
||||
#endif
|
||||
|
||||
RString Root;
|
||||
struct stat st;
|
||||
if( !stat(sDirOfExecutable + "/Packages", &st) && st.st_mode&S_IFDIR )
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#include "MemoryCardDriverThreaded_Linux.h"
|
||||
#include "RageLog.h"
|
||||
#include "RageUtil.h"
|
||||
#include "RageFile.h"
|
||||
#include "RageTimer.h"
|
||||
|
||||
#include <cerrno>
|
||||
@@ -14,8 +13,11 @@
|
||||
#include <dirent.h>
|
||||
#endif
|
||||
|
||||
#include <cstring>
|
||||
#include <fstream>
|
||||
#include <limits.h>
|
||||
#include <stdlib.h>
|
||||
#include <string>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
@@ -286,29 +288,31 @@ void MemoryCardDriverThreaded_Linux::GetUSBStorageDevices( vector<UsbStorageDevi
|
||||
// /dev/sda1 /mnt/flash1 auto noauto,owner 0 0
|
||||
// /dev/sdb1 /mnt/flash2 auto noauto,owner 0 0
|
||||
// /dev/sdc1 /mnt/flash3 auto noauto,owner 0 0
|
||||
|
||||
RString fn = "/rootfs/etc/fstab";
|
||||
RageFile f;
|
||||
if( !f.Open(fn) )
|
||||
|
||||
std::ifstream f("/etc/fstab");
|
||||
if (f.fail())
|
||||
{
|
||||
LOG->Warn( "can't open '%s': %s", fn.c_str(), f.GetError().c_str() );
|
||||
LOG->Warn( "can't open '/etc/fstab': %s", strerror(errno) );
|
||||
return;
|
||||
}
|
||||
|
||||
RString sLine;
|
||||
while( !f.AtEOF() )
|
||||
|
||||
std::string line;
|
||||
while( !f.eof() )
|
||||
{
|
||||
switch( f.GetLine(sLine) )
|
||||
std::getline(f, line);
|
||||
if (f.eof())
|
||||
{
|
||||
case 0: continue; /* eof */
|
||||
case -1:
|
||||
LOG->Warn( "error reading '%s': %s", fn.c_str(), f.GetError().c_str() );
|
||||
continue;
|
||||
}
|
||||
else if (f.fail())
|
||||
{
|
||||
LOG->Warn( "error reading '/etc/fstab': %s", strerror(errno) );
|
||||
return;
|
||||
}
|
||||
|
||||
char szScsiDevice[1024];
|
||||
char szMountPoint[1024];
|
||||
int iRet = sscanf( sLine, "%s %s", szScsiDevice, szMountPoint );
|
||||
int iRet = sscanf( line.c_str(), "%s %s", szScsiDevice, szMountPoint );
|
||||
if( iRet != 2 || szScsiDevice[0] == '#')
|
||||
continue; // don't process this line
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "global.h"
|
||||
|
||||
#include <dlfcn.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#define ALSA_PCM_NEW_HW_PARAMS_API
|
||||
#define ALSA_PCM_NEW_SW_PARAMS_API
|
||||
@@ -28,7 +29,8 @@ RString LoadALSA()
|
||||
* on use, and this would prevent that from happening. I don't know if anyone actually
|
||||
* does that, though: they're often configured to load snd (the core module) if ALSA
|
||||
* devices are accessed, but hardware drivers are typically loaded on boot. */
|
||||
if( !IsADirectory("/rootfs/proc/asound/") )
|
||||
struct stat st;
|
||||
if (stat("/proc/asound/", &st) == -1 || !(st.st_mode & S_IFDIR))
|
||||
return "/proc/asound/ does not exist";
|
||||
|
||||
ASSERT( Handle == nullptr );
|
||||
|
||||
@@ -5,6 +5,9 @@
|
||||
#include "ALSA9Dynamic.h"
|
||||
#include "PrefsManager.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
|
||||
/* int err; must be defined before using this macro */
|
||||
#define ALSA_CHECK(x) \
|
||||
if ( err < 0 ) { LOG->Info("ALSA: %s: %s", x, dsnd_strerror(err)); return false; }
|
||||
@@ -140,11 +143,12 @@ void Alsa9Buf::GetSoundCardDebugInfo()
|
||||
return;
|
||||
done = true;
|
||||
|
||||
if( DoesFileExist("/rootfs/proc/asound/version") )
|
||||
std::ifstream f("/proc/asound/version");
|
||||
if (f.good())
|
||||
{
|
||||
RString sVersion;
|
||||
GetFileContents( "/rootfs/proc/asound/version", sVersion, true );
|
||||
LOG->Info( "ALSA: %s", sVersion.c_str() );
|
||||
std::string version;
|
||||
std::getline(f, version);
|
||||
LOG->Info( "ALSA: %s", version.c_str() );
|
||||
}
|
||||
|
||||
InitializeErrorHandler();
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#include "RageLog.h"
|
||||
#include "RageSound.h"
|
||||
#include "RageSoundManager.h"
|
||||
#include "RageUtil.h"
|
||||
|
||||
#if defined(HAVE_UNISTD_H)
|
||||
#include <unistd.h>
|
||||
@@ -17,6 +16,7 @@
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/soundcard.h>
|
||||
#include <sys/select.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
REGISTER_SOUND_DRIVER_CLASS( OSS );
|
||||
|
||||
@@ -138,7 +138,8 @@ RString RageSoundDriver_OSS::CheckOSSVersion( int fd )
|
||||
*/
|
||||
#ifndef FORCE_OSS
|
||||
#define ALSA_SNDRV_OSS_VERSION ((3<<16)|(8<<8)|(1<<4)|(0))
|
||||
if( version == ALSA_SNDRV_OSS_VERSION && IsADirectory("/rootfs/proc/asound") )
|
||||
struct stat st;
|
||||
if( version == ALSA_SNDRV_OSS_VERSION && stat("/proc/asound", &st) && (st.st_mode & S_IFDIR) )
|
||||
return "RageSoundDriver_OSS: ALSA detected. ALSA OSS emulation is buggy; use ALSA natively.";
|
||||
#endif
|
||||
if( version )
|
||||
|
||||
Reference in New Issue
Block a user