Blame SOURCES/sudo-1.9.7-sigchild.patch

b1b93b
From 727056e0c9519d8eecde801e950b35f2f69c72e2 Mon Sep 17 00:00:00 2001
b1b93b
From: "Todd C. Miller" <Todd.Miller@sudo.ws>
b1b93b
Date: Fri, 23 Apr 2021 07:41:27 -0600
b1b93b
Subject: [PATCH] Make sure SIGCHLD is not ignored when sudo is executed. If
b1b93b
 SIGCHLD is ignored there is a race condition between when the process is
b1b93b
 executed and when the SIGCHLD handler is installed. This fixes the bug
b1b93b
 described by GitHub PR #98
b1b93b
b1b93b
---
b1b93b
 src/signal.c | 12 ++++++++++++
b1b93b
 1 file changed, 12 insertions(+)
b1b93b
b1b93b
diff --git a/src/signal.c b/src/signal.c
b1b93b
index 7f90d707b..866b64790 100644
b1b93b
--- a/src/signal.c
b1b93b
+++ b/src/signal.c
b1b93b
@@ -133,6 +133,18 @@ init_signals(void)
b1b93b
 	    case SIGTTOU:
b1b93b
 		/* Don't install these until exec time. */
b1b93b
 		break;
b1b93b
+	    case SIGCHLD:
b1b93b
+		/* Sudo needs to be able to catch SIGCHLD. */
b1b93b
+		if (ss->sa.sa_handler == SIG_IGN) {
b1b93b
+		    sudo_debug_printf(SUDO_DEBUG_INFO,
b1b93b
+			"will restore signal %d on exec", SIGCHLD);
b1b93b
+		    ss->restore = true;
b1b93b
+		}
b1b93b
+		if (sigaction(SIGCHLD, &sa, NULL) != 0) {
b1b93b
+		    sudo_warn(U_("unable to set handler for signal %d"),
b1b93b
+			SIGCHLD);
b1b93b
+		}
b1b93b
+		break;
b1b93b
 	    default:
b1b93b
 		if (ss->sa.sa_handler != SIG_IGN) {
b1b93b
 		    if (sigaction(ss->signo, &sa, NULL) != 0) {