FreeBSD: Fix privilege escalation prompts not showing up (#1349)

The behaviour of `wc -l` is different on FreeBSD, in which the stdout
result is padded by spaces in the beginning, which causes that the
result[0] is not actually the value we care about. This patch adds
a translate removing all whitespace from the output.
This commit is contained in:
Jertzukka 2024-06-03 09:09:54 +03:00 committed by GitHub
parent 6ac3b02a24
commit bd1e772657
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -309,7 +309,7 @@ namespace VeraCrypt
std::vector<char> buffer(128, 0);
std::string result;
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 | tr -d '[:blank:]'", "r"); // We redirect stderr to stdout (2>&1) to be able to catch the result of the command
if (pipe)
{
while (!feof(pipe))