From bbe4fbaaae99e56d2434646eab2e46e69655753c Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Mon, 7 Nov 2022 14:51:42 -0700 Subject: [PATCH] Call terminate_command() with use_pgrp = false when not running in a pty. When sudo runs a command in the user's existing terminal the command is run in the same process group as sudo itself. The proper way to terminate it is to use kill(2), not killpg(3) --- src/exec_nopty.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/exec_nopty.c b/src/exec_nopty.c index 6e22a1ba3..a7928b64b 100644 --- a/src/exec_nopty.c +++ b/src/exec_nopty.c @@ -374,7 +374,7 @@ read_callback(int fd, int what, void *v) sudo_debug_printf(SUDO_DEBUG_INFO, "read %zd bytes from fd %d", n, fd); if (!iob->action(iob->buf + iob->len, n, iob)) { - terminate_command(iob->ec->cmnd_pid, true); + terminate_command(iob->ec->cmnd_pid, false); iob->ec->cmnd_pid = -1; } iob->len += n; @@ -671,7 +671,7 @@ exec_nopty(struct command_details *details, struct command_status *cstat) } } if (rc == -1) - terminate_command(ec.cmnd_pid, true); + terminate_command(ec.cmnd_pid, false); } /* Enable any I/O log events. */ @@ -690,7 +690,7 @@ exec_nopty(struct command_details *details, struct command_status *cstat) /* error from callback */ sudo_debug_printf(SUDO_DEBUG_ERROR, "event loop exited prematurely"); /* kill command */ - terminate_command(ec.cmnd_pid, true); + terminate_command(ec.cmnd_pid, false); ec.cmnd_pid = -1; }