From: Roy Marples Date: Mon, 30 Mar 2020 20:40:19 +0000 (+0100) Subject: privsep: Improve error when we cannot write the lease X-Git-Tag: v9.0.1~20 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9231f6ba23f68ca5f22f55b9e518101e1578504e;p=thirdparty%2Fdhcpcd.git privsep: Improve error when we cannot write the lease No permission without context isn't great. --- diff --git a/src/dhcp.c b/src/dhcp.c index 758ad779..879ce3e5 100644 --- a/src/dhcp.c +++ b/src/dhcp.c @@ -2301,7 +2301,7 @@ dhcp_bind(struct interface *ifp) if (!state->lease.frominfo && !(ifo->options & (DHCPCD_INFORM | DHCPCD_STATIC))) if (write_lease(ifp, state->new, state->new_len) == -1) - logerr(__func__); + logerr("write_lease: %s", state->leasefile); /* Close the BPF filter as we can now receive DHCP messages * on a UDP socket. */ diff --git a/src/dhcp6.c b/src/dhcp6.c index d345b834..42989d17 100644 --- a/src/dhcp6.c +++ b/src/dhcp6.c @@ -2503,10 +2503,8 @@ dhcp6_writelease(const struct interface *ifp) logdebugx("%s: writing lease `%s'", ifp->name, state->leasefile); fd = open(state->leasefile, O_WRONLY | O_CREAT | O_TRUNC, 0644); - if (fd == -1) { - logerr(__func__); + if (fd == -1) return -1; - } bytes = write(fd, state->new, state->new_len); close(fd); return bytes; @@ -3162,7 +3160,8 @@ dhcp6_bind(struct interface *ifp, const char *op, const char *sfrom) ifp->name, state->expire); rt_build(ifp->ctx, AF_INET6); if (!confirmed && !timedout) - dhcp6_writelease(ifp); + if (dhcp6_writelease(ifp) == -1) + logerr("dhcp6_writelease: %s",state->leasefile); #ifndef SMALL dhcp6_delegate_prefix(ifp); #endif