diff options
| author | Roy Marples <roy@marples.name> | 2020-08-08 20:27:34 +0100 |
|---|---|---|
| committer | Roy Marples <roy@marples.name> | 2020-08-08 20:27:34 +0100 |
| commit | cef90b983f28cbe01b9df2e3ba920dcdbd85b60f (patch) | |
| tree | 59b6e2171b519de0b3ccf3880863b163fc44468a /src/privsep.c | |
| parent | 2c185da4f5e11e350265979bf14dfa307b307a1d (diff) | |
| download | dhcpcd-cef90b983f28cbe01b9df2e3ba920dcdbd85b60f.tar.xz | |
privsep: Improve some errors
Diffstat (limited to 'src/privsep.c')
| -rw-r--r-- | src/privsep.c | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/src/privsep.c b/src/privsep.c index 65260f2c..c5e89baf 100644 --- a/src/privsep.c +++ b/src/privsep.c @@ -645,12 +645,12 @@ ps_sendpsmmsg(struct dhcpcd_ctx *ctx, int fd, iovlen = 1; len = writev(fd, iov, iovlen); -#ifdef PRIVSEP_DEBUG - logdebugx("%s: %zd", __func__, len); -#endif - if ((len == -1 || len == 0) && ctx->options & DHCPCD_FORKED && - !(ctx->options & DHCPCD_PRIVSEPROOT)) - eloop_exit(ctx->eloop, len == 0 ? EXIT_SUCCESS : EXIT_FAILURE); + if (len == -1) { + logerr(__func__); + if (ctx->options & DHCPCD_FORKED && + !(ctx->options & DHCPCD_PRIVSEPROOT)) + eloop_exit(ctx->eloop, EXIT_FAILURE); + } return len; } @@ -789,10 +789,9 @@ ps_recvmsg(struct dhcpcd_ctx *ctx, int rfd, uint16_t cmd, int wfd) }; ssize_t len = recvmsg(rfd, &msg, 0); -#ifdef PRIVSEP_DEBUG - logdebugx("%s: recv fd %d, %zd bytes", __func__, rfd, len); -#endif + if (len == -1) + logerr("%s: recvmsg", __func__); if (len == -1 || len == 0) { if (ctx->options & DHCPCD_FORKED && !(ctx->options & DHCPCD_PRIVSEPROOT)) @@ -803,12 +802,12 @@ ps_recvmsg(struct dhcpcd_ctx *ctx, int rfd, uint16_t cmd, int wfd) iov[0].iov_len = (size_t)len; len = ps_sendcmdmsg(wfd, cmd, &msg); -#ifdef PRIVSEP_DEBUG - logdebugx("%s: send fd %d, %zu bytes", __func__, wfd, len); -#endif - if ((len == -1 || len == 0) && ctx->options & DHCPCD_FORKED && - !(ctx->options & DHCPCD_PRIVSEPROOT)) - eloop_exit(ctx->eloop, len == 0 ? EXIT_SUCCESS : EXIT_FAILURE); + if (len == -1) { + logerr("ps_sendcmdmsg"); + if (ctx->options & DHCPCD_FORKED && + !(ctx->options & DHCPCD_PRIVSEPROOT)) + eloop_exit(ctx->eloop, EXIT_FAILURE); + } return len; } |
