Skip to content

Commit a6ac589

Browse files
committed
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.
1 parent 0497bde commit a6ac589

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

lib/util/term.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,8 @@ sudo_term_restore_v1(int fd, bool flush)
178178
ret = true;
179179
goto unlock;
180180
}
181+
#if !TCSASOFT
182+
/* Only systems without TCSASOFT make changes to c_cflag. */
181183
if ((term.c_cflag & CONTROL_FLAGS) != (cur_term.c_cflag & CONTROL_FLAGS)) {
182184
sudo_debug_printf(SUDO_DEBUG_INFO, "%s: not restoring terminal, "
183185
"c_cflag changed; 0x%x, expected 0x%x", __func__,
@@ -186,6 +188,7 @@ sudo_term_restore_v1(int fd, bool flush)
186188
ret = true;
187189
goto unlock;
188190
}
191+
#endif
189192
if ((term.c_lflag & LOCAL_FLAGS) != (cur_term.c_lflag & LOCAL_FLAGS)) {
190193
sudo_debug_printf(SUDO_DEBUG_INFO, "%s: not restoring terminal, "
191194
"c_lflag changed; 0x%x, expected 0x%x", __func__,

0 commit comments

Comments
 (0)