ladybird/Userland/shutdown.cpp
Jesse a5d80f7e3b Kernel: Only allow superuser to halt() the system (#342)
Following the discussion in #334, shutdown must also have root-only
run permissions.
2019-07-19 13:08:26 +02:00

20 lines
452 B
C++

#include <LibCore/CArgsParser.h>
#include <stdio.h>
#include <unistd.h>
int main(int argc, char** argv)
{
CArgsParser args_parser("shutdown");
args_parser.add_arg("n", "shut down now");
CArgsParserResult args = args_parser.parse(argc, argv);
if (args.is_present("n")) {
if (halt() < 0) {
perror("shutdown");
return 1;
}
} else {
args_parser.print_usage();
return 0;
}
}