]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Make TEST work once more.
authorRoy Marples <roy@marples.name>
Fri, 5 Sep 2008 07:31:09 +0000 (07:31 +0000)
committerRoy Marples <roy@marples.name>
Fri, 5 Sep 2008 07:31:09 +0000 (07:31 +0000)
bind.c
dhcpcd.c
if-options.c

diff --git a/bind.c b/bind.c
index b0f7c9ba9eb8946ca00a20b41f7a96d3d12b5498..8d058d1193d2800c5299c81f3386ccc0885eb46d 100644 (file)
--- a/bind.c
+++ b/bind.c
@@ -173,6 +173,10 @@ bind_interface(void *arg)
                } else
                        reason = "BOUND";
        }
+       if (options & DHCPCD_TEST) {
+               run_script(iface, "TEST");
+               exit(EXIT_SUCCESS);
+       }
        if (lease->leasetime == ~0U)
                lease->renewaltime = lease->rebindtime = lease->leasetime;
        else {
index 023157986476458e7f25f568eec08a62a69f100d..3094fd2bb61fc8388d58b99dd7d04b0b19a3cef1 100644 (file)
--- a/dhcpcd.c
+++ b/dhcpcd.c
@@ -457,13 +457,17 @@ handle_dhcp(struct interface *iface, struct dhcp_message **dhcpp)
                lease->addr.s_addr = dhcp->yiaddr;
                get_option_addr(&lease->server.s_addr, dhcp, DHO_SERVERID);
                log_dhcp(LOG_INFO, "offered", iface, dhcp);
-               if (ifo->options & DHCPCD_TEST) {
-                       run_script(iface, "TEST");
-                       exit(EXIT_SUCCESS);
-               }
                free(state->offer);
                state->offer = dhcp;
                *dhcpp = NULL;
+               if (options & DHCPCD_TEST) {
+                       free(state->old);
+                       state->old = state->new;
+                       state->new = state->offer;
+                       state->offer = NULL;
+                       run_script(iface, "TEST");
+                       exit(EXIT_SUCCESS);
+               }
                delete_timeout(send_discover, iface);
                if (ifo->options & DHCPCD_ARP &&
                    iface->addr.s_addr != state->offer->yiaddr)
@@ -1029,7 +1033,7 @@ main(int argc, char **argv)
 
        /* If we have any other args, we should run as a single dhcpcd instance
         * for that interface. */
-       if (optind == argc - 1)
+       if (optind == argc - 1 && !(options & DHCPCD_TEST))
                snprintf(pidfile, sizeof(pidfile), PIDFILE, "-", argv[optind]);
        else {
                snprintf(pidfile, sizeof(pidfile), PIDFILE, "", "");
index 7d037a4edf4e80942f2b0ddf783785f8a9636244..1b33a7289aa22bca488a684da63bec9859f7fba4 100644 (file)
@@ -262,7 +262,8 @@ parse_option(struct if_options *ifo, int opt, const char *arg)
        case 'k': /* FALLTHROUGH */
        case 'n': /* FALLTHROUGH */
        case 'x': /* FALLTHROUGH */
-       case 'B': /* We need to handle non interface options */
+       case 'B': /* FALLTHROUGH */
+       case 'T': /* We need to handle non interface options */
                break;
        case 'c':
                strlcpy(ifo->script, arg, sizeof(ifo->script));