Skip to content

Commit

Permalink
FreeBSD: Fix privilege escalation prompts not showing up (#1349)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Jertzukka authored Jun 3, 2024
1 parent 6ac3b02 commit bd1e772
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Core/Unix/CoreService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit bd1e772

Please sign in to comment.