Compare commits

...

3 Commits

Author SHA1 Message Date
499bf6dd19
gui+system: Add pledges to loginui and startui
All checks were successful
Build and test / build (push) Successful in 1m46s
2024-12-11 19:56:40 +01:00
94e7dde8af
kernel/waitpid: fix a panic-causing extraneous exclamation mark
Big oof moment.

Thankfully kernel panics sometimes just give you the exact source of the problem :P
"-- KERNEL PANIC: Check failed at kernel/src/sys/waitpid.cpp:67, in sys_waitpid: !target->dead() --"
2024-12-11 19:56:24 +01:00
f38c9e68c1
wind: Remove unneeded pledges
wind doesn't spawn child processes anymore, startui does.
2024-12-11 19:45:04 +01:00
4 changed files with 9 additions and 3 deletions

View File

@ -14,6 +14,7 @@
#include <os/FileSystem.h> #include <os/FileSystem.h>
#include <os/IPC.h> #include <os/IPC.h>
#include <os/Process.h> #include <os/Process.h>
#include <os/Security.h>
#include <pwd.h> #include <pwd.h>
#include <shadow.h> #include <shadow.h>
#include <sys/stat.h> #include <sys/stat.h>
@ -45,6 +46,8 @@ Result<int> luna_main(int argc, char** argv)
return 1; return 1;
} }
TRY(os::Security::pledge("stdio rpath wpath proc exec id", nullptr));
setsid(); setsid();
bool success = os::IPC::Notifier::run_and_wait( bool success = os::IPC::Notifier::run_and_wait(

View File

@ -58,7 +58,7 @@ Result<int> luna_main(int argc, char** argv)
{ {
srand((unsigned)time(NULL)); srand((unsigned)time(NULL));
TRY(os::Security::pledge("stdio rpath wpath cpath unix proc exec tty id", NULL)); TRY(os::Security::pledge("stdio rpath wpath cpath unix tty id", NULL));
StringView socket_path = "/tmp/wind.sock"; StringView socket_path = "/tmp/wind.sock";
StringView system_socket_path = "/tmp/wsys.sock"; StringView system_socket_path = "/tmp/wsys.sock";
@ -128,7 +128,7 @@ Result<int> luna_main(int argc, char** argv)
TRY(fds.try_append({ .fd = server->fd(), .events = POLLIN, .revents = 0 })); TRY(fds.try_append({ .fd = server->fd(), .events = POLLIN, .revents = 0 }));
TRY(fds.try_append({ .fd = system_server->fd(), .events = POLLIN, .revents = 0 })); TRY(fds.try_append({ .fd = system_server->fd(), .events = POLLIN, .revents = 0 }));
TRY(os::Security::pledge("stdio rpath wpath cpath unix proc exec", NULL)); TRY(os::Security::pledge("stdio rpath wpath cpath unix", NULL));
while (1) while (1)
{ {

View File

@ -64,7 +64,7 @@ Result<u64> sys_waitpid(Registers* regs, SyscallArgs args)
check(current->child_being_waited_for != -1); check(current->child_being_waited_for != -1);
target = TRY(Result<Process*>::from_option(Scheduler::find_by_pid(current->child_being_waited_for), ESRCH)); target = TRY(Result<Process*>::from_option(Scheduler::find_by_pid(current->child_being_waited_for), ESRCH));
check(!target->dead()); check(target->dead());
} }
else else
target = child.value(); target = child.value();

View File

@ -15,6 +15,7 @@
#include <os/IPC.h> #include <os/IPC.h>
#include <os/Main.h> #include <os/Main.h>
#include <os/Process.h> #include <os/Process.h>
#include <os/Security.h>
#include <pwd.h> #include <pwd.h>
#include <stdlib.h> #include <stdlib.h>
#include <sys/stat.h> #include <sys/stat.h>
@ -67,6 +68,8 @@ Result<int> luna_main(int argc, char** argv)
parser.add_value_argument(username, 'u', "user", "the user to start the UI session as"); parser.add_value_argument(username, 'u', "user", "the user to start the UI session as");
parser.parse(argc, argv); parser.parse(argc, argv);
TRY(os::Security::pledge("stdio rpath wpath cpath proc exec id", nullptr));
if (geteuid() != 0) if (geteuid() != 0)
{ {
os::eprintln("error: %s can only be started as root.", argv[0]); os::eprintln("error: %s can only be started as root.", argv[0]);