1
0
mirror of https://github.com/veracrypt/VeraCrypt.git synced 2025-11-11 02:58:02 -06:00

Linux/FreeBSD: Fix privilege escalation prompts being ignored (#1100)

Currently if you fail the privilege escalation prompt, the second
one and consecutively every second will be ignored. This is because
if we do not --use-dummy-sudo-password and are on Linux/FreeBSD,
we will be prompted for password twice for one evaluation in the
while(!ElevatedServiceAvailable) loop.

For the fix, we make sure that we run the prompt only once for each
case.
This commit is contained in:
Jertzukka
2023-06-10 02:07:27 +03:00
committed by GitHub
parent 9ad75aaa0f
commit 0ffd61a55c

View File

@@ -303,12 +303,11 @@ namespace VeraCrypt
// We also use the old way if the user is forcing the use of dummy password for sudo // We also use the old way if the user is forcing the use of dummy password for sudo
#if defined(TC_LINUX ) || defined (TC_FREEBSD) #if defined(TC_LINUX ) || defined (TC_FREEBSD)
bool authCheckDone = false;
if (!Core->GetUseDummySudoPassword ()) if (!Core->GetUseDummySudoPassword ())
{ {
std::vector<char> buffer(128, 0); std::vector<char> buffer(128, 0);
std::string result; std::string result;
bool authCheckDone = false;
FILE* pipe = popen("sudo -n uptime 2>&1 | grep 'load average' | wc -l", "r"); // We redirect stderr to stdout (2>&1) to be able to catch the result of the command FILE* pipe = popen("sudo -n uptime 2>&1 | grep 'load average' | wc -l", "r"); // We redirect stderr to stdout (2>&1) to be able to catch the result of the command
if (pipe) if (pipe)
@@ -354,7 +353,10 @@ namespace VeraCrypt
} }
request.FastElevation = false; request.FastElevation = false;
(*AdminPasswordCallback) (request.AdminPassword); #if defined(TC_LINUX ) || defined (TC_FREEBSD)
if(!authCheckDone)
#endif
(*AdminPasswordCallback) (request.AdminPassword);
} }
} }
} }