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

Linux/macOS: use absolute path of 'true' command when checking if sudo session is active.

This commit is contained in:
Mounir IDRASSI
2025-02-19 10:29:27 +01:00
parent 8574033ded
commit fc7037b670

View File

@@ -314,7 +314,11 @@ namespace VeraCrypt
if (sudoAbsolutePath.empty())
throw SystemException(SRC_POS, errorMsg);
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
string trueAbsolutePath = Process::FindSystemBinary("true", errorMsg);
if (trueAbsolutePath.empty())
throw SystemException(SRC_POS, errorMsg);
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
FILE* pipe = popen(popenCommand.c_str(), "r");
if (pipe)
{