Fix a few warnings

This commit is contained in:
Tom Ritchford
2014-05-27 12:55:44 -04:00
committed by Vinnie Falco
parent bfa8dec6f6
commit 48d4fccc22
2 changed files with 9 additions and 12 deletions

View File

@@ -73,10 +73,14 @@ bool Process::isRunningUnderDebugger()
return beast_isRunningUnderDebugger();
}
static void swapUserAndEffectiveUser()
// TODO(tom): raisePrivilege and lowerPrivilege don't seem to be called. If we
// start using them, we should deal with the return codes of setreuid() and
// setregid().
static bool swapUserAndEffectiveUser()
{
(void) setreuid (geteuid(), getuid());
(void) setregid (getegid(), getgid());
auto r1 = setreuid (geteuid(), getuid());
auto r2 = setregid (getegid(), getgid());
return !(r1 || r2);
}
void Process::raisePrivilege() { if (geteuid() != 0 && getuid() == 0) swapUserAndEffectiveUser(); }