summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2020-06-16 11:58:16 +0000
committerRoy Marples <roy@marples.name>2020-06-16 11:58:16 +0000
commit84a8cab4e03c42b445fbcb33c3c03dd93e8803cc (patch)
tree146d8dbc81f0365edb5b42a3c3c24689e4b28dfd
parent51954c915aa6914486fc386cbe1e9aece02d368c (diff)
downloaddhcpcd-84a8cab4e03c42b445fbcb33c3c03dd93e8803cc.tar.xz
privsep: Don't handle any signals meant for the main process
Just incase someone issues a killall -HUP dhcpcd
-rw-r--r--src/dhcpcd.c3
-rw-r--r--src/privsep-bpf.c10
-rw-r--r--src/privsep-control.c10
-rw-r--r--src/privsep-inet.c10
-rw-r--r--src/privsep-root.c23
5 files changed, 41 insertions, 15 deletions
diff --git a/src/dhcpcd.c b/src/dhcpcd.c
index e030ff38..18e373c9 100644
--- a/src/dhcpcd.c
+++ b/src/dhcpcd.c
@@ -1409,6 +1409,9 @@ dhcpcd_signal_cb(int sig, void *arg)
}
if (sig != SIGCHLD && ctx->options & DHCPCD_FORKED) {
+ if (sig == SIGHUP)
+ return;
+
pid_t pid = pidfile_read(ctx->pidfile);
if (pid == -1) {
if (errno != ENOENT)
diff --git a/src/privsep-bpf.c b/src/privsep-bpf.c
index 6189349d..69a38b4c 100644
--- a/src/privsep-bpf.c
+++ b/src/privsep-bpf.c
@@ -175,6 +175,16 @@ ps_bpf_signal_bpfcb(int sig, void *arg)
{
struct dhcpcd_ctx *ctx = arg;
+ /* Ignore dhcpcd signals */
+ switch (sig) {
+ case SIGINT:
+ case SIGALRM:
+ case SIGHUP:
+ case SIGUSR1:
+ case SIGUSR2:
+ return;
+ }
+
eloop_exit(ctx->eloop, sig == SIGTERM ? EXIT_SUCCESS : EXIT_FAILURE);
}
diff --git a/src/privsep-control.c b/src/privsep-control.c
index 619171f8..9f9b554c 100644
--- a/src/privsep-control.c
+++ b/src/privsep-control.c
@@ -100,9 +100,15 @@ ps_ctl_signalcb(int sig, void *arg)
{
struct dhcpcd_ctx *ctx = arg;
- /* Ignore SIGINT, respect PS_STOP command or SIGTERM. */
- if (sig == SIGINT)
+ /* Ignore dhcpcd signals */
+ switch (sig) {
+ case SIGINT:
+ case SIGALRM:
+ case SIGHUP:
+ case SIGUSR1:
+ case SIGUSR2:
return;
+ }
shutdown(ctx->ps_control_fd, SHUT_RDWR);
eloop_exit(ctx->eloop, sig == SIGTERM ? EXIT_SUCCESS : EXIT_FAILURE);
diff --git a/src/privsep-inet.c b/src/privsep-inet.c
index 0ac2b39a..44013a28 100644
--- a/src/privsep-inet.c
+++ b/src/privsep-inet.c
@@ -296,9 +296,15 @@ ps_inet_signalcb(int sig, void *arg)
{
struct dhcpcd_ctx *ctx = arg;
- /* Ignore SIGINT, respect PS_STOP command or SIGTERM. */
- if (sig == SIGINT)
+ /* Ignore dhcpcd signals */
+ switch (sig) {
+ case SIGINT:
+ case SIGALRM:
+ case SIGHUP:
+ case SIGUSR1:
+ case SIGUSR2:
return;
+ }
shutdown(ctx->ps_inet_fd, SHUT_RDWR);
eloop_exit(ctx->eloop, sig == SIGTERM ? EXIT_SUCCESS : EXIT_FAILURE);
diff --git a/src/privsep-root.c b/src/privsep-root.c
index 46daeb07..98829aea 100644
--- a/src/privsep-root.c
+++ b/src/privsep-root.c
@@ -686,23 +686,24 @@ ps_root_signalcb(int sig, void *arg)
{
struct dhcpcd_ctx *ctx = arg;
- /* Ignore SIGINT, respect PS_STOP command or SIGTERM. */
- if (sig == SIGINT)
+ /* Ignore dhcpcd signals, but reap children */
+ switch (sig) {
+ case SIGINT:
+ case SIGALRM:
+ case SIGHUP:
+ case SIGUSR1:
+ case SIGUSR2:
return;
-
- /* Reap children */
- if (sig == SIGCHLD) {
+ case SIGCHLD:
while (waitpid(-1, NULL, WNOHANG) > 0)
;
return;
}
- logerrx("process %d unexpectedly terminating on signal %d",
- getpid(), sig);
- if (ctx->ps_root_pid == getpid()) {
- shutdown(ctx->ps_root_fd, SHUT_RDWR);
- shutdown(ctx->ps_data_fd, SHUT_RDWR);
- }
+ logerrx("%s: process %d unexpectedly terminating on signal %d",
+ __func__, getpid(), sig);
+ shutdown(ctx->ps_root_fd, SHUT_RDWR);
+ shutdown(ctx->ps_data_fd, SHUT_RDWR);
eloop_exit(ctx->eloop, sig == SIGTERM ? EXIT_SUCCESS : EXIT_FAILURE);
}