1
0
mirror of https://github.com/wolfpld/tracy.git synced 2025-03-20 07:40:02 +08:00

redirect stderr to /dev/null when trying potentially incorrect flags

This commit is contained in:
Benoit Jacob 2020-11-16 23:01:44 -05:00
parent 583f43f2fe
commit 485497ee67

View File

@ -847,6 +847,10 @@ static bool TrySuCommandFlag(const char* flag) {
close( read_end ); close( read_end );
dup2( write_end, STDOUT_FILENO ); dup2( write_end, STDOUT_FILENO );
close( write_end ); close( write_end );
// We redirect stderr to /dev/null because by nature this function
// tries incorrect command lines.
int null_fd = open("/dev/null", O_WRONLY);
dup2( null_fd, STDERR_FILENO );
execlp( "su", "su", flag, "id", "-u", nullptr ); execlp( "su", "su", flag, "id", "-u", nullptr );
exit( EXIT_FAILURE ); exit( EXIT_FAILURE );
} }