]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Even if the script is /dev/null or NULL, always send the scripted environment
authorRoy Marples <roy@marples.name>
Wed, 3 Jun 2015 10:13:37 +0000 (10:13 +0000)
committerRoy Marples <roy@marples.name>
Wed, 3 Jun 2015 10:13:37 +0000 (10:13 +0000)
to our listeners.

script.c

index 66985a83883b7ef24cd685cfb4d62d9ce9121ac0..74338055b24f3689c2c5f845758876ebe630cc9e 100644 (file)
--- a/script.c
+++ b/script.c
@@ -622,20 +622,27 @@ script_runreason(const struct interface *ifp, const char *reason)
 
        if (ifp->options->script &&
            (ifp->options->script[0] == '\0' ||
-           strcmp(ifp->options->script, "/dev/null") == 0))
+           strcmp(ifp->options->script, "/dev/null") == 0) &&
+           TAILQ_FIRST(&ifp->ctx->control_fds) == NULL)
                return 0;
 
-       argv[0] = ifp->options->script ? ifp->options->script : UNCONST(SCRIPT);
-       argv[1] = NULL;
-       logger(ifp->ctx, LOG_DEBUG, "%s: executing `%s' %s",
-           ifp->name, argv[0], reason);
-
        /* Make our env */
        elen = (size_t)make_env(ifp, reason, &env);
        if (elen == (size_t)-1) {
                logger(ifp->ctx, LOG_ERR, "%s: make_env: %m", ifp->name);
                return -1;
        }
+
+       if (ifp->options->script &&
+           (ifp->options->script[0] == '\0' ||
+           strcmp(ifp->options->script, "/dev/null") == 0))
+               goto send_listeners;
+
+       argv[0] = ifp->options->script ? ifp->options->script : UNCONST(SCRIPT);
+       argv[1] = NULL;
+       logger(ifp->ctx, LOG_DEBUG, "%s: executing `%s' %s",
+           ifp->name, argv[0], reason);
+
        /* Resize for PATH and RC_SVCNAME */
        svcname = getenv(RC_SVCNAME);
        ep = realloc(env, sizeof(char *) * (elen + 2 + (svcname ? 1 : 0)));
@@ -694,6 +701,7 @@ script_runreason(const struct interface *ifp, const char *reason)
                            __func__, argv[0], strsignal(WTERMSIG(status)));
        }
 
+send_listeners:
        /* Send to our listeners */
        bigenv = NULL;
        status = 0;