1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 20:47:45 +00:00

Kernel+LibC: Implement the socketpair() syscall

This commit is contained in:
Gunnar Beutner 2021-04-28 12:39:12 +02:00 committed by Andreas Kling
parent c841012f56
commit aa792062cb
11 changed files with 100 additions and 91 deletions

View file

@ -150,21 +150,6 @@ index 554ceb0b..67464ef2 100644
#include <netinet/ip.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>
diff --git a/monitor.c b/monitor.c
index b6e855d5..bde8f383 100644
--- a/monitor.c
+++ b/monitor.c
@@ -1752,8 +1752,10 @@ monitor_openfds(struct monitor *mon, int do_logfds)
int on = 1;
#endif
+#ifndef __serenity__
if (socketpair(AF_UNIX, SOCK_STREAM, 0, pair) == -1)
fatal("%s: socketpair: %s", __func__, strerror(errno));
+#endif
#ifdef SO_ZEROIZE
if (setsockopt(pair[0], SOL_SOCKET, SO_ZEROIZE, &on, sizeof(on)) == -1)
error("setsockopt SO_ZEROIZE(0): %.100s", strerror(errno));
diff --git a/openbsd-compat/bsd-misc.c b/openbsd-compat/bsd-misc.c
index 059b6d3b..2a248c81 100644
--- a/openbsd-compat/bsd-misc.c
@ -588,27 +573,6 @@ index af08be41..9e748a23 100644
r = check_host_key(host, hostaddr, options.port, host_key, RDRW,
options.user_hostfiles, options.num_user_hostfiles,
options.system_hostfiles, options.num_system_hostfiles);
diff --git a/sshd.c b/sshd.c
index 6f8f11a3..1ecf3e32 100644
--- a/sshd.c
+++ b/sshd.c
@@ -1231,6 +1231,8 @@ server_accept_loop(int *sock_in, int *sock_out, int *newsock, int *config_s)
continue;
}
+// FIXME: socketpair is seemingly required for SSHD to work, but doesn't current exist.
+#ifndef __serenity__
if (rexec_flag && socketpair(AF_UNIX,
SOCK_STREAM, 0, config_s) == -1) {
error("reexec socketpair: %s",
@@ -1240,6 +1242,7 @@ server_accept_loop(int *sock_in, int *sock_out, int *newsock, int *config_s)
close(startup_p[1]);
continue;
}
+#endif
for (j = 0; j < options.max_startups; j++)
if (startup_pipes[j] == -1) {
diff --git a/sshkey.c b/sshkey.c
index 1571e3d9..2b5c611c 100644
--- a/sshkey.c

View file

@ -1,16 +0,0 @@
e5a0b5cc530260b1ee94105e8c989ba21856b4a2 Use pipes instead of socketpair in SFTP
diff --git a/sftp.c b/sftp.c
index 2799e4a1..9ce7055a 100644
--- a/sftp.c
+++ b/sftp.c
@@ -2296,6 +2296,10 @@ interactive_loop(struct sftp_conn *conn, char *file1, char *file2)
return (err >= 0 ? 0 : -1);
}
+#ifdef __serenity__
+#define USE_PIPES 1
+#endif
+
static void
connect_to_server(char *path, char **args, int *in, int *out)
{