1
0
mirror of https://github.com/veracrypt/VeraCrypt.git synced 2026-07-06 04:58:01 -05:00

Unix: add doas elevation support

Prefer sudo when available and fall back to doas on Unix. Run doas authentication through a PTY while keeping service communication on stdin/stdout pipes, and use a no-fork service mode for the doas path.

Keep doas authentication terminal descriptors close-on-exec and close the slave descriptor after attaching it as the controlling terminal. Preserve startup diagnostics through stderr until service synchronization completes, then redirect no-fork service stderr away from the closed parent pipe.

Use noninteractive privilege-helper auth checks for both sudo and doas so cached, nopass, or persisted sessions do not need an unnecessary VeraCrypt password prompt. Keep the PTY password path for doas when authentication is required.

Use a shared Unix DOAS_USER helper for FUSE and mount ownership, backed by getpwnam_r and guarded so non-OpenBSD platforms only trust it for VeraCrypt's internal doas no-fork service path. Detach asynchronous child-reaper threads to avoid leaking joinable pthread handles.
This commit is contained in:
Mounir IDRASSI
2026-06-21 18:09:09 +09:00
parent 26adb5e882
commit 47786ddce8
8 changed files with 623 additions and 131 deletions
+7 -2
View File
@@ -17,6 +17,7 @@
#include "Platform/SystemLog.h"
#include "Volume/EncryptionThreadPool.h"
#include "Core/Unix/CoreService.h"
#include "Core/Unix/UnixUser.h"
#include "Main/Application.h"
#include "Main/Main.h"
#include "Main/UserInterface.h"
@@ -43,12 +44,16 @@ int main (int argc, char **argv)
setenv ("PATH", sysPathStr.c_str(), 1);
if (argc > 1 && strcmp (argv[1], TC_CORE_SERVICE_CMDLINE_OPTION) == 0)
if (argc > 1 && (strcmp (argv[1], TC_CORE_SERVICE_CMDLINE_OPTION) == 0 || strcmp (argv[1], TC_CORE_SERVICE_NO_FORK_CMDLINE_OPTION) == 0))
{
// Process elevated requests
try
{
CoreService::ProcessElevatedRequests();
bool forkProcess = strcmp (argv[1], TC_CORE_SERVICE_CMDLINE_OPTION) == 0;
if (!forkProcess)
setenv (TC_DOAS_CORE_SERVICE_ENV, "1", 1);
CoreService::ProcessElevatedRequests (forkProcess);
return 0;
}
catch (exception &e)