]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
scripts: Run with an empty sigmask
authorChristos Zoulas <christos@zoulas.com>
Mon, 6 Apr 2020 20:11:45 +0000 (21:11 +0100)
committerRoy Marples <roy@marples.name>
Mon, 6 Apr 2020 20:11:45 +0000 (21:11 +0100)
An empty signal mask is probably more appropriate, since most
programs presume that the signal mask is empty when they start
even when they are using signals.

src/privsep-root.c
src/script.c
src/script.h

index 0f099bb7504270b5b4c2536878e6243e6af3a1ce..95a62f9604aa5792571a3fecf991ba56920a5eb5 100644 (file)
@@ -188,7 +188,7 @@ ps_root_run_script(struct dhcpcd_ctx *ctx, const void *data, size_t len)
        if (script_buftoenv(ctx, UNCONST(envbuf), len) == NULL)
                return -1;
 
-       pid = script_exec(ctx, argv, ctx->script_env);
+       pid = script_exec(argv, ctx->script_env);
        if (pid == -1)
                return -1;
        /* Wait for the script to finish */
index bb17d12ca1606a122f488a455af33e957b968ef9..186b6e05d435ae37131884545e6466ad96ea3d18 100644 (file)
@@ -84,7 +84,7 @@ if_printoptions(void)
 }
 
 pid_t
-script_exec(const struct dhcpcd_ctx *ctx, char *const *argv, char *const *env)
+script_exec(char *const *argv, char *const *env)
 {
        pid_t pid = 0;
        posix_spawnattr_t attr;
@@ -105,10 +105,10 @@ script_exec(const struct dhcpcd_ctx *ctx, char *const *argv, char *const *env)
        flags = POSIX_SPAWN_SETSIGMASK | POSIX_SPAWN_SETSIGDEF;
        posix_spawnattr_setflags(&attr, flags);
        sigemptyset(&defsigs);
+       posix_spawnattr_setsigmask(&attr, &defsigs);
        for (i = 0; i < dhcpcd_signals_len; i++)
                sigaddset(&defsigs, dhcpcd_signals[i]);
        posix_spawnattr_setsigdefault(&attr, &defsigs);
-       posix_spawnattr_setsigmask(&attr, &ctx->sigset);
 #endif
        errno = 0;
        r = posix_spawn(&pid, argv[0], NULL, &attr, argv, env);
@@ -657,7 +657,7 @@ script_run(struct dhcpcd_ctx *ctx, char **argv)
        pid_t pid;
        int status = 0;
 
-       pid = script_exec(ctx, argv, ctx->script_env);
+       pid = script_exec(argv, ctx->script_env);
        if (pid == -1)
                logerr("%s: %s", __func__, argv[0]);
        else if (pid != 0) {
index 0f20f9888c766aabde3de712157d53b04a83a830..769f3787df9187013f0e34f10fd2719aac8f4210 100644 (file)
@@ -34,7 +34,7 @@
 __printflike(2, 3) int efprintf(FILE *, const char *, ...);
 void if_printoptions(void);
 char ** script_buftoenv(struct dhcpcd_ctx *, char *, size_t);
-pid_t script_exec(const struct dhcpcd_ctx *, char *const *, char *const *);
+pid_t script_exec(char *const *, char *const *);
 int send_interface(struct fd_list *, const struct interface *, int);
 int script_runreason(const struct interface *, const char *);
 int script_runchroot(struct dhcpcd_ctx *, char *);