aboutsummaryrefslogtreecommitdiff
path: root/libpam_misc
diff options
context:
space:
mode:
authorStanislav Brabec <sbrabec@suse.cz>2024-07-22 23:18:16 +0200
committerDmitry V. Levin <ldv@strace.io>2024-08-07 08:00:00 +0000
commit8ae228fa76ff9ef1d8d6b2199582d9206f1830c6 (patch)
tree5592c58d516283e094720334c68de98988067273 /libpam_misc
parent02f451baac4dfea03ac93b442f9f8ecbaf83adbf (diff)
downloadpam-8ae228fa76ff9ef1d8d6b2199582d9206f1830c6.tar.gz
pam-8ae228fa76ff9ef1d8d6b2199582d9206f1830c6.tar.bz2
pam-8ae228fa76ff9ef1d8d6b2199582d9206f1830c6.zip
libpam_misc: Use ECHOCTL in the terminal input
Use the canonical terminal mode (line mode) and set ECHOCTL to prevent cursor escape from the login prompt using arrows or escape sequences. ICANON is the default in most cases anyway. ECHOCTL is default on tty, but for example not on pty, allowing cursor to escape. Stanislav Brabec <sbrabec@suse.com>
Diffstat (limited to 'libpam_misc')
-rw-r--r--libpam_misc/misc_conv.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/libpam_misc/misc_conv.c b/libpam_misc/misc_conv.c
index 7410e929..6b839b48 100644
--- a/libpam_misc/misc_conv.c
+++ b/libpam_misc/misc_conv.c
@@ -145,9 +145,10 @@ static int read_string(int echo, const char *prompt, char **retstr)
return -1;
}
memcpy(&term_tmp, &term_before, sizeof(term_tmp));
- if (!echo) {
+ if (echo)
+ term_tmp.c_lflag |= ICANON | ECHOCTL;
+ else
term_tmp.c_lflag &= ~(ECHO);
- }
have_term = 1;
/*