1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 16:38:10 +00:00

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.
This commit is contained in:
Andreas Kling 2020-01-17 11:12:06 +01:00
parent a9b24ebbe8
commit 26a31c7efb
29 changed files with 63 additions and 55 deletions

View file

@ -49,14 +49,14 @@ private:
int main(int argc, char** argv)
{
if (pledge("stdio shared_buffer rpath unix cpath fattr", nullptr) < 0) {
if (pledge("stdio shared_buffer accept rpath unix cpath fattr", nullptr) < 0) {
perror("pledge");
return 1;
}
GApplication app(argc, argv);
if (pledge("stdio shared_buffer rpath unix", nullptr) < 0) {
if (pledge("stdio shared_buffer accept rpath unix", nullptr) < 0) {
perror("pledge");
return 1;
}
@ -70,7 +70,7 @@ int main(int argc, char** argv)
window->set_main_widget(widget);
window->show();
if (pledge("stdio shared_buffer rpath", nullptr) < 0) {
if (pledge("stdio shared_buffer accept rpath", nullptr) < 0) {
perror("pledge");
return 1;
}