diff options
author | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2025-01-25 01:04:47 +0100 |
---|---|---|
committer | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2025-01-25 01:04:47 +0100 |
commit | 5ff256a53d30031d9500e38c699084efc6c3bd56 (patch) | |
tree | 22177b9d5b60f351c19a30821704fb7c98d17c95 | |
parent | e34411b5dbc7101999c47d4b2ae7c06dbe7c5bb3 (diff) | |
download | VeraCrypt-5ff256a53d30031d9500e38c699084efc6c3bd56.tar.gz VeraCrypt-5ff256a53d30031d9500e38c699084efc6c3bd56.zip |
Linux: simpler and more robust approach to detect active sudo session (#1473)
-rw-r--r-- | src/Core/Unix/CoreService.cpp | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/src/Core/Unix/CoreService.cpp b/src/Core/Unix/CoreService.cpp index 712dbab4..dc2f4e6b 100644 --- a/src/Core/Unix/CoreService.cpp +++ b/src/Core/Unix/CoreService.cpp @@ -305,8 +305,6 @@ namespace VeraCrypt bool authCheckDone = false; if (!Core->GetUseDummySudoPassword ()) { - // sudo man page: "If the -l option was specified without a command, sudo, will exit - // with a value of 0 if the user is allowed to run sudo, and they authenticated successfully" // We are using -n to avoid prompting the user for a password. // We are redirecting stderr to stdout and discarding both to avoid any output. // This approach also works on newer macOS versions (12.0 and later). @@ -316,7 +314,7 @@ namespace VeraCrypt if (sudoAbsolutePath.empty()) throw SystemException(SRC_POS, errorMsg); - std::string popenCommand = sudoAbsolutePath + " -n -l > /dev/null 2>&1"; // We redirect stderr to stdout (2>&1) to be able to catch the result of the command + std::string popenCommand = sudoAbsolutePath + " -n true > /dev/null 2>&1"; // We redirect stderr to stdout (2>&1) to be able to catch the result of the command FILE* pipe = popen(popenCommand.c_str(), "r"); if (pipe) { |