From: Roy Marples Date: Mon, 25 Mar 2019 12:17:07 +0000 (+0000) Subject: script: Fix not running when empty string or /dev/null X-Git-Tag: v7.2.0~24 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fc281aed78b0955623e5168568b9a6b629990de3;p=thirdparty%2Fdhcpcd.git script: Fix not running when empty string or /dev/null --- diff --git a/src/if-options.c b/src/if-options.c index 06c47b05..9ef3bdbb 100644 --- a/src/if-options.c +++ b/src/if-options.c @@ -709,6 +709,10 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo, case 'c': ARG_REQUIRED; free(ifo->script); + if (*arg == '\0' || strcmp(arg, "/dev/null") == 0) { + ifo->script = NULL; + break; + } ifo->script = strdup(arg); if (ifo->script == NULL) logerr(__func__); diff --git a/src/script.c b/src/script.c index ba4ce03b..800c4c31 100644 --- a/src/script.c +++ b/src/script.c @@ -704,9 +704,7 @@ script_runreason(const struct interface *ifp, const char *reason) int status = 0; struct fd_list *fd; - if (ifp->options->script && - (ifp->options->script[0] == '\0' || - strcmp(ifp->options->script, "/dev/null") == 0) && + if (ifp->options->script == NULL || TAILQ_FIRST(&ifp->ctx->control_fds) == NULL) return 0;