From 2d243af6b8ebe579f19ad27d3ab3907ebfe6a77e Mon Sep 17 00:00:00 2001 From: Tomas Mraz Date: Wed, 9 Nov 2005 10:17:00 +0000 Subject: Relevant BUGIDs: 562730, 435990 Purpose of commit: bugfix Commit summary: --------------- * modules/pam_access/pam_access.c (pam_sm_acct_mgmt): Parse correctly full path tty name. * modules/pam_time/pam_time.c (pam_sm_acct_mgmt): Parse correctly full path tty name. Allow unset tty. (logic_member): Allow matching ':' in tty name. * modules/pam_group/pam_group.c (pam_sm_acct_mgmt): Parse correctly full path tty name. Allow unset tty. (logic_member): Allow matching ':' in tty name. * libpam_misc/misc_conv.c (read_string): Read only up to EOL if stdin is not terminal. --- libpam_misc/misc_conv.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'libpam_misc') diff --git a/libpam_misc/misc_conv.c b/libpam_misc/misc_conv.c index ded256b2..52d647ab 100644 --- a/libpam_misc/misc_conv.c +++ b/libpam_misc/misc_conv.c @@ -180,7 +180,18 @@ static int read_string(int echo, const char *prompt, char **retstr) D(("")); break; } else { - nc = read(STDIN_FILENO, line, INPUTSIZE-1); + if (have_term) + nc = read(STDIN_FILENO, line, INPUTSIZE-1); + else /* we must read one line only */ + for (nc = 0; nc < INPUTSIZE-1 && (nc?line[nc-1]:0) != '\n'; + nc++) { + int rv; + if ((rv=read(STDIN_FILENO, line+nc, 1)) != 1) { + if (rv < 0) + nc = rv; + break; + } + } if (have_term) { (void) tcsetattr(STDIN_FILENO, TCSADRAIN, &term_before); if (!echo || expired) /* do we need a newline? */ -- cgit v1.2.3