1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 06:58:11 +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

@ -625,7 +625,8 @@ ErrorOr<void> IPv4Socket::ioctl(OpenFileDescription&, unsigned request, Userspac
switch (request) {
case SIOCADDRT: {
if (!Process::current().is_superuser())
auto current_process_credentials = Process::current().credentials();
if (!current_process_credentials->is_superuser())
return EPERM;
if (route.rt_gateway.sa_family != AF_INET)
return EAFNOSUPPORT;
@ -639,7 +640,8 @@ ErrorOr<void> IPv4Socket::ioctl(OpenFileDescription&, unsigned request, Userspac
return update_routing_table(destination, gateway, genmask, route.rt_flags, adapter, UpdateTable::Set);
}
case SIOCDELRT:
if (!Process::current().is_superuser())
auto current_process_credentials = Process::current().credentials();
if (!current_process_credentials->is_superuser())
return EPERM;
if (route.rt_gateway.sa_family != AF_INET)
return EAFNOSUPPORT;
@ -659,9 +661,11 @@ ErrorOr<void> IPv4Socket::ioctl(OpenFileDescription&, unsigned request, Userspac
arpreq arp_req;
TRY(copy_from_user(&arp_req, user_req));
auto current_process_credentials = Process::current().credentials();
switch (request) {
case SIOCSARP:
if (!Process::current().is_superuser())
if (!current_process_credentials->is_superuser())
return EPERM;
if (arp_req.arp_pa.sa_family != AF_INET)
return EAFNOSUPPORT;
@ -669,7 +673,7 @@ ErrorOr<void> IPv4Socket::ioctl(OpenFileDescription&, unsigned request, Userspac
return {};
case SIOCDARP:
if (!Process::current().is_superuser())
if (!current_process_credentials->is_superuser())
return EPERM;
if (arp_req.arp_pa.sa_family != AF_INET)
return EAFNOSUPPORT;
@ -693,9 +697,11 @@ ErrorOr<void> IPv4Socket::ioctl(OpenFileDescription&, unsigned request, Userspac
if (!adapter)
return ENODEV;
auto current_process_credentials = Process::current().credentials();
switch (request) {
case SIOCSIFADDR:
if (!Process::current().is_superuser())
if (!current_process_credentials->is_superuser())
return EPERM;
if (ifr.ifr_addr.sa_family != AF_INET)
return EAFNOSUPPORT;
@ -703,7 +709,7 @@ ErrorOr<void> IPv4Socket::ioctl(OpenFileDescription&, unsigned request, Userspac
return {};
case SIOCSIFNETMASK:
if (!Process::current().is_superuser())
if (!current_process_credentials->is_superuser())
return EPERM;
if (ifr.ifr_addr.sa_family != AF_INET)
return EAFNOSUPPORT;