]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
privsep: Allow zero length messages through
authorRoy Marples <roy@marples.name>
Sat, 15 Jun 2024 09:04:06 +0000 (10:04 +0100)
committerRoy Marples <roy@marples.name>
Sat, 15 Jun 2024 09:04:06 +0000 (10:04 +0100)
They should be handled gracefully without privsep anyway.
Fix for #179.

src/privsep-inet.c
src/privsep.c
src/privsep.h

index 3a192ee0c461340d51c211a3f491d2c2ef2a32c4..7f7494f61ea9cf1c47033d69b41e558a3a00525d 100644 (file)
@@ -53,7 +53,7 @@ ps_inet_recvbootp(void *arg)
 {
        struct dhcpcd_ctx *ctx = arg;
 
-       if (ps_recvmsg(ctx, ctx->udp_rfd, PS_BOOTP, ctx->ps_inet_fd) == -1)
+       if (ps_recvmsg(ctx->udp_rfd, PS_BOOTP, ctx->ps_inet_fd) == -1)
                logerr(__func__);
 }
 #endif
@@ -67,12 +67,12 @@ ps_inet_recvra(void *arg)
        struct rs_state *state = RS_STATE(ifp);
        struct dhcpcd_ctx *ctx = ifp->ctx;
 
-       if (ps_recvmsg(ctx, state->nd_fd, PS_ND, ctx->ps_inet_fd) == -1)
+       if (ps_recvmsg(state->nd_fd, PS_ND, ctx->ps_inet_fd) == -1)
                logerr(__func__);
 #else
        struct dhcpcd_ctx *ctx = arg;
 
-       if (ps_recvmsg(ctx, ctx->nd_fd, PS_ND, ctx->ps_inet_fd) == -1)
+       if (ps_recvmsg(ctx->nd_fd, PS_ND, ctx->ps_inet_fd) == -1)
                logerr(__func__);
 #endif
 }
@@ -84,7 +84,7 @@ ps_inet_recvdhcp6(void *arg)
 {
        struct dhcpcd_ctx *ctx = arg;
 
-       if (ps_recvmsg(ctx, ctx->dhcp6_rfd, PS_DHCP6, ctx->ps_inet_fd) == -1)
+       if (ps_recvmsg(ctx->dhcp6_rfd, PS_DHCP6, ctx->ps_inet_fd) == -1)
                logerr(__func__);
 }
 #endif
@@ -374,7 +374,7 @@ ps_inet_recvinbootp(void *arg)
 {
        struct ps_process *psp = arg;
 
-       if (ps_recvmsg(psp->psp_ctx, psp->psp_work_fd,
+       if (ps_recvmsg(psp->psp_work_fd,
            PS_BOOTP, psp->psp_ctx->ps_data_fd) == -1)
                logerr(__func__);
 }
@@ -463,7 +463,7 @@ ps_inet_recvin6dhcp6(void *arg)
 {
        struct ps_process *psp = arg;
 
-       if (ps_recvmsg(psp->psp_ctx, psp->psp_work_fd,
+       if (ps_recvmsg(psp->psp_work_fd,
            PS_DHCP6, psp->psp_ctx->ps_data_fd) == -1)
                logerr(__func__);
 }
index ab29bb7bdb0210fc309b3c595ecf30edae6ff49b..0f78907ad782fd82edae55959e0abfe63f3a42d5 100644 (file)
@@ -897,7 +897,7 @@ nobufs:
 }
 
 ssize_t
-ps_recvmsg(struct dhcpcd_ctx *ctx, int rfd, uint16_t cmd, int wfd)
+ps_recvmsg(int rfd, uint16_t cmd, int wfd)
 {
        struct sockaddr_storage ss = { .ss_family = AF_UNSPEC };
        uint8_t controlbuf[sizeof(struct sockaddr_storage)] = { 0 };
@@ -913,24 +913,15 @@ ps_recvmsg(struct dhcpcd_ctx *ctx, int rfd, uint16_t cmd, int wfd)
 
        ssize_t len = recvmsg(rfd, &msg, 0);
 
-       if (len == -1)
+       if (len == -1) {
                logerr("%s: recvmsg", __func__);
-       if (len == -1 || len == 0) {
-               if (ctx->options & DHCPCD_FORKED &&
-                   !(ctx->options & DHCPCD_PRIVSEPROOT))
-                       eloop_exit(ctx->eloop,
-                           len == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
                return len;
        }
 
        iov[0].iov_len = (size_t)len;
        len = ps_sendcmdmsg(wfd, cmd, &msg);
-       if (len == -1) {
+       if (len == -1)
                logerr("ps_sendcmdmsg");
-               if (ctx->options & DHCPCD_FORKED &&
-                   !(ctx->options & DHCPCD_PRIVSEPROOT))
-                       eloop_exit(ctx->eloop, EXIT_FAILURE);
-       }
        return len;
 }
 
index 132f679a0560a06d328ff166f986628448ba982a..00184d0727e71e052b3a09abe5504fce552c9824 100644 (file)
@@ -192,7 +192,7 @@ ssize_t ps_sendmsg(struct dhcpcd_ctx *, int, uint16_t, unsigned long,
     const struct msghdr *);
 ssize_t ps_sendcmd(struct dhcpcd_ctx *, int, uint16_t, unsigned long,
     const void *data, size_t len);
-ssize_t ps_recvmsg(struct dhcpcd_ctx *, int, uint16_t, int);
+ssize_t ps_recvmsg(int, uint16_t, int);
 ssize_t ps_recvpsmsg(struct dhcpcd_ctx *, int,
     ssize_t (*callback)(void *, struct ps_msghdr *, struct msghdr *), void *);