From: Roy Marples Date: Thu, 5 Jun 2014 13:03:49 +0000 (+0000) Subject: Ensure we init before forking, but run the preinit scripts afterwards X-Git-Tag: v6.4.0~16 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c9ce5cc4ff17930660ca89c742b90e45673708da;p=thirdparty%2Fdhcpcd.git Ensure we init before forking, but run the preinit scripts afterwards --- diff --git a/dhcpcd.c b/dhcpcd.c index 23895a91..3e25523f 100644 --- a/dhcpcd.c +++ b/dhcpcd.c @@ -674,7 +674,6 @@ static void init_state(struct interface *ifp, int argc, char **argv) { struct if_options *ifo; - const char *reason; configure_interface(ifp, argc, argv); ifo = ifp->options; @@ -696,9 +695,15 @@ init_state(struct interface *ifp, int argc, char **argv) syslog(LOG_ERR, "%s: ipv6_start: %m", ifp->name); ifo->options &= DHCPCD_IPV6; } +} + +static void +run_preinit(struct interface *ifp) +{ + const char *reason; reason = NULL; /* appease gcc */ - if (ifo->options & DHCPCD_LINK) { + if (ifp->options->options & DHCPCD_LINK) { switch (if_carrier(ifp)) { case LINK_DOWN: ifp->carrier = LINK_DOWN; @@ -772,6 +777,7 @@ dhcpcd_handleinterface(void *arg, int action, const char *ifname) } if (action > 0) { init_state(ifp, ctx->argc, ctx->argv); + run_preinit(ifp); dhcpcd_startinterface(ifp); } } @@ -849,6 +855,7 @@ reconf_reboot(struct dhcpcd_ctx *ctx, int action, int argc, char **argv, int oi) } else { TAILQ_INSERT_TAIL(ctx->ifaces, ifp, next); init_state(ifp, argc, argv); + run_preinit(ifp); dhcpcd_startinterface(ifp); } } @@ -1545,12 +1552,16 @@ main(int argc, char **argv) } } + TAILQ_FOREACH(ifp, ctx.ifaces, next) { + init_state(ifp, argc, argv); + } + if (ctx.options & DHCPCD_BACKGROUND && dhcpcd_daemonise(&ctx)) goto exit_success; opt = 0; TAILQ_FOREACH(ifp, ctx.ifaces, next) { - init_state(ifp, argc, argv); + run_preinit(ifp); if (ifp->carrier != LINK_DOWN) opt = 1; }