From: Roy Marples Date: Fri, 6 Jan 2023 11:14:45 +0000 (+0000) Subject: privsep: Try sending error if we cannot send the message. X-Git-Tag: v10.0.0~15 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=96f055d2e48ce48ce828e1c4c175d05afcd1b299;p=thirdparty%2Fdhcpcd.git privsep: Try sending error if we cannot send the message. There is an error sending a reply from an INET6 sysctl RT dump on FreeBSD-14 using the dhcpcd-9 branch. It seems to be related to capsicum and doesn't happen on FreeBSD-13. We should handle the error gracefully and allow dhcpcd to try to contuinue regardless. --- diff --git a/src/privsep-root.c b/src/privsep-root.c index 0bf2345c..5fda1626 100644 --- a/src/privsep-root.c +++ b/src/privsep-root.c @@ -209,12 +209,26 @@ ps_root_writeerror(struct dhcpcd_ctx *ctx, ssize_t result, { .iov_base = &psr, .iov_len = sizeof(psr) }, { .iov_base = data, .iov_len = len }, }; + ssize_t err; #ifdef PRIVSEP_DEBUG logdebugx("%s: result %zd errno %d", __func__, result, errno); #endif - return writev(ctx->ps_root->psp_fd, iov, __arraycount(iov)); + err = writev(ctx->ps_root->psp_fd, iov, __arraycount(iov)); + + /* Error sending the message? Try sending the error of sending. */ + if (err == -1) { + logerr("%s: result=%zd, data=%p, len=%zu", + __func__, result, data, len); + psr.psr_result = err; + psr.psr_errno = errno; + iov[1].iov_base = NULL; + iov[1].iov_len = 0; + err = writev(ctx->ps_root->psp_fd, iov, __arraycount(iov)); + } + + return err; } static ssize_t