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 | |
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.
-rw-r--r-- | CHANGELOG | 6 | ||||
-rw-r--r-- | examples/Makefile | 3 | ||||
-rw-r--r-- | libpam_misc/misc_conv.c | 22 |
3 files changed, 22 insertions, 9 deletions
@@ -49,13 +49,13 @@ bug report - outstanding bugs are listed here: 0.76: please submit patches for this section with actual code/doc patches! +* some BSD updates and fixes from Mark Murray - including a slightly + more robust conversation function and some minimization of gcc + warnings. (Bugs 449203,463984 - agmorgan) * verified that the setcred stack didn't suffer from the bug I was nervous about, add a new module pam_debug to help me test this. fixed a libpam/pam_dispatch.c instrumentation line that I tripped over when testing. (Bug 424315 - agmorgan) -* some BSD updates and fixes from Mark Murray - including a slightly - more robust conversation function and some minimization of gcc - warnings. (Bug 449203 - agmorgan) * pam_unix/support.c: sample use of reentrant NSS function. Not yet active, because modules do not include _pam_aconf_h! (Bug 440107 - vorlon) * doc/Makefile changes - use $(mandir) [courtesy Harald Welte] (Bug diff --git a/examples/Makefile b/examples/Makefile index e9432ba7..58600f49 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -16,8 +16,7 @@ endif CFLAGS += -I../libpam_misc/include -I../libpamc/include -LOADLIBES = -L../libpam -L../libpamc -L../libpam_misc \ - -lpam$(LIBSUFFIX) -lpam_misc$(LIBSUFFIX) +LOADLIBES = -L../libpam -L../libpamc -L../libpam_misc -lpam -lpam_misc ifeq ($(STATIC_LIBPAM),yes) ifneq ($(DYNAMIC),) 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) { |