summaryrefslogtreecommitdiffstats
path: root/Process.c
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2017-07-26 15:40:55 -0300
committerHisham Muhammad <hisham@gobolinux.org>2017-07-26 15:40:55 -0300
commit543d65c6ab767a53844c28d9e887440dec90da1c (patch)
tree8f3dd30712aca174dd621f21e35e07a99164db70 /Process.c
parentf205f7004c2530a499175ad240e0d83e484a0961 (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.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/Process.c b/Process.c
index f31cb705..b02761c3 100644
--- a/Process.c
+++ b/Process.c
@@ -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) {

© 2014-2024 Faster IT GmbH | imprint | privacy policy