]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
If dumping leases, skip authentication and address expiry checks.
authorRoy Marples <roy@marples.name>
Wed, 18 Nov 2015 17:06:32 +0000 (17:06 +0000)
committerRoy Marples <roy@marples.name>
Wed, 18 Nov 2015 17:06:32 +0000 (17:06 +0000)
dhcp.c
dhcp6.c

diff --git a/dhcp.c b/dhcp.c
index 12aba1183ce159dbcb69ab413b81affd3d994041..0ee7295be0db74b51a714d97c24736d3f7da7117 100644 (file)
--- a/dhcp.c
+++ b/dhcp.c
@@ -1153,6 +1153,9 @@ read_lease(struct interface *ifp)
                return NULL;
        }
 
+       if (ifp->ctx->options & DHCPCD_DUMPLEASE)
+               return dhcp;
+
        /* We may have found a BOOTP server */
        if (get_option_uint8(ifp->ctx, &type, dhcp, DHO_MESSAGETYPE) == -1)
                type = 0;
diff --git a/dhcp6.c b/dhcp6.c
index 06b280a5e3d278af5677a926b7a7f41857925fc7..eef7e4b4120918c7c3ea7b428e9291a24ce70809 100644 (file)
--- a/dhcp6.c
+++ b/dhcp6.c
@@ -2189,18 +2189,14 @@ dhcp6_readlease(struct interface *ifp, int validate)
        void *newnew;
 
        state = D6_STATE(ifp);
-       if (state->leasefile[0] == '\0')
-               logger(ifp->ctx, LOG_DEBUG, "reading standard input");
-       else {
-               if (stat(state->leasefile, &st) == -1)
-                       return -1;
+       if (state->leasefile[0] == '\0') {
+               logger(ifp->ctx, LOG_DEBUG, "reading standard input");
+               fd = fileno(stdin);
+       } else {
                logger(ifp->ctx, LOG_DEBUG, "%s: reading lease `%s'",
                    ifp->name, state->leasefile);
-       }
-       if (state->leasefile[0] == '\0')
-               fd = fileno(stdin);
-       else
                fd = open(state->leasefile, O_RDONLY);
+       }
        if (fd == -1)
                return -1;
        state->new_len = 0;
@@ -2232,6 +2228,9 @@ dhcp6_readlease(struct interface *ifp, int validate)
        if (retval == -1)
                goto ex;
 
+       if (ifp->ctx->options & DHCPCD_DUMPLEASE)
+               return 0;
+
        /* If not validating IA's and if they have expired,
         * skip to the auth check. */
        if (!validate) {
@@ -2239,24 +2238,21 @@ dhcp6_readlease(struct interface *ifp, int validate)
                goto auth;
        }
 
-       if ((now = time(NULL)) == -1) {
-               retval = 1;
+       retval = -1;
+       if (stat(state->leasefile, &st) == -1)
                goto ex;
-       }
-
        clock_gettime(CLOCK_MONOTONIC, &acquired);
+       if ((now = time(NULL)) == -1)
+               goto ex;
        acquired.tv_sec -= now - st.st_mtime;
 
        /* Check to see if the lease is still valid */
        fd = dhcp6_validatelease(ifp, state->new, state->new_len, NULL,
            &acquired);
-       if (fd == -1) {
-               retval = 1;
+       if (fd == -1)
                goto ex;
-       }
 
-       if (!(ifp->ctx->options & DHCPCD_DUMPLEASE) &&
-           state->expire != ND6_INFINITE_LIFETIME &&
+       if (state->expire != ND6_INFINITE_LIFETIME &&
            state->leasefile[0] != '\0')
        {
                if ((time_t)state->expire < now - st.st_mtime) {