]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
DHCP: Don't log an error if the lease file is empty
authorRoy Marples <roy@marples.name>
Sun, 1 Sep 2019 20:26:39 +0000 (21:26 +0100)
committerRoy Marples <roy@marples.name>
Sun, 1 Sep 2019 20:26:39 +0000 (21:26 +0100)
src/dhcp.c
src/dhcp6.c

index 591c00faf0c7c937774b61651f070d0cc0ddf5e5..4ba4ebca566278af3b4cdc5304b747ebd53c9fdf 100644 (file)
@@ -1178,7 +1178,6 @@ read_lease(struct interface *ifp, struct bootp **bootp)
                close(fd);
        if (bytes == 0) {
                free(lease);
-               logerr("%s: dhcp_read_lease_fd", __func__);
                return 0;
        }
 
index c6fd7af14f59c0c370fec25405897768038ac220..81a40c77dfb6ec8f2ef59127b522a821f2f978c1 100644 (file)
@@ -2517,16 +2517,19 @@ dhcp6_readlease(struct interface *ifp, int validate)
        lease = NULL;
        free(state->new);
        state->new_len = dhcp_read_lease_fd(fd, (void **)&lease);
-       state->new = lease;
+       state->new = state->new_len != 0 ? lease : NULL;
        if (fd_opened)
                close(fd);
-       if (state->new_len == 0)
-               goto ex;
 
        if (ifp->ctx->options & DHCPCD_DUMPLEASE ||
            state->leasefile[0] == '\0')
                return 0;
 
+       if (state->new_len == 0) {
+               retval = 0;
+               goto ex;
+       }
+
        /* If not validating IA's and if they have expired,
         * skip to the auth check. */
        if (!validate) {
@@ -2586,12 +2589,10 @@ auth:
 
 ex:
        dhcp6_freedrop_addrs(ifp, 0, NULL);
+       unlink(state->leasefile);
        free(state->new);
        state->new = NULL;
        state->new_len = 0;
-       if (!(ifp->ctx->options & DHCPCD_DUMPLEASE) &&
-           state->leasefile[0] != '\0')
-               unlink(state->leasefile);
        return retval;
 }