1
0
mirror of https://github.com/veracrypt/VeraCrypt.git synced 2025-11-13 03:48:26 -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

@@ -432,28 +432,14 @@ namespace VeraCrypt
#if defined(TC_LINUX)
// AppImage specific handling:
// If running from an AppImage, and appPath is inside the AppImage's mount point (APPDIR),
// and APPDIR has the expected prefix, then use the AppImage file path (APPIMAGE) for sudo.
// If running from an AppImage, use the path to the AppImage file itself for sudo.
const char* appImageEnv = getenv("APPIMAGE");
const char* appDirEnv = getenv("APPDIR");
if (appImageEnv && appDirEnv)
{
string appDirString = appDirEnv;
string appImageFileString = appImageEnv;
const string appImageMountPrefix = "/tmp/.mount_Veracr"; // Based on observed "/tmp/.mount_VeracrXXXXXX"
// Check: APPDIR is not empty,
// appPath starts with APPDIR,
// and APPDIR itself starts with the expected AppImage mount prefix
if (!appDirString.empty() &&
appPath.rfind(appDirString, 0) == 0 &&
appDirString.rfind(appImageMountPrefix, 0) == 0)
{
// All conditions met, this is the AppImage scenario.
// Use the path to the AppImage file itself for sudo.
appPath = appImageFileString;
}
if (Process::IsRunningUnderAppImage(appPath) && appImageEnv != NULL)
{
// The path to the AppImage file is stored in the APPIMAGE environment variable.
// We need to use this path for sudo to work correctly.
appPath = appImageEnv;
}
#endif
throw_sys_if (dup2 (inPipe->GetReadFD(), STDIN_FILENO) == -1);