Skip to content

Commit

Permalink
sudo_term_restore: don't check c_cflag on systems with TCSASOFT.
Browse files Browse the repository at this point in the history
If TCSASOFT is present, tcsetattr() will ignore c_cflag.
Fixes a bug where sudo_term_restore() would refuse to change
the terminal settings back if the PARENB control flag was set.
GitHub issue #326.
  • Loading branch information
millert committed Nov 8, 2023
1 parent 0497bde commit a6ac589
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/util/term.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ sudo_term_restore_v1(int fd, bool flush)
ret = true;
goto unlock;
}
#if !TCSASOFT
/* Only systems without TCSASOFT make changes to c_cflag. */
if ((term.c_cflag & CONTROL_FLAGS) != (cur_term.c_cflag & CONTROL_FLAGS)) {
sudo_debug_printf(SUDO_DEBUG_INFO, "%s: not restoring terminal, "
"c_cflag changed; 0x%x, expected 0x%x", __func__,
Expand All @@ -186,6 +188,7 @@ sudo_term_restore_v1(int fd, bool flush)
ret = true;
goto unlock;
}
#endif
if ((term.c_lflag & LOCAL_FLAGS) != (cur_term.c_lflag & LOCAL_FLAGS)) {
sudo_debug_printf(SUDO_DEBUG_INFO, "%s: not restoring terminal, "
"c_lflag changed; 0x%x, expected 0x%x", __func__,
Expand Down

0 comments on commit a6ac589

Please sign in to comment.