1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 06:57:44 +00:00

LoginServer: Port to LibMain :^)

This commit is contained in:
Andreas Kling 2021-11-23 11:18:10 +01:00
parent c1a3968c66
commit c1c9da6c35
2 changed files with 14 additions and 40 deletions

View file

@ -13,4 +13,4 @@ set(SOURCES
) )
serenity_bin(LoginServer) serenity_bin(LoginServer)
target_link_libraries(LoginServer LibGUI) target_link_libraries(LoginServer LibGUI LibMain)

View file

@ -6,7 +6,9 @@
#include <LibCore/Account.h> #include <LibCore/Account.h>
#include <LibCore/ArgsParser.h> #include <LibCore/ArgsParser.h>
#include <LibCore/System.h>
#include <LibGUI/Application.h> #include <LibGUI/Application.h>
#include <LibMain/Main.h>
#include <Services/LoginServer/LoginWindow.h> #include <Services/LoginServer/LoginWindow.h>
#include <errno.h> #include <errno.h>
#include <string.h> #include <string.h>
@ -49,46 +51,18 @@ static void login(Core::Account const& account, LoginWindow& window)
window.show(); window.show();
} }
int main(int argc, char** argv) ErrorOr<int> 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) { TRY(Core::System::pledge("stdio recvfd sendfd rpath exec proc id", nullptr));
perror("pledge"); TRY(Core::System::unveil("/home", "r"));
return 1; TRY(Core::System::unveil("/etc/passwd", "r"));
} TRY(Core::System::unveil("/etc/shadow", "r"));
TRY(Core::System::unveil("/etc/group", "r"));
if (unveil("/home", "r") < 0) { TRY(Core::System::unveil("/bin/SystemServer", "x"));
perror("unveil"); TRY(Core::System::unveil("/res", "r"));
return 1; TRY(Core::System::unveil(nullptr, nullptr));
}
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);
auto window = LoginWindow::construct(); auto window = LoginWindow::construct();
window->on_submit = [&]() { window->on_submit = [&]() {
@ -118,7 +92,7 @@ int main(int argc, char** argv)
Core::ArgsParser args_parser; Core::ArgsParser args_parser;
args_parser.add_option(auto_login, "automatically log in with no prompt", "auto-login", 'a', "username"); 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) { if (!auto_login) {
window->show(); window->show();