mirror of
https://github.com/RGBCube/serenity
synced 2025-05-23 18:45:07 +00:00
Kernel: Only allow superuser to halt() the system (#342)
Following the discussion in #334, shutdown must also have root-only run permissions.
This commit is contained in:
parent
cd76b691fb
commit
a5d80f7e3b
6 changed files with 31 additions and 10 deletions
|
@ -2639,6 +2639,21 @@ int Process::sys$systrace(pid_t pid)
|
|||
return fd;
|
||||
}
|
||||
|
||||
int Process::sys$halt()
|
||||
{
|
||||
if (!is_superuser())
|
||||
return -EPERM;
|
||||
|
||||
dbgprintf("acquiring FS locks...\n");
|
||||
FS::lock_all();
|
||||
dbgprintf("syncing mounted filesystems...\n");
|
||||
FS::sync();
|
||||
dbgprintf("attempting system shutdown...\n");
|
||||
IO::out16(0x604, 0x2000);
|
||||
|
||||
return ESUCCESS;
|
||||
}
|
||||
|
||||
int Process::sys$reboot()
|
||||
{
|
||||
if (!is_superuser())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue