1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 08:17:45 +00:00

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.
This commit is contained in:
Timothy Flynn 2022-12-15 07:36:17 -05:00 committed by Linus Groh
parent 701e77019c
commit 366f24a73b
3 changed files with 12 additions and 5 deletions

View file

@ -8,6 +8,7 @@
#include <LibCore/EventLoop.h> #include <LibCore/EventLoop.h>
#include <LibCore/File.h> #include <LibCore/File.h>
#include <LibCore/LocalServer.h> #include <LibCore/LocalServer.h>
#include <LibCore/StandardPaths.h>
#include <LibCore/Stream.h> #include <LibCore/Stream.h>
#include <LibCore/System.h> #include <LibCore/System.h>
#include <LibIPC/SingleServer.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")); 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. // 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)) auto webdriver_socket_path = DeprecatedString::formatted("{}/webdriver", TRY(Core::StandardPaths::runtime_directory()));
TRY(Core::System::unveil("/tmp/webdriver", "rw")); 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("/sys/kernel/processes", "r"));
TRY(Core::System::unveil("/res", "r")); TRY(Core::System::unveil("/res", "r"));

View file

@ -11,6 +11,7 @@
#include "Session.h" #include "Session.h"
#include "Client.h" #include "Client.h"
#include <LibCore/LocalServer.h> #include <LibCore/LocalServer.h>
#include <LibCore/StandardPaths.h>
#include <LibCore/Stream.h> #include <LibCore/Stream.h>
#include <LibCore/System.h> #include <LibCore/System.h>
#include <unistd.h> #include <unistd.h>
@ -61,7 +62,7 @@ ErrorOr<void> Session::start()
{ {
auto promise = TRY(ServerPromise::try_create()); 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)); auto web_content_server = TRY(create_server(web_content_socket_path, promise));
if (m_options.headless) { if (m_options.headless) {

View file

@ -7,6 +7,7 @@
#include <LibCore/ArgsParser.h> #include <LibCore/ArgsParser.h>
#include <LibCore/Directory.h> #include <LibCore/Directory.h>
#include <LibCore/EventLoop.h> #include <LibCore/EventLoop.h>
#include <LibCore/StandardPaths.h>
#include <LibCore/System.h> #include <LibCore/System.h>
#include <LibCore/TCPServer.h> #include <LibCore/TCPServer.h>
#include <LibMain/Main.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::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")); TRY(Core::System::pledge("stdio accept rpath recvfd inet unix proc exec fattr"));
Core::EventLoop loop; 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("/bin/headless-browser", "rx"));
TRY(Core::System::unveil("/etc/timezone", "r")); TRY(Core::System::unveil("/etc/timezone", "r"));
TRY(Core::System::unveil("/res/icons", "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::unveil(nullptr, nullptr));
TRY(Core::System::pledge("stdio accept rpath recvfd unix proc exec fattr")); TRY(Core::System::pledge("stdio accept rpath recvfd unix proc exec fattr"));