diff options
author | Andrew G. Morgan <morgan@kernel.org> | 2001-10-11 04:14:30 +0000 |
---|---|---|
committer | Andrew G. Morgan <morgan@kernel.org> | 2001-10-11 04:14:30 +0000 |
commit | 345044121bc4e8977a22d6235d31df4b2114a240 (patch) | |
tree | 9b76c2ed9812a14a9f212db8e46ab86ad39ce7b2 /libpam_misc/misc_conv.c | |
parent | 6180f388df5004d5435cd6912445130cf260f94e (diff) | |
download | pam-345044121bc4e8977a22d6235d31df4b2114a240.tar.gz pam-345044121bc4e8977a22d6235d31df4b2114a240.tar.bz2 pam-345044121bc4e8977a22d6235d31df4b2114a240.zip |
Relevant BUGIDs: 463984
Purpose of commit: bugfix
Commit summary:
---------------
The last fix to the conversation function was less than marginal: it
didn't actually work! This second commit adds the all important 'return
the user's input' bit!
Also added some more D() stuff to pam_misc to help locate the problem
and finally cleaned up the Makefile in the examples/ directory. I used
xsh to do the testing.
Diffstat (limited to 'libpam_misc/misc_conv.c')
-rw-r--r-- | libpam_misc/misc_conv.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/libpam_misc/misc_conv.c b/libpam_misc/misc_conv.c index fbde3735..c58a597a 100644 --- a/libpam_misc/misc_conv.c +++ b/libpam_misc/misc_conv.c @@ -137,6 +137,8 @@ static char *read_string(int echo, const char *prompt) D(("called with echo='%s', prompt='%s'.", echo ? "ON":"OFF" , prompt)); + input = line; + if (isatty(STDIN_FILENO)) { /* terminal state */ /* is a terminal so record settings and flush it */ @@ -191,27 +193,37 @@ static char *read_string(int echo, const char *prompt) if (expired) { delay = get_delay(); } else if (nc > 0) { /* we got some user input */ + D(("we got some user input")); if (nc > 0 && line[nc-1] == '\n') { /* <NUL> terminate */ line[--nc] = '\0'; } else { + if (echo) { + fprintf(stderr, "\n"); + } line[nc] = '\0'; } input = x_strdup(line); _pam_overwrite(line); goto cleanexit; /* return malloc()ed string */ + } else if (nc == 0) { /* Ctrl-D */ D(("user did not want to type anything")); input = x_strdup(""); - fprintf(stderr, "\n"); + if (echo) { + fprintf(stderr, "\n"); + } goto cleanexit; /* return malloc()ed "" */ } } } /* getting here implies that the timer expired */ + + D(("the timer appears to have expired")); + input = NULL; _pam_overwrite(line); @@ -222,7 +234,9 @@ static char *read_string(int echo, const char *prompt) (void) tcsetattr(STDIN_FILENO, TCSADRAIN, &term_before); } - return NULL; + D(("returning [%s]", input)); + + return input; } /* end of read_string functions */ @@ -325,8 +339,6 @@ int misc_conv(int num_msg, const struct pam_message **msgm, } } - /* New (0.59+) behavior is to always have a reply - this is - compatable with the X/Open (March 1997) spec. */ *response = reply; reply = NULL; @@ -334,6 +346,8 @@ int misc_conv(int num_msg, const struct pam_message **msgm, failed_conversation: + D(("the conversation failed")); + if (reply) { for (count=0; count<num_msg; ++count) { if (reply[count].resp == NULL) { |