]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Fix dumping DHCPv6 leases. This broke when we ignored IAIDs we didn't ask for.
authorRoy Marples <roy@marples.name>
Thu, 3 Jul 2014 09:47:42 +0000 (09:47 +0000)
committerRoy Marples <roy@marples.name>
Thu, 3 Jul 2014 09:47:42 +0000 (09:47 +0000)
dhcp6.c
dhcpcd.c

diff --git a/dhcp6.c b/dhcp6.c
index 1c10e1cf16ded3d1f9f64efef84e35cbd05276d4..921ea00cc27be35f139062c8b8cdf6e4308d4c31 100644 (file)
--- a/dhcp6.c
+++ b/dhcp6.c
@@ -1822,7 +1822,7 @@ dhcp6_readlease(struct interface *ifp)
        if (fd == -1)
                goto ex;
        if (fd == 0) {
-               syslog(LOG_INFO, "%s: lease was for different IA type",
+               syslog(LOG_INFO, "%s: no useable IA found in lease",
                    ifp->name);
                goto ex;
        }
@@ -1867,7 +1867,8 @@ ex:
        free(state->new);
        state->new = NULL;
        state->new_len = 0;
-       unlink(state->leasefile);
+       if (!(ifp->ctx->options & DHCPCD_DUMPLEASE))
+               unlink(state->leasefile);
        return 0;
 }
 
index 47481ded607d2849e0372703aa1dc249cc39e8be..3322a271f25b8b655130db95c3982f1e7e7a5b87 100644 (file)
--- a/dhcpcd.c
+++ b/dhcpcd.c
@@ -1383,20 +1383,22 @@ main(int argc, char **argv)
                        goto exit_failure;
                }
                i = 0;
-               if (ctx.ifaces == NULL) {
-                       ctx.ifaces = malloc(sizeof(*ctx.ifaces));
-                       if (ctx.ifaces == NULL) {
+               /* We need to try and find the interface so we can
+                * load the hardware address to compare automated IAID */
+               ctx.ifaces = if_discover(&ctx, 1, argv + optind);
+               if (ctx.ifaces == NULL)
+                       goto exit_failure;
+               ifp = TAILQ_FIRST(ctx.ifaces);
+               if (ifp == NULL) {
+                       ifp = calloc(1, sizeof(*ifp));
+                       if (ifp == NULL) {
                                syslog(LOG_ERR, "%s: %m", __func__);
                                goto exit_failure;
                        }
-                       TAILQ_INIT(ctx.ifaces);
+                       strlcpy(ifp->name, argv[optind], sizeof(ifp->name));
+                       ifp->ctx = &ctx;
+                       TAILQ_INSERT_HEAD(ctx.ifaces, ifp, next);
                }
-               ifp = calloc(1, sizeof(*ifp));
-               if (ifp == NULL)
-                       goto exit_failure;
-               strlcpy(ifp->name, argv[optind], sizeof(ifp->name));
-               ifp->ctx = &ctx;
-               TAILQ_INSERT_HEAD(ctx.ifaces, ifp, next);
                configure_interface(ifp, 0, NULL);
                if (family == 0 || family == AF_INET) {
                        if (dhcp_dump(ifp) == -1)