sudo_term_restore: don't check c_cflag on systems with TCSASOFT.

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.
This commit is contained in:
Todd C. Miller
2023-11-08 16:58:02 -07:00
parent 0497bde983
commit a6ac589cc1

View File

@@ -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__,
@@ -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__,