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:
@@ -40,9 +40,6 @@
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
#ifdef TC_OPENBSD
|
||||
#include <pwd.h>
|
||||
#endif
|
||||
#include <sys/mman.h>
|
||||
#include <sys/statvfs.h>
|
||||
#include <sys/time.h>
|
||||
@@ -55,6 +52,7 @@
|
||||
#include "Platform/SystemLog.h"
|
||||
#include "Platform/Unix/Pipe.h"
|
||||
#include "Platform/Unix/Poller.h"
|
||||
#include "Core/Unix/UnixUser.h"
|
||||
#include "Volume/EncryptionThreadPool.h"
|
||||
#include "Core/Core.h"
|
||||
|
||||
@@ -68,26 +66,6 @@ namespace VeraCrypt
|
||||
static const uint64 VC_FUSE_METADATA_SIZE = 64 * 1024;
|
||||
static const uint64 VC_FUSE_STAT_BLOCK_SIZE = 512;
|
||||
|
||||
#ifdef TC_OPENBSD
|
||||
static bool fuse_service_get_doas_user_ids (uid_t *uid, gid_t *gid)
|
||||
{
|
||||
const char *env = getenv ("DOAS_USER");
|
||||
if (!env || !env[0])
|
||||
return false;
|
||||
|
||||
struct passwd *pw = getpwnam (env);
|
||||
if (!pw)
|
||||
return false;
|
||||
|
||||
if (uid)
|
||||
*uid = pw->pw_uid;
|
||||
if (gid)
|
||||
*gid = pw->pw_gid;
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
static uint64 fuse_service_ceil_div (uint64 value, uint64 divisor)
|
||||
{
|
||||
return (value / divisor) + ((value % divisor) ? 1 : 0);
|
||||
@@ -813,18 +791,16 @@ namespace VeraCrypt
|
||||
}
|
||||
catch (...) { }
|
||||
}
|
||||
#ifdef TC_OPENBSD
|
||||
else
|
||||
{
|
||||
uid_t doasUid;
|
||||
gid_t doasGid;
|
||||
if (fuse_service_get_doas_user_ids (&doasUid, &doasGid))
|
||||
if (GetDoasUserIds (&doasUid, &doasGid))
|
||||
{
|
||||
FuseService::UserId = doasUid;
|
||||
FuseService::GroupId = doasGid;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static fuse_operations fuse_service_oper;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user