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
Notes: sideshowbarker 2024-07-17 10:10:18 +09:00
3 changed files with 12 additions and 5 deletions

View file

@ -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"));

View file

@ -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) {

View file

@ -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"));