From: Roy Marples Date: Fri, 5 Sep 2008 07:31:09 +0000 (+0000) Subject: Make TEST work once more. X-Git-Tag: v5.0.0~292 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e7eeaf88da7f1512b33847d180288f4158ef6bd4;p=thirdparty%2Fdhcpcd.git Make TEST work once more. --- diff --git a/bind.c b/bind.c index b0f7c9ba..8d058d11 100644 --- 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 { diff --git a/dhcpcd.c b/dhcpcd.c index 02315798..3094fd2b 100644 --- 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, "", ""); diff --git a/if-options.c b/if-options.c index 7d037a4e..1b33a728 100644 --- a/if-options.c +++ b/if-options.c @@ -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));