summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd C. Miller <Todd.Miller@sudo.ws>2023-05-11 18:22:06 -0600
committerTodd C. Miller <Todd.Miller@sudo.ws>2023-05-11 18:22:06 -0600
commit04b77312db0c7977311d2438bf19604e10cf464d (patch)
treeffa539320d2b9a42d6c02ad68ecdea674d4274a4
parent7c63b65be3550c6767da1d708e01fea6f9de9cb9 (diff)
downloadsudo-master.tar.gz
Work around a macOS a kernel bug where tcsetpgrp() does not restart.HEADmaster
I reported this bug to Apple over 12 years ago.
-rw-r--r--plugins/sudoers/visudo.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/plugins/sudoers/visudo.c b/plugins/sudoers/visudo.c
index 2f6289e28..a2f39b8c8 100644
--- a/plugins/sudoers/visudo.c
+++ b/plugins/sudoers/visudo.c
@@ -983,12 +983,19 @@ run_command(const char *path, char *const *argv)
* (suspending visudo itself if running in the background).
*/
if (ttyfd != -1) {
+ retry:
if (tcsetpgrp(ttyfd, pid) == 0) {
sudo_debug_printf(SUDO_DEBUG_DIAG, "%s: %d: continuing",
__func__, (int)pid);
killpg(pid, SIGCONT);
break;
} else {
+ /*
+ * macOS suffers from a kernel bug where tcsetpgrp()
+ * is not restarted so we have to do it manually.
+ */
+ if (errno == EINTR && tcgetpgrp(ttyfd) == visudo_pgrp)
+ goto retry;
sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_ERRNO,
"%s: unable to set foreground pgrp to %d (visudo)",
__func__, (int)visudo_pgrp);