1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 13:48:12 +00:00

Kernel: Use Process::credentials() and remove user ID/group ID helpers

Move away from using the group ID/user ID helpers in the process to
allow for us to take advantage of the immutable credentials instead.
This commit is contained in:
Anthony Iacono 2022-08-20 18:21:01 -04:00 committed by Andreas Kling
parent 8026d8926c
commit f86b671de2
27 changed files with 109 additions and 94 deletions

View file

@ -34,7 +34,9 @@ ErrorOr<FlatPtr> Process::sys$sched_setparam(int pid, Userspace<const struct sch
if (!peer)
return ESRCH;
if (!is_superuser() && euid() != peer->process().uid() && uid() != peer->process().uid())
auto credentials = this->credentials();
auto peer_credentials = peer->process().credentials();
if (!credentials->is_superuser() && credentials->euid() != peer_credentials->uid() && credentials->uid() != peer_credentials->uid())
return EPERM;
peer->set_priority((u32)param.sched_priority);
@ -58,7 +60,9 @@ ErrorOr<FlatPtr> Process::sys$sched_getparam(pid_t pid, Userspace<struct sched_p
if (!peer)
return ESRCH;
if (!is_superuser() && euid() != peer->process().uid() && uid() != peer->process().uid())
auto credentials = this->credentials();
auto peer_credentials = peer->process().credentials();
if (!credentials->is_superuser() && credentials->euid() != peer_credentials->uid() && credentials->uid() != peer_credentials->uid())
return EPERM;
priority = (int)peer->priority();