From 73eb0665d357f16a7696fae1b314e7f23f859d34 Mon Sep 17 00:00:00 2001 From: Christos Zoulas Date: Mon, 6 Apr 2020 21:11:45 +0100 Subject: [PATCH] scripts: Run with an empty sigmask 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 | 2 +- src/script.c | 6 +++--- src/script.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/privsep-root.c b/src/privsep-root.c index 0f099bb7..95a62f96 100644 --- a/src/privsep-root.c +++ b/src/privsep-root.c @@ -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 */ diff --git a/src/script.c b/src/script.c index bb17d12c..186b6e05 100644 --- a/src/script.c +++ b/src/script.c @@ -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) { diff --git a/src/script.h b/src/script.h index 0f20f988..769f3787 100644 --- a/src/script.h +++ b/src/script.h @@ -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 *); -- 2.47.2