]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
privsep: Improve error when we cannot write the lease
authorRoy Marples <roy@marples.name>
Mon, 30 Mar 2020 20:40:19 +0000 (21:40 +0100)
committerRoy Marples <roy@marples.name>
Mon, 30 Mar 2020 20:40:19 +0000 (21:40 +0100)
No permission without context isn't great.

src/dhcp.c
src/dhcp6.c

index 758ad779a192acb3e4553d76153eeec0ef7fa716..879ce3e5dd4a74e3a770284f2b6329fe6e50ddf5 100644 (file)
@@ -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. */
index d345b8349b8513cf32b55f49f1919c5086975665..42989d175c00937d2454565907f08fa77e2288d9 100644 (file)
@@ -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