summaryrefslogtreecommitdiff
path: root/Kernel/Net/LocalSocket.h
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-06-24 22:57:37 +0200
committerAndreas Kling <kling@serenityos.org>2020-06-24 23:08:09 +0200
commitd4195672b7571e105cd9fb3891334d8c734ae775 (patch)
tree6c2797a945aa3fd8f88d31fb9ea9bbb443bb89a4 /Kernel/Net/LocalSocket.h
parentcd02144a06d4b648effdb744e00b664a871bf52b (diff)
downloadserenity-d4195672b7571e105cd9fb3891334d8c734ae775.zip
Kernel+LibC: Add sys$recvfd() and sys$sendfd() for fd passing
These new syscalls allow you to send and receive file descriptors over a local domain socket. This will enable various privilege separation techniques and other good stuff. :^)
Diffstat (limited to 'Kernel/Net/LocalSocket.h')
-rw-r--r--Kernel/Net/LocalSocket.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/Kernel/Net/LocalSocket.h b/Kernel/Net/LocalSocket.h
index 8435480d53..0d50b77bdd 100644
--- a/Kernel/Net/LocalSocket.h
+++ b/Kernel/Net/LocalSocket.h
@@ -42,6 +42,9 @@ public:
static KResultOr<NonnullRefPtr<Socket>> create(int type);
virtual ~LocalSocket() override;
+ KResult sendfd(FileDescription& socket_description, NonnullRefPtr<FileDescription> passing_description);
+ KResultOr<NonnullRefPtr<FileDescription>> recvfd(FileDescription& socket_description);
+
static void for_each(Function<void(const LocalSocket&)>);
StringView socket_path() const;
@@ -71,6 +74,8 @@ private:
static Lockable<InlineLinkedList<LocalSocket>>& all_sockets();
DoubleBuffer& receive_buffer_for(FileDescription&);
DoubleBuffer& send_buffer_for(FileDescription&);
+ NonnullRefPtrVector<FileDescription>& sendfd_queue_for(FileDescription&);
+ NonnullRefPtrVector<FileDescription>& recvfd_queue_for(FileDescription&);
// An open socket file on the filesystem.
RefPtr<FileDescription> m_file;
@@ -100,6 +105,9 @@ private:
DoubleBuffer m_for_client;
DoubleBuffer m_for_server;
+ NonnullRefPtrVector<FileDescription> m_fds_for_client;
+ NonnullRefPtrVector<FileDescription> m_fds_for_server;
+
// for InlineLinkedList
LocalSocket* m_prev { nullptr };
LocalSocket* m_next { nullptr };