diff options
author | Andreas Kling <awesomekling@gmail.com> | 2020-01-17 11:12:06 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2020-01-17 11:19:06 +0100 |
commit | 26a31c7efbb62e2836a2199a27e6377c50cc1896 (patch) | |
tree | f00732a2acd59eaa5a99858db8732d4b4c5e7001 /Servers | |
parent | a9b24ebbe86e2d3e98631454922ec08f4119c64b (diff) | |
download | serenity-26a31c7efbb62e2836a2199a27e6377c50cc1896.zip |
Kernel: Add "accept" pledge promise for accepting incoming connections
This patch adds a new "accept" promise that allows you to call accept()
on an already listening socket. This lets programs set up a socket for
for listening and then dropping "inet" and/or "unix" so that only
incoming (and existing) connections are allowed from that point on.
No new outgoing connections or listening server sockets can be created.
In addition to accept() it also allows getsockopt() with SOL_SOCKET
and SO_PEERCRED, which is used to find the PID/UID/GID of the socket
peer. This is used by our IPC library when creating shared buffers that
should only be accessible to a specific peer process.
This allows us to drop "unix" in WindowServer and LookupServer. :^)
It also makes the debugging/introspection RPC sockets in CEventLoop
based programs work again.
Diffstat (limited to 'Servers')
-rw-r--r-- | Servers/AudioServer/main.cpp | 4 | ||||
-rw-r--r-- | Servers/LookupServer/main.cpp | 4 | ||||
-rw-r--r-- | Servers/ProtocolServer/main.cpp | 5 | ||||
-rw-r--r-- | Servers/SystemServer/main.cpp | 2 | ||||
-rw-r--r-- | Servers/WindowServer/main.cpp | 4 |
5 files changed, 10 insertions, 9 deletions
diff --git a/Servers/AudioServer/main.cpp b/Servers/AudioServer/main.cpp index 496feb850c..3f76f04642 100644 --- a/Servers/AudioServer/main.cpp +++ b/Servers/AudioServer/main.cpp @@ -4,12 +4,12 @@ int main(int, char**) { - if (pledge("stdio thread shared_buffer rpath wpath cpath unix fattr", nullptr) < 0) { + if (pledge("stdio thread shared_buffer accept rpath wpath cpath unix fattr", nullptr) < 0) { perror("pledge"); return 1; } ASEventLoop event_loop; - if (pledge("stdio thread shared_buffer rpath wpath unix", nullptr) < 0) { + if (pledge("stdio thread shared_buffer accept rpath wpath", nullptr) < 0) { perror("pledge"); return 1; } diff --git a/Servers/LookupServer/main.cpp b/Servers/LookupServer/main.cpp index 4b0bcef162..d14458def0 100644 --- a/Servers/LookupServer/main.cpp +++ b/Servers/LookupServer/main.cpp @@ -7,7 +7,7 @@ int main(int argc, char** argv) (void)argc; (void)argv; - if (pledge("stdio unix inet cpath rpath fattr", nullptr) < 0) { + if (pledge("stdio accept unix inet cpath rpath fattr", nullptr) < 0) { perror("pledge"); return 1; } @@ -15,7 +15,7 @@ int main(int argc, char** argv) CEventLoop event_loop; LookupServer server; - if (pledge("stdio unix inet", nullptr) < 0) { + if (pledge("stdio accept inet", nullptr) < 0) { perror("pledge"); return 1; } diff --git a/Servers/ProtocolServer/main.cpp b/Servers/ProtocolServer/main.cpp index 31c69c165c..4d95f89b75 100644 --- a/Servers/ProtocolServer/main.cpp +++ b/Servers/ProtocolServer/main.cpp @@ -6,12 +6,13 @@ int main(int, char**) { - if (pledge("stdio inet shared_buffer unix rpath cpath fattr", nullptr) < 0) { + if (pledge("stdio inet shared_buffer accept unix rpath cpath fattr", nullptr) < 0) { perror("pledge"); return 1; } CEventLoop event_loop; - if (pledge("stdio inet shared_buffer unix", nullptr) < 0) { + // FIXME: Establish a connection to LookupServer and then drop "unix"? + if (pledge("stdio inet shared_buffer accept unix", nullptr) < 0) { perror("pledge"); return 1; } diff --git a/Servers/SystemServer/main.cpp b/Servers/SystemServer/main.cpp index 154334ee0c..cfe2ff7848 100644 --- a/Servers/SystemServer/main.cpp +++ b/Servers/SystemServer/main.cpp @@ -77,7 +77,7 @@ static void mount_all_filesystems() int main(int, char**) { - if (pledge("stdio proc exec tty unix rpath wpath cpath chown fattr id", nullptr) < 0) { + if (pledge("stdio proc exec tty accept unix rpath wpath cpath chown fattr id", nullptr) < 0) { perror("pledge"); return 1; } diff --git a/Servers/WindowServer/main.cpp b/Servers/WindowServer/main.cpp index 10d6e5cdbd..3ffadc2c95 100644 --- a/Servers/WindowServer/main.cpp +++ b/Servers/WindowServer/main.cpp @@ -10,7 +10,7 @@ int main(int, char**) { - if (pledge("stdio video thread shared_buffer rpath wpath cpath unix proc exec fattr", nullptr) < 0) { + if (pledge("stdio video thread shared_buffer accept rpath wpath cpath unix proc exec fattr", nullptr) < 0) { perror("pledge"); return 1; } @@ -35,7 +35,7 @@ int main(int, char**) WSEventLoop loop; - if (pledge("stdio video thread shared_buffer rpath wpath cpath unix proc exec", nullptr) < 0) { + if (pledge("stdio video thread shared_buffer accept rpath wpath cpath proc exec", nullptr) < 0) { perror("pledge"); return 1; } |