]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
script: Fix not running when empty string or /dev/null
authorRoy Marples <roy@marples.name>
Mon, 25 Mar 2019 12:17:07 +0000 (12:17 +0000)
committerRoy Marples <roy@marples.name>
Mon, 25 Mar 2019 12:17:07 +0000 (12:17 +0000)
src/if-options.c
src/script.c

index 06c47b0593c741039dbb2bfe363d3d1b0e004507..9ef3bdbbb9c19373b00ae2698c5fc957eb10f9e3 100644 (file)
@@ -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__);
index ba4ce03b2936052e6d37fe0620fb55d5925f1f65..800c4c3164e1b6bc6ce35e657111e961c3891dfa 100644 (file)
@@ -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;