summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTodd C. Miller <Todd.Miller@courtesan.com>2014-02-05 12:03:58 -0700
committerTodd C. Miller <Todd.Miller@courtesan.com>2014-02-05 12:03:58 -0700
commit4e328f08d3593d0b105dd52fb76885b191bdb32e (patch)
tree42466a272ae973a952d04933537b7983aa7ff00c /src
parent62850a9308265539c1ac567db871c35800dc986b (diff)
downloadsudo-4e328f08d3593d0b105dd52fb76885b191bdb32e.tar.gz
In term_restore(), only restores the terminal if we are in the
foregroup process group. Instead of calling tcgetpgrp(), which is racy, we set a temporary handler for SIGTTOU and check whether it was received after a failed call to tcsetattr().
Diffstat (limited to 'src')
-rw-r--r--src/exec_pty.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/src/exec_pty.c b/src/exec_pty.c
index 0287c5d1b..d2975d54a 100644
--- a/src/exec_pty.c
+++ b/src/exec_pty.c
@@ -115,11 +115,8 @@ pty_cleanup(void)
{
debug_decl(cleanup, SUDO_DEBUG_EXEC);
- if (!TAILQ_EMPTY(&io_plugins) && io_fds[SFD_USERTTY] != -1) {
- check_foreground();
- if (foreground)
- term_restore(io_fds[SFD_USERTTY], 0);
- }
+ if (!TAILQ_EMPTY(&io_plugins) && io_fds[SFD_USERTTY] != -1)
+ term_restore(io_fds[SFD_USERTTY], 0);
#ifdef HAVE_SELINUX
selinux_restore_tty();
#endif
@@ -812,11 +809,8 @@ pty_close(struct command_status *cstat)
}
/* Restore terminal settings. */
- if (io_fds[SFD_USERTTY] != -1) {
- check_foreground();
- if (foreground)
- term_restore(io_fds[SFD_USERTTY], 0);
- }
+ if (io_fds[SFD_USERTTY] != -1)
+ term_restore(io_fds[SFD_USERTTY], 0);
/* If child was signalled, write the reason to stdout like the shell. */
if (cstat->type == CMD_WSTATUS && WIFSIGNALED(cstat->val)) {