1
0
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:
Mounir IDRASSI
2025-05-10 19:09:31 +09:00
parent 01cfc169c6
commit 3edae48717
4 changed files with 56 additions and 20 deletions

View File

@@ -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
}