mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 22:57:44 +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
|
@ -1,5 +1,6 @@
|
|||
#include <Kernel/Syscall.h>
|
||||
#include <LibCore/CArgsParser.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
|
@ -8,8 +9,10 @@ int main(int argc, char** argv)
|
|||
CArgsParserResult args = args_parser.parse(argc, argv);
|
||||
|
||||
if (args.is_present("n")) {
|
||||
syscall(SC_halt);
|
||||
return 0;
|
||||
if (halt() < 0) {
|
||||
perror("shutdown");
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
args_parser.print_usage();
|
||||
return 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue