Skip to content

Commit fc7037b

Browse files
committed
Linux/macOS: use absolute path of 'true' command when checking if sudo session is active.
1 parent 8574033 commit fc7037b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/Core/Unix/CoreService.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,11 @@ namespace VeraCrypt
314314
if (sudoAbsolutePath.empty())
315315
throw SystemException(SRC_POS, errorMsg);
316316

317-
std::string popenCommand = sudoAbsolutePath + " -n true > /dev/null 2>&1"; // We redirect stderr to stdout (2>&1) to be able to catch the result of the command
317+
string trueAbsolutePath = Process::FindSystemBinary("true", errorMsg);
318+
if (trueAbsolutePath.empty())
319+
throw SystemException(SRC_POS, errorMsg);
320+
321+
std::string popenCommand = sudoAbsolutePath + " -n " + trueAbsolutePath + " > /dev/null 2>&1"; // We redirect stderr to stdout (2>&1) to be able to catch the result of the command
318322
FILE* pipe = popen(popenCommand.c_str(), "r");
319323
if (pipe)
320324
{

0 commit comments

Comments
 (0)