From ca331b8b349cf1a42e6219d8733ae581199961fc Mon Sep 17 00:00:00 2001 From: Mounir IDRASSI Date: Wed, 25 Dec 2024 11:29:32 +0100 Subject: Linux/macOS: Simplify sudo session detection logic and extend it to macOS This update simplifies the logic for detecting active sudo sessions by checking the exit code of the sudo -n -l command, which reliably returns 0 if a session is active. Additionally, this approach is now applicable to recent macOS versions, as they no longer have the sudo bug that previously prevented us from using this method. --- src/Main/CommandLineInterface.cpp | 4 ---- src/Main/CommandLineInterface.h | 2 -- src/Main/UserInterface.cpp | 2 -- 3 files changed, 8 deletions(-) (limited to 'src/Main') diff --git a/src/Main/CommandLineInterface.cpp b/src/Main/CommandLineInterface.cpp index 735cbeef..08042c9e 100644 --- a/src/Main/CommandLineInterface.cpp +++ b/src/Main/CommandLineInterface.cpp @@ -32,9 +32,7 @@ namespace VeraCrypt ArgAllowScreencapture (false), ArgDisableFileSizeCheck (false), ArgUseLegacyPassword (false), -#if defined(TC_LINUX ) || defined (TC_FREEBSD) ArgUseDummySudoPassword (false), -#endif StartBackgroundTask (false) { wxCmdLineParser parser; @@ -376,9 +374,7 @@ namespace VeraCrypt ArgDisableFileSizeCheck = parser.Found (L"no-size-check"); ArgUseLegacyPassword = parser.Found (L"legacy-password-maxlength"); -#if defined(TC_LINUX ) || defined (TC_FREEBSD) ArgUseDummySudoPassword = parser.Found (L"use-dummy-sudo-password"); -#endif #if !defined(TC_WINDOWS) && !defined(TC_MACOSX) if (parser.Found (L"fs-options", &str)) diff --git a/src/Main/CommandLineInterface.h b/src/Main/CommandLineInterface.h index f773ca6f..7e7b1054 100644 --- a/src/Main/CommandLineInterface.h +++ b/src/Main/CommandLineInterface.h @@ -87,9 +87,7 @@ namespace VeraCrypt bool ArgAllowScreencapture; bool ArgDisableFileSizeCheck; bool ArgUseLegacyPassword; -#if defined(TC_LINUX ) || defined (TC_FREEBSD) bool ArgUseDummySudoPassword; -#endif bool StartBackgroundTask; UserPreferences Preferences; diff --git a/src/Main/UserInterface.cpp b/src/Main/UserInterface.cpp index 81093d08..4bb8bcda 100644 --- a/src/Main/UserInterface.cpp +++ b/src/Main/UserInterface.cpp @@ -570,9 +570,7 @@ namespace VeraCrypt Core->SetAdminPasswordCallback (shared_ptr (new AdminPasswordRequestHandler)); } -#if defined(TC_LINUX ) || defined (TC_FREEBSD) Core->ForceUseDummySudoPassword (CmdLine->ArgUseDummySudoPassword); -#endif Core->WarningEvent.Connect (EventConnector (this, &UserInterface::OnWarning)); Core->VolumeMountedEvent.Connect (EventConnector (this, &UserInterface::OnVolumeMounted)); -- cgit v1.2.3