diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2017-07-26 15:40:55 -0300 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2017-07-26 15:40:55 -0300 |
commit | 543d65c6ab767a53844c28d9e887440dec90da1c (patch) | |
tree | 8f3dd30712aca174dd621f21e35e07a99164db70 /Process.c | |
parent | f205f7004c2530a499175ad240e0d83e484a0961 (diff) |
Security review: make privilege dropping-restoring optional.
This is/was necessary only on macOS, because you needed root in order
to read the process list. This was never necessary on Linux, and
it also raises security concerns, so now it needs to be enabled
explicitly at build time.
Diffstat (limited to 'Process.c')
-rw-r--r-- | Process.c | 10 |
1 files changed, 4 insertions, 6 deletions
@@ -522,11 +522,10 @@ void Process_toggleTag(Process* this) { } bool Process_setPriority(Process* this, int priority) { - uid_t euid = geteuid(); - (void) seteuid(getuid()); + CRT_dropPrivileges(); int old_prio = getpriority(PRIO_PROCESS, this->pid); int err = setpriority(PRIO_PROCESS, this->pid, priority); - (void) seteuid(euid); + CRT_restorePrivileges(); if (err == 0 && old_prio != getpriority(PRIO_PROCESS, this->pid)) { this->nice = priority; } @@ -538,10 +537,9 @@ bool Process_changePriorityBy(Process* this, size_t delta) { } void Process_sendSignal(Process* this, size_t sgn) { - uid_t euid = geteuid(); - (void) seteuid(getuid()); + CRT_dropPrivileges(); kill(this->pid, (int) sgn); - (void) seteuid(euid); + CRT_restorePrivileges(); } long Process_pidCompare(const void* v1, const void* v2) { |