From f8fb0359ae706aa14e220ac251f6a155de44e9cb Mon Sep 17 00:00:00 2001 From: Peter Elliott Date: Thu, 7 Oct 2021 23:17:37 -0600 Subject: [PATCH] SystemServer: Add per user mode (--user) System server running in user mode will form the basis of a "session" for login purposes in serenity. --- Base/etc/SystemServer.ini | 45 +++---------------------- Userland/Services/SystemServer/main.cpp | 25 ++++++++++---- 2 files changed, 23 insertions(+), 47 deletions(-) diff --git a/Base/etc/SystemServer.ini b/Base/etc/SystemServer.ini index 189e002b366..425ac0e6bbe 100644 --- a/Base/etc/SystemServer.ini +++ b/Base/etc/SystemServer.ini @@ -99,33 +99,6 @@ SocketPermissions=600 Priority=low User=anon -[DesktopPicker.Applet] -Priority=low -KeepAlive=1 -User=anon - -[ResourceGraph.Applet] -Arguments=--cpu=CPUGraph,#00bb00 --memory=MemoryGraph,#00bbbb -Priority=low -KeepAlive=1 -User=anon - -[Audio.Applet] -Priority=low -KeepAlive=1 -User=anon - -[Network.Applet] -Arguments=--name=Network -Priority=low -KeepAlive=1 -User=anon - -[ClipboardHistory.Applet] -Priority=low -KeepAlive=1 -User=anon - [AudioServer] # TODO: It would be nice to make this lazy, but Audio.Applet connects to it immediately on startup anyway. Socket=/tmp/portal/audio @@ -134,20 +107,6 @@ KeepAlive=1 User=anon BootModes=text,graphical -[Taskbar] -KeepAlive=1 -User=anon - -[Desktop] -Executable=/bin/FileManager -Arguments=--desktop -KeepAlive=1 -User=anon - -[Terminal] -User=anon -WorkingDirectory=/home/anon - [Shell@tty0] Executable=/bin/Shell StdIO=/dev/tty0 @@ -203,3 +162,7 @@ BootModes=self-test [SpiceAgent] KeepAlive=0 + +[SystemServer] +Arguments=--user +User=anon diff --git a/Userland/Services/SystemServer/main.cpp b/Userland/Services/SystemServer/main.cpp index 2d6bd2343be..0f4c17b0c16 100644 --- a/Userland/Services/SystemServer/main.cpp +++ b/Userland/Services/SystemServer/main.cpp @@ -1,5 +1,6 @@ /* * Copyright (c) 2018-2021, Andreas Kling + * Copyright (c) 2021, Peter Elliott * * SPDX-License-Identifier: BSD-2-Clause */ @@ -8,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -456,18 +458,27 @@ static void create_tmp_coredump_directory() umask(old_umask); } -int main(int, char**) +int main(int argc, char** argv) { - mount_all_filesystems(); - prepare_synthetic_filesystems(); + bool user = false; + Core::ArgsParser args_parser; + args_parser.add_option(user, "Run in user-mode", "user", 'u'); + args_parser.parse(argc, argv); + + if (!user) { + mount_all_filesystems(); + prepare_synthetic_filesystems(); + } if (pledge("stdio proc exec tty accept unix rpath wpath cpath chown fattr id sigaction", nullptr) < 0) { perror("pledge"); return 1; } - create_tmp_coredump_directory(); - parse_boot_mode(); + if (!user) { + create_tmp_coredump_directory(); + parse_boot_mode(); + } Core::EventLoop event_loop; @@ -476,7 +487,9 @@ int main(int, char**) // Read our config and instantiate services. // This takes care of setting up sockets. NonnullRefPtrVector services; - auto config = Core::ConfigFile::open_for_system("SystemServer"); + auto config = (user) + ? Core::ConfigFile::open_for_app("SystemServer") + : Core::ConfigFile::open_for_system("SystemServer"); for (auto name : config->groups()) { auto service = Service::construct(*config, name); if (service->is_enabled())