]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
privsep: Use xsocketpair
authorRoy Marples <roy@marples.name>
Sat, 5 Sep 2020 15:12:30 +0000 (16:12 +0100)
committerRoy Marples <roy@marples.name>
Sat, 5 Sep 2020 15:12:30 +0000 (16:12 +0100)
src/privsep-control.c
src/privsep.c

index e0f9088f59ee810e5fcefaa169a20a92c5ba74f4..8d1ed506be4c58fbe4c60b319af12325ee8d25a4 100644 (file)
@@ -225,16 +225,10 @@ ps_ctl_start(struct dhcpcd_ctx *ctx)
        int data_fd[2], listen_fd[2];
        pid_t pid;
 
-       if (socketpair(AF_UNIX, SOCK_STREAM | SOCK_CXNB, 0, data_fd) == -1)
+       if (xsocketpair(AF_UNIX, SOCK_STREAM | SOCK_CXNB, 0, data_fd) == -1)
                return -1;
-       if (socketpair(AF_UNIX, SOCK_STREAM | SOCK_CXNB, 0, listen_fd) == -1)
+       if (xsocketpair(AF_UNIX, SOCK_STREAM | SOCK_CXNB, 0, listen_fd) == -1)
                return -1;
-#ifdef PRIVSEP_RIGHTS
-       if (ps_rights_limit_fdpair(data_fd) == -1)
-               return -1;
-       if (ps_rights_limit_fdpair(listen_fd) == -1)
-               return -1;
-#endif
 
        pid = ps_dostart(ctx, &ctx->ps_control_pid, &ctx->ps_control_fd,
            ps_ctl_recvmsg, ps_ctl_dodispatch, ctx,
index aa5cd9abc2070f00aed9c1fe65a16e00562f5405..14760e6e2818ee6b2f3747aac7cb9c6085aeaf38 100644 (file)
@@ -284,12 +284,10 @@ ps_dostart(struct dhcpcd_ctx *ctx,
     void *recv_ctx, int (*callback)(void *), void (*signal_cb)(int, void *),
     unsigned int flags)
 {
-       int stype;
        int fd[2];
        pid_t pid;
 
-       stype = SOCK_CLOEXEC | SOCK_NONBLOCK;
-       if (socketpair(AF_UNIX, SOCK_DGRAM | stype, 0, fd) == -1) {
+       if (xsocketpair(AF_UNIX, SOCK_DGRAM | SOCK_CXNB, 0, fd) == -1) {
                logerr("%s: socketpair", __func__);
                return -1;
        }
@@ -297,12 +295,6 @@ ps_dostart(struct dhcpcd_ctx *ctx,
                logerr("%s: ps_setbuf_fdpair", __func__);
                return -1;
        }
-#ifdef PRIVSEP_RIGHTS
-       if (ps_rights_limit_fdpair(fd) == -1) {
-               logerr("%s: ps_rights_limit_fdpair", __func__);
-               return -1;
-       }
-#endif
 
        switch (pid = fork()) {
        case -1: