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)
This commit is contained in:
Todd C. Miller
2022-11-07 14:51:42 -07:00
parent 36742deec3
commit bbe4fbaaae

View File

@@ -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;
}