Blame SOURCES/sudo-1.9.7-sigchild.patch

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