From c1c9da6c35ff3f28aefb6370dad898cb85e6bcef Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Tue, 23 Nov 2021 11:18:10 +0100 Subject: [PATCH] LoginServer: Port to LibMain :^) --- Userland/Services/LoginServer/CMakeLists.txt | 2 +- Userland/Services/LoginServer/main.cpp | 52 +++++--------------- 2 files changed, 14 insertions(+), 40 deletions(-) diff --git a/Userland/Services/LoginServer/CMakeLists.txt b/Userland/Services/LoginServer/CMakeLists.txt index 972d5e9246..e341c88974 100644 --- a/Userland/Services/LoginServer/CMakeLists.txt +++ b/Userland/Services/LoginServer/CMakeLists.txt @@ -13,4 +13,4 @@ set(SOURCES ) serenity_bin(LoginServer) -target_link_libraries(LoginServer LibGUI) +target_link_libraries(LoginServer LibGUI LibMain) diff --git a/Userland/Services/LoginServer/main.cpp b/Userland/Services/LoginServer/main.cpp index 9cba441a5b..0f7c877525 100644 --- a/Userland/Services/LoginServer/main.cpp +++ b/Userland/Services/LoginServer/main.cpp @@ -6,7 +6,9 @@ #include #include +#include #include +#include #include #include #include @@ -49,46 +51,18 @@ static void login(Core::Account const& account, LoginWindow& window) window.show(); } -int main(int argc, char** argv) +ErrorOr serenity_main(Main::Arguments arguments) { - auto app = GUI::Application::construct(argc, argv); + auto app = GUI::Application::construct(arguments); - if (pledge("stdio recvfd sendfd rpath exec proc id", nullptr) < 0) { - perror("pledge"); - return 1; - } - - if (unveil("/home", "r") < 0) { - perror("unveil"); - return 1; - } - - if (unveil("/etc/passwd", "r") < 0) { - perror("unveil"); - return 1; - } - - if (unveil("/etc/shadow", "r") < 0) { - perror("unveil"); - return 1; - } - - if (unveil("/etc/group", "r") < 0) { - perror("unveil"); - return 1; - } - - if (unveil("/bin/SystemServer", "x") < 0) { - perror("unveil"); - return 1; - } - - if (unveil("/res", "r") < 0) { - perror("unveil"); - return 1; - } - - unveil(nullptr, nullptr); + TRY(Core::System::pledge("stdio recvfd sendfd rpath exec proc id", nullptr)); + TRY(Core::System::unveil("/home", "r")); + TRY(Core::System::unveil("/etc/passwd", "r")); + TRY(Core::System::unveil("/etc/shadow", "r")); + TRY(Core::System::unveil("/etc/group", "r")); + TRY(Core::System::unveil("/bin/SystemServer", "x")); + TRY(Core::System::unveil("/res", "r")); + TRY(Core::System::unveil(nullptr, nullptr)); auto window = LoginWindow::construct(); window->on_submit = [&]() { @@ -118,7 +92,7 @@ int main(int argc, char** argv) Core::ArgsParser args_parser; args_parser.add_option(auto_login, "automatically log in with no prompt", "auto-login", 'a', "username"); - args_parser.parse(argc, argv); + args_parser.parse(arguments); if (!auto_login) { window->show();