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()
|
local file = RageFileUtil.CreateRageFile()
|
||||||
|
|
||||||
if not file:Open(file_path, RageFile.WRITE) then
|
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()
|
file:destroy()
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -386,16 +386,6 @@ RString ArchHooks_Unix::GetClipboard()
|
|||||||
static LocalizedString COULDNT_FIND_SONGS( "ArchHooks_Unix", "Couldn't find 'Songs'" );
|
static LocalizedString COULDNT_FIND_SONGS( "ArchHooks_Unix", "Couldn't find 'Songs'" );
|
||||||
void ArchHooks::MountInitialFilesystems( const RString &sDirOfExecutable )
|
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;
|
RString Root;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
if( !stat(sDirOfExecutable + "/Packages", &st) && st.st_mode&S_IFDIR )
|
if( !stat(sDirOfExecutable + "/Packages", &st) && st.st_mode&S_IFDIR )
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
#include "MemoryCardDriverThreaded_Linux.h"
|
#include "MemoryCardDriverThreaded_Linux.h"
|
||||||
#include "RageLog.h"
|
#include "RageLog.h"
|
||||||
#include "RageUtil.h"
|
#include "RageUtil.h"
|
||||||
#include "RageFile.h"
|
|
||||||
#include "RageTimer.h"
|
#include "RageTimer.h"
|
||||||
|
|
||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
@@ -14,8 +13,11 @@
|
|||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <cstring>
|
||||||
|
#include <fstream>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <string>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
@@ -287,28 +289,30 @@ void MemoryCardDriverThreaded_Linux::GetUSBStorageDevices( vector<UsbStorageDevi
|
|||||||
// /dev/sdb1 /mnt/flash2 auto noauto,owner 0 0
|
// /dev/sdb1 /mnt/flash2 auto noauto,owner 0 0
|
||||||
// /dev/sdc1 /mnt/flash3 auto noauto,owner 0 0
|
// /dev/sdc1 /mnt/flash3 auto noauto,owner 0 0
|
||||||
|
|
||||||
RString fn = "/rootfs/etc/fstab";
|
std::ifstream f("/etc/fstab");
|
||||||
RageFile f;
|
if (f.fail())
|
||||||
if( !f.Open(fn) )
|
|
||||||
{
|
{
|
||||||
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
RString sLine;
|
std::string line;
|
||||||
while( !f.AtEOF() )
|
while( !f.eof() )
|
||||||
{
|
{
|
||||||
switch( f.GetLine(sLine) )
|
std::getline(f, line);
|
||||||
|
if (f.eof())
|
||||||
{
|
{
|
||||||
case 0: continue; /* eof */
|
continue;
|
||||||
case -1:
|
}
|
||||||
LOG->Warn( "error reading '%s': %s", fn.c_str(), f.GetError().c_str() );
|
else if (f.fail())
|
||||||
|
{
|
||||||
|
LOG->Warn( "error reading '/etc/fstab': %s", strerror(errno) );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
char szScsiDevice[1024];
|
char szScsiDevice[1024];
|
||||||
char szMountPoint[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] == '#')
|
if( iRet != 2 || szScsiDevice[0] == '#')
|
||||||
continue; // don't process this line
|
continue; // don't process this line
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "global.h"
|
#include "global.h"
|
||||||
|
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#define ALSA_PCM_NEW_HW_PARAMS_API
|
#define ALSA_PCM_NEW_HW_PARAMS_API
|
||||||
#define ALSA_PCM_NEW_SW_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
|
* 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
|
* 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. */
|
* 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";
|
return "/proc/asound/ does not exist";
|
||||||
|
|
||||||
ASSERT( Handle == nullptr );
|
ASSERT( Handle == nullptr );
|
||||||
|
|||||||
@@ -5,6 +5,9 @@
|
|||||||
#include "ALSA9Dynamic.h"
|
#include "ALSA9Dynamic.h"
|
||||||
#include "PrefsManager.h"
|
#include "PrefsManager.h"
|
||||||
|
|
||||||
|
#include <fstream>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
/* int err; must be defined before using this macro */
|
/* int err; must be defined before using this macro */
|
||||||
#define ALSA_CHECK(x) \
|
#define ALSA_CHECK(x) \
|
||||||
if ( err < 0 ) { LOG->Info("ALSA: %s: %s", x, dsnd_strerror(err)); return false; }
|
if ( err < 0 ) { LOG->Info("ALSA: %s: %s", x, dsnd_strerror(err)); return false; }
|
||||||
@@ -140,11 +143,12 @@ void Alsa9Buf::GetSoundCardDebugInfo()
|
|||||||
return;
|
return;
|
||||||
done = true;
|
done = true;
|
||||||
|
|
||||||
if( DoesFileExist("/rootfs/proc/asound/version") )
|
std::ifstream f("/proc/asound/version");
|
||||||
|
if (f.good())
|
||||||
{
|
{
|
||||||
RString sVersion;
|
std::string version;
|
||||||
GetFileContents( "/rootfs/proc/asound/version", sVersion, true );
|
std::getline(f, version);
|
||||||
LOG->Info( "ALSA: %s", sVersion.c_str() );
|
LOG->Info( "ALSA: %s", version.c_str() );
|
||||||
}
|
}
|
||||||
|
|
||||||
InitializeErrorHandler();
|
InitializeErrorHandler();
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
#include "RageLog.h"
|
#include "RageLog.h"
|
||||||
#include "RageSound.h"
|
#include "RageSound.h"
|
||||||
#include "RageSoundManager.h"
|
#include "RageSoundManager.h"
|
||||||
#include "RageUtil.h"
|
|
||||||
|
|
||||||
#if defined(HAVE_UNISTD_H)
|
#if defined(HAVE_UNISTD_H)
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@@ -17,6 +16,7 @@
|
|||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <sys/soundcard.h>
|
#include <sys/soundcard.h>
|
||||||
#include <sys/select.h>
|
#include <sys/select.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
REGISTER_SOUND_DRIVER_CLASS( OSS );
|
REGISTER_SOUND_DRIVER_CLASS( OSS );
|
||||||
|
|
||||||
@@ -138,7 +138,8 @@ RString RageSoundDriver_OSS::CheckOSSVersion( int fd )
|
|||||||
*/
|
*/
|
||||||
#ifndef FORCE_OSS
|
#ifndef FORCE_OSS
|
||||||
#define ALSA_SNDRV_OSS_VERSION ((3<<16)|(8<<8)|(1<<4)|(0))
|
#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.";
|
return "RageSoundDriver_OSS: ALSA detected. ALSA OSS emulation is buggy; use ALSA natively.";
|
||||||
#endif
|
#endif
|
||||||
if( version )
|
if( version )
|
||||||
|
|||||||
Reference in New Issue
Block a user