diff options
author | Andreas Kling <kling@serenityos.org> | 2021-11-23 10:59:50 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-11-23 11:33:36 +0100 |
commit | 21a5fb0fa21a92030f68bc6e9df6a9e438355f11 (patch) | |
tree | 9883ba94b650d2a6fd97f38942ba40ac3da35694 | |
parent | acc2eccede491e0c34d718e348d76c13c190347c (diff) | |
download | serenity-21a5fb0fa21a92030f68bc6e9df6a9e438355f11.zip |
LibCore+LibSystem: Move syscall wrappers from LibSystem to LibCore
With this change, System::foo() becomes Core::System::foo().
Since LibCore builds on other systems than SerenityOS, we now have to
make sure that wrappers work with just a standard C library underneath.
32 files changed, 165 insertions, 173 deletions
diff --git a/Userland/Applets/ResourceGraph/main.cpp b/Userland/Applets/ResourceGraph/main.cpp index 402ca85f1f..966039a445 100644 --- a/Userland/Applets/ResourceGraph/main.cpp +++ b/Userland/Applets/ResourceGraph/main.cpp @@ -9,13 +9,13 @@ #include <AK/JsonObject.h> #include <LibCore/ArgsParser.h> #include <LibCore/File.h> +#include <LibCore/System.h> #include <LibGUI/Application.h> #include <LibGUI/Frame.h> #include <LibGUI/Painter.h> #include <LibGUI/Window.h> #include <LibGfx/Palette.h> #include <LibMain/Main.h> -#include <LibSystem/Wrappers.h> #include <serenity.h> #include <spawn.h> #include <stdio.h> @@ -185,11 +185,11 @@ private: ErrorOr<int> serenity_main(Main::Arguments arguments) { - TRY(System::pledge("stdio recvfd sendfd proc exec rpath unix", nullptr)); + TRY(Core::System::pledge("stdio recvfd sendfd proc exec rpath unix", nullptr)); auto app = GUI::Application::construct(arguments); - TRY(System::pledge("stdio recvfd sendfd proc exec rpath", nullptr)); + TRY(Core::System::pledge("stdio recvfd sendfd proc exec rpath", nullptr)); const char* cpu = nullptr; const char* memory = nullptr; @@ -231,11 +231,11 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) if (memory) create_applet(GraphType::Memory, memory); - TRY(System::unveil("/res", "r")); - TRY(System::unveil("/proc/stat", "r")); - TRY(System::unveil("/proc/memstat", "r")); - TRY(System::unveil("/bin/SystemMonitor", "x")); - TRY(System::unveil(nullptr, nullptr)); + TRY(Core::System::unveil("/res", "r")); + TRY(Core::System::unveil("/proc/stat", "r")); + TRY(Core::System::unveil("/proc/memstat", "r")); + TRY(Core::System::unveil("/bin/SystemMonitor", "x")); + TRY(Core::System::unveil(nullptr, nullptr)); return app->exec(); } diff --git a/Userland/Applications/3DFileViewer/main.cpp b/Userland/Applications/3DFileViewer/main.cpp index d9bdb12e24..96be3b80f9 100644 --- a/Userland/Applications/3DFileViewer/main.cpp +++ b/Userland/Applications/3DFileViewer/main.cpp @@ -6,6 +6,7 @@ #include <LibCore/ElapsedTimer.h> #include <LibCore/File.h> +#include <LibCore/System.h> #include <LibFileSystemAccessClient/Client.h> #include <LibGL/GL/gl.h> #include <LibGL/GLContext.h> @@ -23,7 +24,6 @@ #include <LibGfx/Bitmap.h> #include <LibGfx/Palette.h> #include <LibMain/Main.h> -#include <LibSystem/Wrappers.h> #include "Mesh.h" #include "WavefrontOBJLoader.h" @@ -286,13 +286,13 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) { auto app = GUI::Application::construct(arguments); - TRY(System::pledge("stdio thread recvfd sendfd rpath unix", nullptr)); + TRY(Core::System::pledge("stdio thread recvfd sendfd rpath unix", nullptr)); - TRY(System::unveil("/tmp/portal/filesystemaccess", "rw")); - TRY(System::unveil("/home/anon/Documents/3D Models/teapot.obj", "r")); - TRY(System::unveil("/home/anon/Documents/3D Models/teapot.bmp", "r")); - TRY(System::unveil("/res", "r")); - TRY(System::unveil(nullptr, nullptr)); + TRY(Core::System::unveil("/tmp/portal/filesystemaccess", "rw")); + TRY(Core::System::unveil("/home/anon/Documents/3D Models/teapot.obj", "r")); + TRY(Core::System::unveil("/home/anon/Documents/3D Models/teapot.bmp", "r")); + TRY(Core::System::unveil("/res", "r")); + TRY(Core::System::unveil(nullptr, nullptr)); // Construct the main window auto window = GUI::Window::construct(); diff --git a/Userland/Applications/Browser/main.cpp b/Userland/Applications/Browser/main.cpp index 9677c2f483..339deb19aa 100644 --- a/Userland/Applications/Browser/main.cpp +++ b/Userland/Applications/Browser/main.cpp @@ -14,13 +14,13 @@ #include <LibCore/ArgsParser.h> #include <LibCore/File.h> #include <LibCore/StandardPaths.h> +#include <LibCore/System.h> #include <LibDesktop/Launcher.h> #include <LibGUI/Application.h> #include <LibGUI/BoxLayout.h> #include <LibGUI/Icon.h> #include <LibGUI/TabWidget.h> #include <LibMain/Main.h> -#include <LibSystem/Wrappers.h> #include <stdio.h> #include <unistd.h> @@ -39,7 +39,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) return 1; } - TRY(System::pledge("stdio recvfd sendfd unix cpath rpath wpath", nullptr)); + TRY(Core::System::pledge("stdio recvfd sendfd unix cpath rpath wpath", nullptr)); const char* specified_url = nullptr; @@ -60,13 +60,13 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) return 1; } - TRY(System::unveil("/home", "rwc")); - TRY(System::unveil("/res", "r")); - TRY(System::unveil("/etc/passwd", "r")); - TRY(System::unveil("/tmp/portal/image", "rw")); - TRY(System::unveil("/tmp/portal/webcontent", "rw")); - TRY(System::unveil("/tmp/portal/request", "rw")); - TRY(System::unveil(nullptr, nullptr)); + TRY(Core::System::unveil("/home", "rwc")); + TRY(Core::System::unveil("/res", "r")); + TRY(Core::System::unveil("/etc/passwd", "r")); + TRY(Core::System::unveil("/tmp/portal/image", "rw")); + TRY(Core::System::unveil("/tmp/portal/webcontent", "rw")); + TRY(Core::System::unveil("/tmp/portal/request", "rw")); + TRY(Core::System::unveil(nullptr, nullptr)); auto app_icon = GUI::Icon::default_icon("app-browser"); diff --git a/Userland/Applications/FileManager/main.cpp b/Userland/Applications/FileManager/main.cpp index 28f5f18235..abd77e71d2 100644 --- a/Userland/Applications/FileManager/main.cpp +++ b/Userland/Applications/FileManager/main.cpp @@ -19,6 +19,7 @@ #include <LibCore/ArgsParser.h> #include <LibCore/File.h> #include <LibCore/StandardPaths.h> +#include <LibCore/System.h> #include <LibDesktop/Launcher.h> #include <LibGUI/Action.h> #include <LibGUI/ActionGroup.h> @@ -43,7 +44,6 @@ #include <LibGUI/Window.h> #include <LibGfx/Palette.h> #include <LibMain/Main.h> -#include <LibSystem/Wrappers.h> #include <pthread.h> #include <signal.h> #include <stdio.h> @@ -64,12 +64,12 @@ static bool add_launch_handler_actions_to_menu(RefPtr<GUI::Menu>& menu, Director ErrorOr<int> serenity_main(Main::Arguments arguments) { - TRY(System::pledge("stdio thread recvfd sendfd unix cpath rpath wpath fattr proc exec sigaction", nullptr)); + TRY(Core::System::pledge("stdio thread recvfd sendfd unix cpath rpath wpath fattr proc exec sigaction", nullptr)); struct sigaction act = {}; act.sa_flags = SA_NOCLDWAIT; act.sa_handler = SIG_IGN; - TRY(System::sigaction(SIGCHLD, &act, nullptr)); + TRY(Core::System::sigaction(SIGCHLD, &act, nullptr)); Core::ArgsParser args_parser; bool is_desktop_mode { false }, is_selection_mode { false }, ignore_path_resolution { false }; @@ -82,7 +82,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) auto app = GUI::Application::construct(arguments); - TRY(System::pledge("stdio thread recvfd sendfd cpath rpath wpath fattr proc exec unix", nullptr)); + TRY(Core::System::pledge("stdio thread recvfd sendfd cpath rpath wpath fattr proc exec unix", nullptr)); Config::pledge_domains({ "FileManager", "WindowManager" }); Config::monitor_domain("FileManager"); diff --git a/Userland/Applications/Mail/main.cpp b/Userland/Applications/Mail/main.cpp index c2f56bced9..83a6931434 100644 --- a/Userland/Applications/Mail/main.cpp +++ b/Userland/Applications/Mail/main.cpp @@ -6,27 +6,27 @@ #include "MailWidget.h" #include <LibConfig/Client.h> +#include <LibCore/System.h> #include <LibGUI/Application.h> #include <LibGUI/Icon.h> #include <LibGUI/Menu.h> #include <LibGUI/Menubar.h> #include <LibGUI/Window.h> #include <LibMain/Main.h> -#include <LibSystem/Wrappers.h> ErrorOr<int> serenity_main(Main::Arguments arguments) { - TRY(System::pledge("stdio recvfd sendfd rpath unix inet", nullptr)); + TRY(Core::System::pledge("stdio recvfd sendfd rpath unix inet", nullptr)); auto app = GUI::Application::construct(arguments); Config::pledge_domains("Mail"); - TRY(System::unveil("/res", "r")); - TRY(System::unveil("/etc", "r")); - TRY(System::unveil("/tmp/portal/webcontent", "rw")); - TRY(System::unveil("/tmp/portal/lookup", "rw")); - TRY(System::unveil(nullptr, nullptr)); + TRY(Core::System::unveil("/res", "r")); + TRY(Core::System::unveil("/etc", "r")); + TRY(Core::System::unveil("/tmp/portal/webcontent", "rw")); + TRY(Core::System::unveil("/tmp/portal/lookup", "rw")); + TRY(Core::System::unveil(nullptr, nullptr)); auto window = GUI::Window::construct(); diff --git a/Userland/Applications/PDFViewer/main.cpp b/Userland/Applications/PDFViewer/main.cpp index 7f608e1a14..89854efc26 100644 --- a/Userland/Applications/PDFViewer/main.cpp +++ b/Userland/Applications/PDFViewer/main.cpp @@ -6,6 +6,7 @@ */ #include "PDFViewerWidget.h" +#include <LibCore/System.h> #include <LibFileSystemAccessClient/Client.h> #include <LibGUI/Application.h> #include <LibGUI/Icon.h> @@ -13,7 +14,6 @@ #include <LibGUI/MessageBox.h> #include <LibGUI/Window.h> #include <LibMain/Main.h> -#include <LibSystem/Wrappers.h> ErrorOr<int> serenity_main(Main::Arguments arguments) { @@ -24,9 +24,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) window->set_title("PDF Viewer"); window->resize(640, 400); - TRY(System::unveil("/res", "r")); - TRY(System::unveil("/tmp/portal/filesystemaccess", "rw")); - TRY(System::unveil(nullptr, nullptr)); + TRY(Core::System::unveil("/res", "r")); + TRY(Core::System::unveil("/tmp/portal/filesystemaccess", "rw")); + TRY(Core::System::unveil(nullptr, nullptr)); auto& pdf_viewer_widget = window->set_main_widget<PDFViewerWidget>(); diff --git a/Userland/Applications/Piano/main.cpp b/Userland/Applications/Piano/main.cpp index 04eada0410..4f8d48fc3e 100644 --- a/Userland/Applications/Piano/main.cpp +++ b/Userland/Applications/Piano/main.cpp @@ -15,6 +15,7 @@ #include <LibAudio/ClientConnection.h> #include <LibAudio/WavWriter.h> #include <LibCore/EventLoop.h> +#include <LibCore/System.h> #include <LibGUI/Action.h> #include <LibGUI/Application.h> #include <LibGUI/FilePicker.h> @@ -23,11 +24,10 @@ #include <LibGUI/MessageBox.h> #include <LibGUI/Window.h> #include <LibMain/Main.h> -#include <LibSystem/Wrappers.h> ErrorOr<int> serenity_main(Main::Arguments arguments) { - TRY(System::pledge("stdio thread rpath cpath wpath recvfd sendfd unix", nullptr)); + TRY(Core::System::pledge("stdio thread rpath cpath wpath recvfd sendfd unix", nullptr)); auto app = GUI::Application::construct(arguments); diff --git a/Userland/Applications/PixelPaint/main.cpp b/Userland/Applications/PixelPaint/main.cpp index 98e62aff3f..1c1cd1443b 100644 --- a/Userland/Applications/PixelPaint/main.cpp +++ b/Userland/Applications/PixelPaint/main.cpp @@ -8,6 +8,7 @@ #include "MainWidget.h" #include <LibConfig/Client.h> #include <LibCore/ArgsParser.h> +#include <LibCore/System.h> #include <LibFileSystemAccessClient/Client.h> #include <LibGUI/Action.h> #include <LibGUI/Application.h> @@ -17,11 +18,10 @@ #include <LibGUI/Window.h> #include <LibGfx/Painter.h> #include <LibMain/Main.h> -#include <LibSystem/Wrappers.h> ErrorOr<int> serenity_main(Main::Arguments arguments) { - TRY(System::pledge("stdio thread recvfd sendfd rpath unix wpath cpath", nullptr)); + TRY(Core::System::pledge("stdio thread recvfd sendfd rpath unix wpath cpath", nullptr)); auto app = GUI::Application::construct(arguments); Config::pledge_domains("PixelPaint"); @@ -31,11 +31,11 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) args_parser.add_positional_argument(image_file, "Image file to open", "path", Core::ArgsParser::Required::No); args_parser.parse(arguments); - TRY(System::unveil("/res", "r")); - TRY(System::unveil("/tmp/portal/clipboard", "rw")); - TRY(System::unveil("/tmp/portal/filesystemaccess", "rw")); - TRY(System::unveil("/tmp/portal/image", "rw")); - TRY(System::unveil(nullptr, nullptr)); + TRY(Core::System::unveil("/res", "r")); + TRY(Core::System::unveil("/tmp/portal/clipboard", "rw")); + TRY(Core::System::unveil("/tmp/portal/filesystemaccess", "rw")); + TRY(Core::System::unveil("/tmp/portal/image", "rw")); + TRY(Core::System::unveil(nullptr, nullptr)); auto app_icon = GUI::Icon::default_icon("app-pixel-paint"); diff --git a/Userland/Applications/Terminal/main.cpp b/Userland/Applications/Terminal/main.cpp index 78831be5d2..6c28703826 100644 --- a/Userland/Applications/Terminal/main.cpp +++ b/Userland/Applications/Terminal/main.cpp @@ -11,6 +11,7 @@ #include <LibCore/ArgsParser.h> #include <LibCore/DirIterator.h> #include <LibCore/Process.h> +#include <LibCore/System.h> #include <LibDesktop/Launcher.h> #include <LibGUI/Action.h> #include <LibGUI/ActionGroup.h> @@ -33,7 +34,6 @@ #include <LibGUI/Window.h> #include <LibGfx/Palette.h> #include <LibMain/Main.h> -#include <LibSystem/Wrappers.h> #include <LibVT/TerminalWidget.h> #include <assert.h> #include <errno.h> @@ -252,18 +252,18 @@ static RefPtr<GUI::Window> create_find_window(VT::TerminalWidget& terminal) ErrorOr<int> serenity_main(Main::Arguments arguments) { - TRY(System::pledge("stdio tty rpath cpath wpath recvfd sendfd proc exec unix sigaction", nullptr)); + TRY(Core::System::pledge("stdio tty rpath cpath wpath recvfd sendfd proc exec unix sigaction", nullptr)); struct sigaction act; memset(&act, 0, sizeof(act)); act.sa_flags = SA_NOCLDWAIT; act.sa_handler = SIG_IGN; - TRY(System::sigaction(SIGCHLD, &act, nullptr)); + TRY(Core::System::sigaction(SIGCHLD, &act, nullptr)); auto app = GUI::Application::construct(arguments); - TRY(System::pledge("stdio tty rpath cpath wpath recvfd sendfd proc exec unix", nullptr)); + TRY(Core::System::pledge("stdio tty rpath cpath wpath recvfd sendfd proc exec unix", nullptr)); Config::pledge_domains("Terminal"); @@ -422,14 +422,14 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) settings_window->close(); }; - TRY(System::unveil("/res", "r")); - TRY(System::unveil("/bin", "r")); - TRY(System::unveil("/bin/Terminal", "x")); - TRY(System::unveil("/bin/utmpupdate", "x")); - TRY(System::unveil("/etc/FileIconProvider.ini", "r")); - TRY(System::unveil("/tmp/portal/launch", "rw")); - TRY(System::unveil("/tmp/portal/config", "rw")); - TRY(System::unveil(nullptr, nullptr)); + TRY(Core::System::unveil("/res", "r")); + TRY(Core::System::unveil("/bin", "r")); + TRY(Core::System::unveil("/bin/Terminal", "x")); + TRY(Core::System::unveil("/bin/utmpupdate", "x")); + TRY(Core::System::unveil("/etc/FileIconProvider.ini", "r")); + TRY(Core::System::unveil("/tmp/portal/launch", "rw")); + TRY(Core::System::unveil("/tmp/portal/config", "rw")); + TRY(Core::System::unveil(nullptr, nullptr)); window->show(); int result = app->exec(); diff --git a/Userland/Demos/Starfield/Starfield.cpp b/Userland/Demos/Starfield/Starfield.cpp index 0f04f5cd5d..1bde670b41 100644 --- a/Userland/Demos/Starfield/Starfield.cpp +++ b/Userland/Demos/Starfield/Starfield.cpp @@ -6,6 +6,7 @@ #include <AK/Vector.h> #include <LibCore/ArgsParser.h> +#include <LibCore/System.h> #include <LibGUI/Application.h> #include <LibGUI/Event.h> #include <LibGUI/Icon.h> @@ -14,7 +15,6 @@ #include <LibGUI/Window.h> #include <LibGfx/Bitmap.h> #include <LibMain/Main.h> -#include <LibSystem/Wrappers.h> #include <stdio.h> #include <time.h> @@ -149,7 +149,7 @@ void Starfield::draw() ErrorOr<int> serenity_main(Main::Arguments arguments) { - TRY(System::pledge("stdio recvfd sendfd rpath unix", nullptr)); + TRY(Core::System::pledge("stdio recvfd sendfd rpath unix", nullptr)); unsigned star_count = 1000; unsigned refresh_rate = 16; @@ -164,7 +164,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) auto app = GUI::Application::construct(arguments); - TRY(System::pledge("stdio recvfd sendfd rpath", nullptr)); + TRY(Core::System::pledge("stdio recvfd sendfd rpath", nullptr)); auto app_icon = GUI::Icon::default_icon("app-screensaver"); auto window = GUI::Window::construct(); diff --git a/Userland/DevTools/HackStudio/LanguageServers/Cpp/main.cpp b/Userland/DevTools/HackStudio/LanguageServers/Cpp/main.cpp index 70c78735c3..6b3b3100f5 100644 --- a/Userland/DevTools/HackStudio/LanguageServers/Cpp/main.cpp +++ b/Userland/DevTools/HackStudio/LanguageServers/Cpp/main.cpp @@ -10,9 +10,9 @@ #include <LibCore/ArgsParser.h> #include <LibCore/EventLoop.h> #include <LibCore/LocalServer.h> +#include <LibCore/System.h> #include <LibIPC/ClientConnection.h> #include <LibMain/Main.h> -#include <LibSystem/Wrappers.h> #include <unistd.h> static ErrorOr<int> mode_server(); @@ -34,13 +34,13 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) ErrorOr<int> mode_server() { Core::EventLoop event_loop; - TRY(System::pledge("stdio unix recvfd rpath ", nullptr)); + TRY(Core::System::pledge("stdio unix recvfd rpath ", nullptr)); auto socket = Core::LocalSocket::take_over_accepted_socket_from_system_server(); IPC::new_client_connection<LanguageServers::Cpp::ClientConnection>(socket.release_nonnull(), 1); - TRY(System::pledge("stdio recvfd rpath", nullptr)); - TRY(System::unveil("/usr/include", "r")); + TRY(Core::System::pledge("stdio recvfd rpath", nullptr)); + TRY(Core::System::unveil("/usr/include", "r")); // unveil will be sealed later, when we know the project's root path. return event_loop.exec(); diff --git a/Userland/DevTools/HackStudio/LanguageServers/Shell/main.cpp b/Userland/DevTools/HackStudio/LanguageServers/Shell/main.cpp index be46401579..ef7800e9f6 100644 --- a/Userland/DevTools/HackStudio/LanguageServers/Shell/main.cpp +++ b/Userland/DevTools/HackStudio/LanguageServers/Shell/main.cpp @@ -7,19 +7,19 @@ #include "ClientConnection.h" #include <LibCore/EventLoop.h> #include <LibCore/LocalServer.h> +#include <LibCore/System.h> #include <LibIPC/ClientConnection.h> #include <LibMain/Main.h> -#include <LibSystem/Wrappers.h> ErrorOr<int> serenity_main(Main::Arguments) { Core::EventLoop event_loop; - TRY(System::pledge("stdio unix rpath recvfd", nullptr)); + TRY(Core::System::pledge("stdio unix rpath recvfd", nullptr)); auto socket = Core::LocalSocket::take_over_accepted_socket_from_system_server(); IPC::new_client_connection<LanguageServers::Shell::ClientConnection>(socket.release_nonnull(), 1); - TRY(System::pledge("stdio rpath recvfd", nullptr)); - TRY(System::unveil("/etc/passwd", "r")); + TRY(Core::System::pledge("stdio rpath recvfd", nullptr)); + TRY(Core::System::unveil("/etc/passwd", "r")); return event_loop.exec(); } diff --git a/Userland/Games/2048/main.cpp b/Userland/Games/2048/main.cpp index 989d318a57..bc474c6737 100644 --- a/Userland/Games/2048/main.cpp +++ b/Userland/Games/2048/main.cpp @@ -8,6 +8,7 @@ #include "Game.h" #include "GameSizeDialog.h" #include <LibConfig/Client.h> +#include <LibCore/System.h> #include <LibGUI/Action.h> #include <LibGUI/Application.h> #include <LibGUI/BoxLayout.h> @@ -20,13 +21,12 @@ #include <LibGUI/Window.h> #include <LibGfx/Painter.h> #include <LibMain/Main.h> -#include <LibSystem/Wrappers.h> #include <stdio.h> #include <time.h> ErrorOr<int> serenity_main(Main::Arguments arguments) { - TRY(System::pledge("stdio rpath recvfd sendfd unix", nullptr)); + TRY(Core::System::pledge("stdio rpath recvfd sendfd unix", nullptr)); srand(time(nullptr)); @@ -37,10 +37,10 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) Config::pledge_domains("2048"); - TRY(System::pledge("stdio rpath recvfd sendfd", nullptr)); + TRY(Core::System::pledge("stdio rpath recvfd sendfd", nullptr)); - TRY(System::unveil("/res", "r")); - TRY(System::unveil(nullptr, nullptr)); + TRY(Core::System::unveil("/res", "r")); + TRY(Core::System::unveil(nullptr, nullptr)); size_t board_size = Config::read_i32("2048", "", "board_size", 4); u32 target_tile = Config::read_i32("2048", "", "target_tile", 2048); diff --git a/Userland/Games/Breakout/main.cpp b/Userland/Games/Breakout/main.cpp index 54628c28d5..7017e2e12d 100644 --- a/Userland/Games/Breakout/main.cpp +++ b/Userland/Games/Breakout/main.cpp @@ -5,6 +5,7 @@ */ #include "Game.h" +#include <LibCore/System.h> #include <LibGUI/Application.h> #include <LibGUI/Icon.h> #include <LibGUI/Menu.h> @@ -12,18 +13,17 @@ #include <LibGUI/Window.h> #include <LibGfx/Bitmap.h> #include <LibMain/Main.h> -#include <LibSystem/Wrappers.h> ErrorOr<int> serenity_main(Main::Arguments arguments) { - TRY(System::pledge("stdio recvfd sendfd rpath unix", nullptr)); + TRY(Core::System::pledge("stdio recvfd sendfd rpath unix", nullptr)); auto app = GUI::Application::construct(arguments); - TRY(System::pledge("stdio recvfd sendfd rpath", nullptr)); + TRY(Core::System::pledge("stdio recvfd sendfd rpath", nullptr)); - TRY(System::unveil("/res", "r")); - TRY(System::unveil(nullptr, nullptr)); + TRY(Core::System::unveil("/res", "r")); + TRY(Core::System::unveil(nullptr, nullptr)); auto window = GUI::Window::construct(); window->resize(Breakout::Game::game_width, Breakout::Game::game_height); diff --git a/Userland/Games/Chess/main.cpp b/Userland/Games/Chess/main.cpp index 9408ffe9c5..8d67dbdd13 100644 --- a/Userland/Games/Chess/main.cpp +++ b/Userland/Games/Chess/main.cpp @@ -7,6 +7,7 @@ #include "ChessWidget.h" #include <LibConfig/Client.h> #include <LibCore/DirIterator.h> +#include <LibCore/System.h> #include <LibGUI/ActionGroup.h> #include <LibGUI/Application.h> #include <LibGUI/Clipboard.h> @@ -17,28 +18,27 @@ #include <LibGUI/MessageBox.h> #include <LibGUI/Window.h> #include <LibMain/Main.h> -#include <LibSystem/Wrappers.h> ErrorOr<int> serenity_main(Main::Arguments arguments) { - TRY(System::pledge("stdio rpath wpath cpath recvfd sendfd thread proc exec unix", nullptr)); + TRY(Core::System::pledge("stdio rpath wpath cpath recvfd sendfd thread proc exec unix", nullptr)); auto app = GUI::Application::construct(arguments); Config::pledge_domains("Chess"); - TRY(System::pledge("stdio rpath wpath cpath recvfd sendfd thread proc exec", nullptr)); + TRY(Core::System::pledge("stdio rpath wpath cpath recvfd sendfd thread proc exec", nullptr)); auto app_icon = GUI::Icon::default_icon("app-chess"); auto window = GUI::Window::construct(); auto& widget = window->set_main_widget<ChessWidget>(); - TRY(System::unveil("/res", "r")); - TRY(System::unveil("/bin/ChessEngine", "x")); - TRY(System::unveil("/etc/passwd", "r")); - TRY(System::unveil(Core::StandardPaths::home_directory().characters(), "wcbr")); - TRY(System::unveil(nullptr, nullptr)); + TRY(Core::System::unveil("/res", "r")); + TRY(Core::System::unveil("/bin/ChessEngine", "x")); + TRY(Core::System::unveil("/etc/passwd", "r")); + TRY(Core::System::unveil(Core::StandardPaths::home_directory().characters(), "wcbr")); + TRY(Core::System::unveil(nullptr, nullptr)); auto size = Config::read_i32("Chess", "Display", "size", 512); window->set_title("Chess"); diff --git a/Userland/Games/FlappyBug/main.cpp b/Userland/Games/FlappyBug/main.cpp index 55daae3185..13d8b7660a 100644 --- a/Userland/Games/FlappyBug/main.cpp +++ b/Userland/Games/FlappyBug/main.cpp @@ -6,6 +6,7 @@ #include "Game.h" #include <LibConfig/Client.h> +#include <LibCore/System.h> #include <LibGUI/Application.h> #include <LibGUI/Icon.h> #include <LibGUI/Menu.h> @@ -13,20 +14,19 @@ #include <LibGUI/MessageBox.h> #include <LibGUI/Window.h> #include <LibMain/Main.h> -#include <LibSystem/Wrappers.h> ErrorOr<int> serenity_main(Main::Arguments arguments) { - TRY(System::pledge("stdio rpath recvfd sendfd unix", nullptr)); + TRY(Core::System::pledge("stdio rpath recvfd sendfd unix", nullptr)); auto app = GUI::Application::construct(arguments.argc, arguments.argv); Config::pledge_domains("FlappyBug"); - TRY(System::pledge("stdio rpath recvfd sendfd", nullptr)); + TRY(Core::System::pledge("stdio rpath recvfd sendfd", nullptr)); - TRY(System::unveil("/res", "r")); - TRY(System::unveil(nullptr, nullptr)); + TRY(Core::System::unveil("/res", "r")); + TRY(Core::System::unveil(nullptr, nullptr)); u32 high_score = Config::read_i32("FlappyBug", "Game", "HighScore", 0); diff --git a/Userland/Games/Minesweeper/main.cpp b/Userland/Games/Minesweeper/main.cpp index 889fa9e0bc..c6955129e4 100644 --- a/Userland/Games/Minesweeper/main.cpp +++ b/Userland/Games/Minesweeper/main.cpp @@ -7,6 +7,7 @@ #include "CustomGameDialog.h" #include "Field.h" #include <LibConfig/Client.h> +#include <LibCore/System.h> #include <LibGUI/Action.h> #include <LibGUI/ActionGroup.h> #include <LibGUI/Application.h> @@ -19,21 +20,20 @@ #include <LibGUI/SeparatorWidget.h> #include <LibGUI/Window.h> #include <LibMain/Main.h> -#include <LibSystem/Wrappers.h> #include <stdio.h> ErrorOr<int> serenity_main(Main::Arguments arguments) { - TRY(System::pledge("stdio rpath recvfd sendfd unix", nullptr)); + TRY(Core::System::pledge("stdio rpath recvfd sendfd unix", nullptr)); auto app = GUI::Application::construct(arguments); Config::pledge_domains("Minesweeper"); - TRY(System::pledge("stdio rpath recvfd sendfd", nullptr)); + TRY(Core::System::pledge("stdio rpath recvfd sendfd", nullptr)); - TRY(System::unveil("/res", "r")); - TRY(System::unveil(nullptr, nullptr)); + TRY(Core::System::unveil("/res", "r")); + TRY(Core::System::unveil(nullptr, nullptr)); auto app_icon = GUI::Icon::default_icon("app-minesweeper"); diff --git a/Userland/Games/Spider/main.cpp b/Userland/Games/Spider/main.cpp index 8df279c878..7a30dd6e92 100644 --- a/Userland/Games/Spider/main.cpp +++ b/Userland/Games/Spider/main.cpp @@ -8,6 +8,7 @@ #include "Game.h" #include <Games/Spider/SpiderGML.h> #include <LibConfig/Client.h> +#include <LibCore/System.h> #include <LibCore/Timer.h> #include <LibGUI/Action.h> #include <LibGUI/ActionGroup.h> @@ -19,7 +20,6 @@ #include <LibGUI/Statusbar.h> #include <LibGUI/Window.h> #include <LibMain/Main.h> -#include <LibSystem/Wrappers.h> #include <stdio.h> enum class StatisticDisplay : u8 { @@ -39,17 +39,17 @@ static String format_seconds(uint64_t seconds_elapsed) ErrorOr<int> serenity_main(Main::Arguments arguments) { - TRY(System::pledge("stdio recvfd sendfd rpath unix", nullptr)); + TRY(Core::System::pledge("stdio recvfd sendfd rpath unix", nullptr)); auto app = GUI::Application::construct(arguments.argc, arguments.argv); auto app_icon = GUI::Icon::default_icon("app-spider"); Config::pledge_domains("Spider"); - TRY(System::pledge("stdio recvfd sendfd rpath", nullptr)); + TRY(Core::System::pledge("stdio recvfd sendfd rpath", nullptr)); - TRY(System::unveil("/res", "r")); - TRY(System::unveil(nullptr, nullptr)); + TRY(Core::System::unveil("/res", "r")); + TRY(Core::System::unveil(nullptr, nullptr)); auto window = GUI::Window::construct(); window->set_title("Spider"); diff --git a/Userland/Libraries/LibCore/CMakeLists.txt b/Userland/Libraries/LibCore/CMakeLists.txt index a87e8fb8a9..b90062a5c0 100644 --- a/Userland/Libraries/LibCore/CMakeLists.txt +++ b/Userland/Libraries/LibCore/CMakeLists.txt @@ -27,6 +27,7 @@ set(SOURCES SecretString.cpp Socket.cpp StandardPaths.cpp + System.cpp TCPServer.cpp TCPSocket.cpp Timer.cpp diff --git a/Userland/Libraries/LibSystem/Wrappers.cpp b/Userland/Libraries/LibCore/System.cpp index 0cade18695..5d0e465bb2 100644 --- a/Userland/Libraries/LibSystem/Wrappers.cpp +++ b/Userland/Libraries/LibCore/System.cpp @@ -4,7 +4,7 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#include <LibSystem/Wrappers.h> +#include <LibCore/System.h> #include <LibSystem/syscall.h> #define HANDLE_SYSCALL_RETURN_VALUE(syscall_name, rc, success_value) \ @@ -13,8 +13,9 @@ } \ return success_value; -namespace System { +namespace Core::System { +#ifdef __serenity__ ErrorOr<void> pledge(StringView promises, StringView execpromises) { Syscall::SC_pledge_params params { @@ -34,18 +35,13 @@ ErrorOr<void> unveil(StringView path, StringView permissions) int rc = syscall(SC_unveil, ¶ms); HANDLE_SYSCALL_RETURN_VALUE("unveil"sv, rc, {}); } +#endif ErrorOr<void> sigaction(int signal, struct sigaction const* action, struct sigaction* old_action) { - int rc = syscall(SC_sigaction, signal, action, old_action); - HANDLE_SYSCALL_RETURN_VALUE("sigaction"sv, rc, {}); -} - -ErrorOr<struct stat> fstat(int fd) -{ - struct stat st; - int rc = syscall(SC_fstat, fd, &st); - HANDLE_SYSCALL_RETURN_VALUE("fstat"sv, rc, st); + if (::sigaction(signal, action, old_action) < 0) + return Error::from_syscall("sigaction"sv, -errno); + return {}; } } diff --git a/Userland/Libraries/LibSystem/Wrappers.h b/Userland/Libraries/LibCore/System.h index 751d598334..638fed1c9d 100644 --- a/Userland/Libraries/LibSystem/Wrappers.h +++ b/Userland/Libraries/LibCore/System.h @@ -8,13 +8,14 @@ #include <AK/Error.h> #include <signal.h> -#include <sys/stat.h> -namespace System { +namespace Core::System { +#ifdef __serenity__ ErrorOr<void> pledge(StringView promises, StringView execpromises); ErrorOr<void> unveil(StringView path, StringView permissions); +#endif + ErrorOr<void> sigaction(int signal, struct sigaction const* action, struct sigaction* old_action); -ErrorOr<struct stat> fstat(int fd); } diff --git a/Userland/Libraries/LibSystem/CMakeLists.txt b/Userland/Libraries/LibSystem/CMakeLists.txt index a376338226..61ffa0622f 100644 --- a/Userland/Libraries/LibSystem/CMakeLists.txt +++ b/Userland/Libraries/LibSystem/CMakeLists.txt @@ -1,13 +1,7 @@ set(SOURCES - Wrappers.cpp syscall.cpp ) -# FIXME: This is a hack to avoid a circular dependency with LibC. Figure out a better way. -if ("${SERENITY_ARCH}" STREQUAL "i686") - set_source_files_properties(${SOURCES} PROPERTIES COMPILE_FLAGS "-fno-stack-protector") -endif() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -nostdlib") serenity_libc(LibSystem system) target_include_directories(LibSystem PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/Userland/Services/FileSystemAccessServer/main.cpp b/Userland/Services/FileSystemAccessServer/main.cpp index cbf295dcb3..f25b369052 100644 --- a/Userland/Services/FileSystemAccessServer/main.cpp +++ b/Userland/Services/FileSystemAccessServer/main.cpp @@ -6,14 +6,14 @@ #include <FileSystemAccessServer/ClientConnection.h> #include <LibCore/LocalServer.h> +#include <LibCore/System.h> #include <LibGUI/Application.h> #include <LibIPC/ClientConnection.h> #include <LibMain/Main.h> -#include <LibSystem/Wrappers.h> ErrorOr<int> serenity_main(Main::Arguments) { - TRY(System::pledge("stdio recvfd sendfd rpath cpath wpath unix thread", nullptr)); + TRY(Core::System::pledge("stdio recvfd sendfd rpath cpath wpath unix thread", nullptr)); auto app = GUI::Application::construct(0, nullptr); app->set_quit_when_last_window_deleted(false); diff --git a/Userland/Services/ImageDecoder/main.cpp b/Userland/Services/ImageDecoder/main.cpp index fc1588144b..7f4194cd4e 100644 --- a/Userland/Services/ImageDecoder/main.cpp +++ b/Userland/Services/ImageDecoder/main.cpp @@ -7,18 +7,18 @@ #include <ImageDecoder/ClientConnection.h> #include <LibCore/EventLoop.h> #include <LibCore/LocalServer.h> +#include <LibCore/System.h> #include <LibIPC/ClientConnection.h> #include <LibMain/Main.h> -#include <LibSystem/Wrappers.h> ErrorOr<int> serenity_main(Main::Arguments) { Core::EventLoop event_loop; - TRY(System::pledge("stdio recvfd sendfd unix", nullptr)); - TRY(System::unveil(nullptr, nullptr)); + TRY(Core::System::pledge("stdio recvfd sendfd unix", nullptr)); + TRY(Core::System::unveil(nullptr, nullptr)); auto socket = Core::LocalSocket::take_over_accepted_socket_from_system_server(); IPC::new_client_connection<ImageDecoder::ClientConnection>(socket.release_nonnull(), 1); - TRY(System::pledge("stdio recvfd sendfd", nullptr)); + TRY(Core::System::pledge("stdio recvfd sendfd", nullptr)); return event_loop.exec(); } diff --git a/Userland/Services/RequestServer/main.cpp b/Userland/Services/RequestServer/main.cpp index e8784ce371..c1fc7fa925 100644 --- a/Userland/Services/RequestServer/main.cpp +++ b/Userland/Services/RequestServer/main.cpp @@ -7,9 +7,9 @@ #include <AK/OwnPtr.h> #include <LibCore/EventLoop.h> #include <LibCore/LocalServer.h> +#include <LibCore/System.h> #include <LibIPC/ClientConnection.h> #include <LibMain/Main.h> -#include <LibSystem/Wrappers.h> #include <LibTLS/Certificate.h> #include <RequestServer/ClientConnection.h> #include <RequestServer/GeminiProtocol.h> @@ -19,7 +19,7 @@ ErrorOr<int> serenity_main(Main::Arguments) { - TRY(System::pledge("stdio inet accept unix rpath sendfd recvfd sigaction", nullptr)); + TRY(Core::System::pledge("stdio inet accept unix rpath sendfd recvfd sigaction", nullptr)); signal(SIGINFO, [](int) { RequestServer::ConnectionCache::dump_jobs(); }); @@ -28,9 +28,9 @@ ErrorOr<int> serenity_main(Main::Arguments) Core::EventLoop event_loop; // FIXME: Establish a connection to LookupServer and then drop "unix"? - TRY(System::pledge("stdio inet accept unix sendfd recvfd", nullptr)); - TRY(System::unveil("/tmp/portal/lookup", "rw")); - TRY(System::unveil(nullptr, nullptr)); + TRY(Core::System::pledge("stdio inet accept unix sendfd recvfd", nullptr)); + TRY(Core::System::unveil("/tmp/portal/lookup", "rw")); + TRY(Core::System::unveil(nullptr, nullptr)); [[maybe_unused]] auto gemini = make<RequestServer::GeminiProtocol>(); [[maybe_unused]] auto http = make<RequestServer::HttpProtocol>(); diff --git a/Userland/Services/WebContent/main.cpp b/Userland/Services/WebContent/main.cpp index 057c2de950..350995f518 100644 --- a/Userland/Services/WebContent/main.cpp +++ b/Userland/Services/WebContent/main.cpp @@ -6,20 +6,20 @@ #include <LibCore/EventLoop.h> #include <LibCore/LocalServer.h> +#include <LibCore/System.h> #include <LibIPC/ClientConnection.h> #include <LibMain/Main.h> -#include <LibSystem/Wrappers.h> #include <WebContent/ClientConnection.h> ErrorOr<int> serenity_main(Main::Arguments) { Core::EventLoop event_loop; - TRY(System::pledge("stdio recvfd sendfd accept unix rpath", nullptr)); - TRY(System::unveil("/res", "r")); - TRY(System::unveil("/tmp/portal/request", "rw")); - TRY(System::unveil("/tmp/portal/image", "rw")); - TRY(System::unveil("/tmp/portal/websocket", "rw")); - TRY(System::unveil(nullptr, nullptr)); + TRY(Core::System::pledge("stdio recvfd sendfd accept unix rpath", nullptr)); + TRY(Core::System::unveil("/res", "r")); + TRY(Core::System::unveil("/tmp/portal/request", "rw")); + TRY(Core::System::unveil("/tmp/portal/image", "rw")); + TRY(Core::System::unveil("/tmp/portal/websocket", "rw")); + TRY(Core::System::unveil(nullptr, nullptr)); auto socket = Core::LocalSocket::take_over_accepted_socket_from_system_server(); VERIFY(socket); diff --git a/Userland/Services/WebSocket/main.cpp b/Userland/Services/WebSocket/main.cpp index 0e8cf8b0ab..5fc28d3c20 100644 --- a/Userland/Services/WebSocket/main.cpp +++ b/Userland/Services/WebSocket/main.cpp @@ -6,24 +6,24 @@ #include <LibCore/EventLoop.h> #include <LibCore/LocalServer.h> +#include <LibCore/System.h> #include <LibIPC/ClientConnection.h> #include <LibMain/Main.h> -#include <LibSystem/Wrappers.h> #include <LibTLS/Certificate.h> #include <WebSocket/ClientConnection.h> ErrorOr<int> serenity_main(Main::Arguments) { - TRY(System::pledge("stdio inet unix rpath sendfd recvfd", nullptr)); + TRY(Core::System::pledge("stdio inet unix rpath sendfd recvfd", nullptr)); // Ensure the certificates are read out here. [[maybe_unused]] auto& certs = DefaultRootCACertificates::the(); Core::EventLoop event_loop; // FIXME: Establish a connection to LookupServer and then drop "unix"? - TRY(System::pledge("stdio inet unix sendfd recvfd", nullptr)); - TRY(System::unveil("/tmp/portal/lookup", "rw")); - TRY(System::unveil(nullptr, nullptr)); + TRY(Core::System::pledge("stdio inet unix sendfd recvfd", nullptr)); + TRY(Core::System::unveil("/tmp/portal/lookup", "rw")); + TRY(Core::System::unveil(nullptr, nullptr)); auto socket = Core::LocalSocket::take_over_accepted_socket_from_system_server(); VERIFY(socket); diff --git a/Userland/Services/WindowServer/main.cpp b/Userland/Services/WindowServer/main.cpp index d4ff05dbc3..54e69c6c68 100644 --- a/Userland/Services/WindowServer/main.cpp +++ b/Userland/Services/WindowServer/main.cpp @@ -12,25 +12,25 @@ #include <LibCore/ConfigFile.h> #include <LibCore/DirIterator.h> #include <LibCore/File.h> +#include <LibCore/System.h> #include <LibGfx/Palette.h> #include <LibGfx/SystemTheme.h> #include <LibMain/Main.h> -#include <LibSystem/Wrappers.h> #include <signal.h> #include <string.h> ErrorOr<int> serenity_main(Main::Arguments) { - TRY(System::pledge("stdio video thread sendfd recvfd accept rpath wpath cpath unix proc sigaction", nullptr)); - TRY(System::unveil("/res", "r")); - TRY(System::unveil("/tmp", "cw")); - TRY(System::unveil("/etc/WindowServer.ini", "rwc")); - TRY(System::unveil("/dev", "rw")); + TRY(Core::System::pledge("stdio video thread sendfd recvfd accept rpath wpath cpath unix proc sigaction", nullptr)); + TRY(Core::System::unveil("/res", "r")); + TRY(Core::System::unveil("/tmp", "cw")); + TRY(Core::System::unveil("/etc/WindowServer.ini", "rwc")); + TRY(Core::System::unveil("/dev", "rw")); struct sigaction act = {}; act.sa_flags = SA_NOCLDWAIT; act.sa_handler = SIG_IGN; - TRY(System::sigaction(SIGCHLD, &act, nullptr)); + TRY(Core::System::sigaction(SIGCHLD, &act, nullptr)); auto wm_config = Core::ConfigFile::open("/etc/WindowServer.ini"); auto theme_name = wm_config->read_entry("Theme", "Name", "Default"); @@ -48,7 +48,7 @@ ErrorOr<int> serenity_main(Main::Arguments) WindowServer::EventLoop loop; - TRY(System::pledge("stdio video thread sendfd recvfd accept rpath wpath cpath proc", nullptr)); + TRY(Core::System::pledge("stdio video thread sendfd recvfd accept rpath wpath cpath proc", nullptr)); // First check which screens are explicitly configured { @@ -114,13 +114,13 @@ ErrorOr<int> serenity_main(Main::Arguments) auto am = WindowServer::AppletManager::construct(); auto mm = WindowServer::MenuManager::construct(); - TRY(System::unveil("/tmp", "")); + TRY(Core::System::unveil("/tmp", "")); // NOTE: Because we dynamically need to be able to open new /dev/fb* // devices we can't really unveil all of /dev unless we have some // other mechanism that can hand us file descriptors for these. - TRY(System::unveil(nullptr, nullptr)); + TRY(Core::System::unveil(nullptr, nullptr)); dbgln("Entering WindowServer main loop"); loop.exec(); diff --git a/Userland/Utilities/id.cpp b/Userland/Utilities/id.cpp index 4f61138845..7bc7bb388f 100644 --- a/Userland/Utilities/id.cpp +++ b/Userland/Utilities/id.cpp @@ -7,8 +7,8 @@ #include <AK/StringUtils.h> #include <LibCore/Account.h> #include <LibCore/ArgsParser.h> +#include <LibCore/System.h> #include <LibMain/Main.h> -#include <LibSystem/Wrappers.h> #include <alloca.h> #include <grp.h> #include <pwd.h> @@ -25,10 +25,10 @@ static String user_str; ErrorOr<int> serenity_main(Main::Arguments arguments) { - TRY(System::unveil("/etc/passwd", "r")); - TRY(System::unveil("/etc/group", "r")); - TRY(System::unveil(nullptr, nullptr)); - TRY(System::pledge("stdio rpath", nullptr)); + TRY(Core::System::unveil("/etc/passwd", "r")); + TRY(Core::System::unveil("/etc/group", "r")); + TRY(Core::System::unveil(nullptr, nullptr)); + TRY(Core::System::pledge("stdio rpath", nullptr)); Core::ArgsParser args_parser; args_parser.add_option(flag_print_uid, "Print UID", nullptr, 'u'); diff --git a/Userland/Utilities/js.cpp b/Userland/Utilities/js.cpp index 0e2fe5ef6e..7eef2531b3 100644 --- a/Userland/Utilities/js.cpp +++ b/Userland/Utilities/js.cpp @@ -13,6 +13,7 @@ #include <LibCore/ArgsParser.h> #include <LibCore/File.h> #include <LibCore/StandardPaths.h> +#include <LibCore/System.h> #include <LibJS/AST.h> #include <LibJS/Bytecode/BasicBlock.h> #include <LibJS/Bytecode/Generator.h> @@ -61,7 +62,6 @@ #include <LibJS/Runtime/Value.h> #include <LibLine/Editor.h> #include <LibMain/Main.h> -#include <LibSystem/Wrappers.h> #include <fcntl.h> #include <signal.h> #include <stdio.h> @@ -1107,7 +1107,7 @@ public: ErrorOr<int> serenity_main(Main::Arguments arguments) { #ifdef __serenity__ - TRY(System::pledge("stdio rpath wpath cpath tty sigaction", nullptr)); + TRY(Core::System::pledge("stdio rpath wpath cpath tty sigaction", nullptr)); #endif bool gc_on_every_allocation = false; diff --git a/Userland/Utilities/nproc.cpp b/Userland/Utilities/nproc.cpp index 8d91d200fc..6358078b22 100644 --- a/Userland/Utilities/nproc.cpp +++ b/Userland/Utilities/nproc.cpp @@ -6,12 +6,12 @@ #include <AK/JsonObject.h> #include <LibCore/File.h> +#include <LibCore/System.h> #include <LibMain/Main.h> -#include <LibSystem/Wrappers.h> ErrorOr<int> serenity_main(Main::Arguments) { - TRY(System::pledge("stdio rpath", nullptr)); + TRY(Core::System::pledge("stdio rpath", nullptr)); auto file = TRY(Core::File::open("/proc/cpuinfo", Core::OpenMode::ReadOnly)); auto buffer = file->read_all(); diff --git a/Userland/Utilities/w.cpp b/Userland/Utilities/w.cpp index 4dd68aa98a..5729a5246f 100644 --- a/Userland/Utilities/w.cpp +++ b/Userland/Utilities/w.cpp @@ -9,20 +9,20 @@ #include <LibCore/DateTime.h> #include <LibCore/File.h> #include <LibCore/ProcessStatisticsReader.h> +#include <LibCore/System.h> #include <LibMain/Main.h> -#include <LibSystem/Wrappers.h> #include <pwd.h> #include <sys/stat.h> #include <time.h> ErrorOr<int> serenity_main(Main::Arguments) { - TRY(System::pledge("stdio rpath", nullptr)); - TRY(System::unveil("/dev", "r")); - TRY(System::unveil("/etc/passwd", "r")); - TRY(System::unveil("/var/run/utmp", "r")); - TRY(System::unveil("/proc", "r")); - TRY(System::unveil(nullptr, nullptr)); + TRY(Core::System::pledge("stdio rpath", nullptr)); + TRY(Core::System::unveil("/dev", "r")); + TRY(Core::System::unveil("/etc/passwd", "r")); + TRY(Core::System::unveil("/var/run/utmp", "r")); + TRY(Core::System::unveil("/proc", "r")); + TRY(Core::System::unveil(nullptr, nullptr)); auto file = TRY(Core::File::open("/var/run/utmp", Core::OpenMode::ReadOnly)); auto json = TRY(JsonValue::from_string(file->read_all())); |