mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-22 09:12:13 -05:00
LibCore: Remove SessionManagement utilities
We don't need these, they are only relevant for SerenityOS system builds of LibCore.
This commit is contained in:
parent
1549d393b9
commit
0075048206
Notes:
github-actions[bot]
2024-11-26 10:01:50 +00:00
Author: https://github.com/ADKaster Commit: https://github.com/LadybirdBrowser/ladybird/commit/00750482060 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2582
10 changed files with 1 additions and 96 deletions
|
@ -48,7 +48,6 @@ set(SOURCES
|
|||
Resource.cpp
|
||||
ResourceImplementation.cpp
|
||||
ResourceImplementationFile.cpp
|
||||
SessionManagement.cpp
|
||||
Socket.cpp
|
||||
SystemServerTakeover.cpp
|
||||
TCPServer.cpp
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
#include <LibCore/LocalServer.h>
|
||||
#include <LibCore/Notifier.h>
|
||||
#include <LibCore/SessionManagement.h>
|
||||
#include <LibCore/Socket.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibCore/SystemServerTakeover.h>
|
||||
|
@ -33,20 +32,6 @@ LocalServer::~LocalServer()
|
|||
::close(m_fd);
|
||||
}
|
||||
|
||||
ErrorOr<void> LocalServer::take_over_from_system_server(ByteString const& socket_path)
|
||||
{
|
||||
if (m_listening)
|
||||
return Error::from_string_literal("Core::LocalServer: Can't perform socket takeover when already listening");
|
||||
|
||||
auto const parsed_path = TRY(Core::SessionManagement::parse_path_with_sid(socket_path));
|
||||
auto socket = TRY(take_over_socket_from_system_server(parsed_path));
|
||||
m_fd = TRY(socket->release_fd());
|
||||
|
||||
m_listening = true;
|
||||
setup_notifier();
|
||||
return {};
|
||||
}
|
||||
|
||||
ErrorOr<void> LocalServer::take_over_fd(int socket_fd)
|
||||
{
|
||||
if (m_listening)
|
||||
|
|
|
@ -16,7 +16,6 @@ class LocalServer : public EventReceiver {
|
|||
public:
|
||||
virtual ~LocalServer() override;
|
||||
|
||||
ErrorOr<void> take_over_from_system_server(ByteString const& path = ByteString());
|
||||
ErrorOr<void> take_over_fd(int socket_fd);
|
||||
bool is_listening() const { return m_listening; }
|
||||
bool listen(ByteString const& address);
|
||||
|
|
|
@ -1,43 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Peter Elliott <pelliott@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibCore/Directory.h>
|
||||
#include <LibCore/SessionManagement.h>
|
||||
#include <LibCore/System.h>
|
||||
|
||||
namespace Core::SessionManagement {
|
||||
|
||||
ErrorOr<pid_t> root_session_id([[maybe_unused]] Optional<pid_t> force_sid)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
ErrorOr<void> logout(Optional<pid_t> force_sid)
|
||||
{
|
||||
pid_t sid = TRY(root_session_id(force_sid));
|
||||
TRY(System::kill(-sid, SIGTERM));
|
||||
return {};
|
||||
}
|
||||
|
||||
ErrorOr<ByteString> parse_path_with_sid(StringView general_path, Optional<pid_t> force_sid)
|
||||
{
|
||||
if (general_path.contains("%sid"sv)) {
|
||||
pid_t sid = TRY(root_session_id(force_sid));
|
||||
return general_path.replace("%sid"sv, ByteString::number(sid), ReplaceMode::All);
|
||||
}
|
||||
return ByteString(general_path);
|
||||
}
|
||||
|
||||
ErrorOr<void> create_session_temporary_directory_if_needed(uid_t uid, gid_t gid, Optional<pid_t> force_sid)
|
||||
{
|
||||
pid_t sid = TRY(root_session_id(force_sid));
|
||||
auto const temporary_directory = ByteString::formatted("/tmp/session/{}", sid);
|
||||
auto directory = TRY(Core::Directory::create(temporary_directory, Core::Directory::CreateDirectories::Yes));
|
||||
TRY(directory.chown(uid, gid));
|
||||
return {};
|
||||
}
|
||||
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Peter Elliott <pelliott@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/Error.h>
|
||||
#include <AK/Types.h>
|
||||
|
||||
namespace Core::SessionManagement {
|
||||
|
||||
ErrorOr<pid_t> root_session_id(Optional<pid_t> force_sid = {});
|
||||
ErrorOr<void> logout(Optional<pid_t> force_sid = {});
|
||||
|
||||
ErrorOr<ByteString> parse_path_with_sid(StringView general_path, Optional<pid_t> force_sid = {});
|
||||
ErrorOr<void> create_session_temporary_directory_if_needed(uid_t uid, gid_t gid, Optional<pid_t> force_sid = {});
|
||||
|
||||
}
|
|
@ -18,7 +18,6 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
#if !defined(AK_OS_WINDOWS)
|
||||
# include <LibCore/SessionManagement.h>
|
||||
# include <pwd.h>
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
@ -202,10 +201,7 @@ ErrorOr<ByteString> StandardPaths::runtime_directory()
|
|||
|
||||
StringBuilder builder;
|
||||
|
||||
#if defined(AK_OS_SERENITY)
|
||||
auto sid = TRY(Core::SessionManagement::root_session_id());
|
||||
builder.appendff("/tmp/session/{}", sid);
|
||||
#elif defined(AK_OS_MACOS)
|
||||
#if defined(AK_OS_MACOS)
|
||||
builder.append(home_directory());
|
||||
builder.append("/Library/Application Support"sv);
|
||||
#elif defined(AK_OS_HAIKU)
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
#include <AK/String.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibCore/Environment.h>
|
||||
#include <LibCore/SessionManagement.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <limits.h>
|
||||
#include <stdarg.h>
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <LibCore/SessionManagement.h>
|
||||
#include <LibIPC/Connection.h>
|
||||
|
||||
namespace IPC {
|
||||
|
|
|
@ -16,13 +16,6 @@ namespace IPC {
|
|||
template<typename ConnectionFromClientType>
|
||||
class MultiServer {
|
||||
public:
|
||||
static ErrorOr<NonnullOwnPtr<MultiServer>> try_create(Optional<ByteString> socket_path = {})
|
||||
{
|
||||
auto server = TRY(Core::LocalServer::try_create());
|
||||
TRY(server->take_over_from_system_server(socket_path.value_or({})));
|
||||
return adopt_nonnull_own_or_enomem(new (nothrow) MultiServer(move(server)));
|
||||
}
|
||||
|
||||
static ErrorOr<NonnullOwnPtr<MultiServer>> try_create(NonnullRefPtr<Core::LocalServer> server)
|
||||
{
|
||||
return adopt_nonnull_own_or_enomem(new (nothrow) MultiServer(move(server)));
|
||||
|
|
|
@ -74,8 +74,6 @@ source_set("sources") {
|
|||
"Resource.h",
|
||||
"ResourceImplementation.cpp",
|
||||
"ResourceImplementationFile.cpp",
|
||||
"SessionManagement.cpp",
|
||||
"SessionManagement.h",
|
||||
"SharedCircularQueue.h",
|
||||
"Socket.cpp",
|
||||
"Socket.h",
|
||||
|
|
Loading…
Reference in a new issue