mirror of
https://github.com/veracrypt/VeraCrypt.git
synced 2025-11-11 11:08:02 -06:00
Linux: Correct handling of documentation in case of AppImage. Code refactoring.
This commit is contained in:
@@ -263,4 +263,36 @@ namespace VeraCrypt
|
||||
|
||||
return strOutput;
|
||||
}
|
||||
|
||||
#if defined(TC_LINUX)
|
||||
bool Process::IsRunningUnderAppImage (const string &executablePath)
|
||||
{
|
||||
if (executablePath.empty())
|
||||
return false;
|
||||
|
||||
// AppImage detection logic:
|
||||
// Check that APPIMAGE and APPDIR environment variables are set
|
||||
// Check that the executable path starts with APPDIR
|
||||
// Check that APPDIR itself starts with the expected AppImage mount prefix
|
||||
const char* appImageEnv = getenv("APPIMAGE");
|
||||
const char* appDirEnv = getenv("APPDIR");
|
||||
|
||||
if (appImageEnv && appDirEnv)
|
||||
{
|
||||
string appDirString = appDirEnv;
|
||||
string appImageFileString = appImageEnv;
|
||||
const string appImageMountPrefix1 = "/tmp/.mount_Veracr";
|
||||
const string appImageMountPrefix2 = "/tmp/.mount_VeraCr";
|
||||
|
||||
if (!appDirString.empty() &&
|
||||
executablePath.rfind(appDirString, 0) == 0 &&
|
||||
(appDirString.rfind(appImageMountPrefix1, 0) == 0 || appDirString.rfind(appImageMountPrefix2, 0) == 0))
|
||||
{
|
||||
// All conditions met, this is the AppImage scenario.
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user