wind: Use init --user and pledge()
Some checks failed
continuous-integration/drone/pr Build is failing

This commit is contained in:
apio 2023-08-14 11:07:19 +02:00
parent d56469441b
commit 64e6ee9489
Signed by: apio
GPG Key ID: B8A7D06E42258954
2 changed files with 10 additions and 2 deletions

3
base/etc/user/00-gclient Normal file
View File

@ -0,0 +1,3 @@
Name=gclient
Description=Sample user application.
Command=/usr/bin/gclient

View File

@ -7,6 +7,7 @@
#include <os/File.h> #include <os/File.h>
#include <os/LocalServer.h> #include <os/LocalServer.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 <string.h> #include <string.h>
@ -19,6 +20,8 @@ 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));
StringView socket_path = "/tmp/wind.sock"; StringView socket_path = "/tmp/wind.sock";
StringView user; StringView user;
@ -74,8 +77,8 @@ Result<int> luna_main(int argc, char** argv)
auto server = TRY(os::LocalServer::create(socket_path, false)); auto server = TRY(os::LocalServer::create(socket_path, false));
TRY(server->listen(20)); TRY(server->listen(20));
StringView args[] = { "/usr/bin/gclient"_sv }; StringView args[] = { "/usr/bin/init"_sv, "--user"_sv };
TRY(os::Process::spawn("/usr/bin/gclient"_sv, Slice<StringView> { args, 1 }, false)); TRY(os::Process::spawn("/usr/bin/init"_sv, Slice<StringView> { args, 2 }, false));
ui::Color background = ui::BLACK; ui::Color background = ui::BLACK;
@ -85,6 +88,8 @@ Result<int> luna_main(int argc, char** argv)
Vector<os::LocalServer::Client> clients; Vector<os::LocalServer::Client> clients;
TRY(os::Security::pledge("stdio rpath unix", NULL));
while (1) while (1)
{ {
screen.canvas().fill(background); screen.canvas().fill(background);