From a6ac589cc14b8e171422ee9f42de3fd4ad64a49a Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Wed, 8 Nov 2023 16:58:02 -0700 Subject: [PATCH] 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. --- lib/util/term.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/util/term.c b/lib/util/term.c index a7286b59f..a195c8151 100644 --- a/lib/util/term.c +++ b/lib/util/term.c @@ -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__,