diff options
author | Timothy Flynn <trflynn89@pm.me> | 2022-12-15 07:36:17 -0500 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-12-15 17:29:19 +0000 |
commit | 366f24a73b1ea689b280e30c33ac0c4e992e502a (patch) | |
tree | 0777665fd1dbe1d5f5bbe9d01bf18fe7c6d4df54 /Userland | |
parent | 701e77019cded0ecb860d25920c109127115e6c8 (diff) | |
download | serenity-366f24a73b1ea689b280e30c33ac0c4e992e502a.zip |
WebContent+WebDriver: Move WebDriver socket to the standard runtime path
This will allow Ladybird to use local socket files rather than passing
around a bunch of socket FDs.
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Services/WebContent/main.cpp | 6 | ||||
-rw-r--r-- | Userland/Services/WebDriver/Session.cpp | 3 | ||||
-rw-r--r-- | Userland/Services/WebDriver/main.cpp | 8 |
3 files changed, 12 insertions, 5 deletions
diff --git a/Userland/Services/WebContent/main.cpp b/Userland/Services/WebContent/main.cpp index b8687c844b..ebd2959f78 100644 --- a/Userland/Services/WebContent/main.cpp +++ b/Userland/Services/WebContent/main.cpp @@ -8,6 +8,7 @@ #include <LibCore/EventLoop.h> #include <LibCore/File.h> #include <LibCore/LocalServer.h> +#include <LibCore/StandardPaths.h> #include <LibCore/Stream.h> #include <LibCore/System.h> #include <LibIPC/SingleServer.h> @@ -27,8 +28,9 @@ ErrorOr<int> serenity_main(Main::Arguments) TRY(Core::System::pledge("stdio recvfd sendfd accept unix rpath")); // This must be first; we can't check if /tmp/webdriver exists once we've unveiled other paths. - if (Core::File::exists("/tmp/webdriver"sv)) - TRY(Core::System::unveil("/tmp/webdriver", "rw")); + auto webdriver_socket_path = DeprecatedString::formatted("{}/webdriver", TRY(Core::StandardPaths::runtime_directory())); + if (Core::File::exists(webdriver_socket_path)) + TRY(Core::System::unveil(webdriver_socket_path, "rw"sv)); TRY(Core::System::unveil("/sys/kernel/processes", "r")); TRY(Core::System::unveil("/res", "r")); diff --git a/Userland/Services/WebDriver/Session.cpp b/Userland/Services/WebDriver/Session.cpp index 8a45a50156..46692dc359 100644 --- a/Userland/Services/WebDriver/Session.cpp +++ b/Userland/Services/WebDriver/Session.cpp @@ -11,6 +11,7 @@ #include "Session.h" #include "Client.h" #include <LibCore/LocalServer.h> +#include <LibCore/StandardPaths.h> #include <LibCore/Stream.h> #include <LibCore/System.h> #include <unistd.h> @@ -61,7 +62,7 @@ ErrorOr<void> Session::start() { auto promise = TRY(ServerPromise::try_create()); - auto web_content_socket_path = DeprecatedString::formatted("/tmp/webdriver/session_{}_{}", getpid(), m_id); + auto web_content_socket_path = DeprecatedString::formatted("{}/webdriver/session_{}_{}", TRY(Core::StandardPaths::runtime_directory()), getpid(), m_id); auto web_content_server = TRY(create_server(web_content_socket_path, promise)); if (m_options.headless) { diff --git a/Userland/Services/WebDriver/main.cpp b/Userland/Services/WebDriver/main.cpp index d21fcf627e..bebf3f7577 100644 --- a/Userland/Services/WebDriver/main.cpp +++ b/Userland/Services/WebDriver/main.cpp @@ -7,6 +7,7 @@ #include <LibCore/ArgsParser.h> #include <LibCore/Directory.h> #include <LibCore/EventLoop.h> +#include <LibCore/StandardPaths.h> #include <LibCore/System.h> #include <LibCore/TCPServer.h> #include <LibMain/Main.h> @@ -38,7 +39,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) TRY(Core::System::pledge("stdio accept cpath rpath recvfd inet unix proc exec fattr")); - TRY(Core::Directory::create("/tmp/webdriver"sv, Core::Directory::CreateDirectories::Yes)); + auto webdriver_socket_path = DeprecatedString::formatted("{}/webdriver", TRY(Core::StandardPaths::runtime_directory())); + TRY(Core::Directory::create(webdriver_socket_path, Core::Directory::CreateDirectories::Yes)); + TRY(Core::System::pledge("stdio accept rpath recvfd inet unix proc exec fattr")); Core::EventLoop loop; @@ -74,7 +77,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) TRY(Core::System::unveil("/bin/headless-browser", "rx")); TRY(Core::System::unveil("/etc/timezone", "r")); TRY(Core::System::unveil("/res/icons", "r")); - TRY(Core::System::unveil("/tmp/webdriver", "rwc")); + TRY(Core::System::unveil("/sys/kernel/processes", "r")); + TRY(Core::System::unveil(webdriver_socket_path, "rwc"sv)); TRY(Core::System::unveil(nullptr, nullptr)); TRY(Core::System::pledge("stdio accept rpath recvfd unix proc exec fattr")); |