]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
privsep: Don't handle any signals meant for the main process
authorRoy Marples <roy@marples.name>
Tue, 16 Jun 2020 11:58:16 +0000 (11:58 +0000)
committerRoy Marples <roy@marples.name>
Tue, 16 Jun 2020 11:58:16 +0000 (11:58 +0000)
Just incase someone issues a killall -HUP dhcpcd

src/dhcpcd.c
src/privsep-bpf.c
src/privsep-control.c
src/privsep-inet.c
src/privsep-root.c

index e030ff386aab567f3f50a4a15fc3eeb26f00b8f3..18e373c9256e007cb66cc9f5c4f8ae80e0848c0c 100644 (file)
@@ -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)
index 6189349db0f09e63b2bbf7a7f803305a6e4de6fd..69a38b4cde5b596132a9058ebafd54a774e38e67 100644 (file)
@@ -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);
 }
 
index 619171f8fde562c707c04eba9a7a3d08c261071c..9f9b554c68e3d4cf230e9ef745b93445681881e3 100644 (file)
@@ -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);
index 0ac2b39a797146a9365602c64c2e61f6d4d04f53..44013a28e0bc9e1dbabaa4b4eff2770e8af65ed8 100644 (file)
@@ -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);
index 46daeb0766ee6f9a401f1aaf8d9f2bc874cb0c6a..98829aea74b858ae00d1d4e4b50064fadce5227a 100644 (file)
@@ -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);
 }