From bd1e7726573e1834e9954d3b30c9bc255c96a840 Mon Sep 17 00:00:00 2001 From: Jertzukka Date: Mon, 3 Jun 2024 09:09:54 +0300 Subject: 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. --- src/Core/Unix/CoreService.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Core/Unix') diff --git a/src/Core/Unix/CoreService.cpp b/src/Core/Unix/CoreService.cpp index e543652a..e3fca20e 100644 --- a/src/Core/Unix/CoreService.cpp +++ b/src/Core/Unix/CoreService.cpp @@ -309,7 +309,7 @@ namespace VeraCrypt std::vector 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)) -- cgit v1.2.3