diff options
author | Todd C. Miller <Todd.Miller@courtesan.com> | 1998-11-03 20:03:31 +0000 |
---|---|---|
committer | Todd C. Miller <Todd.Miller@courtesan.com> | 1998-11-03 20:03:31 +0000 |
commit | bc78bda887fcb4ff72aa9fe004d31721d71889f3 (patch) | |
tree | 2d9f981b24ca9f2c456f40c9d64b89f732c088c2 /tgetpass.c | |
parent | 2d07ef78081ba744899dfefaebce8af123950b6d (diff) | |
download | sudo-bc78bda887fcb4ff72aa9fe004d31721d71889f3.tar.gz |
the prompt is expanded before tgetpass is called
Diffstat (limited to 'tgetpass.c')
-rw-r--r-- | tgetpass.c | 31 |
1 files changed, 5 insertions, 26 deletions
diff --git a/tgetpass.c b/tgetpass.c index d417b8ca1..a3aae51d2 100644 --- a/tgetpass.c +++ b/tgetpass.c @@ -95,11 +95,9 @@ static char rcsid[] = "$Id$"; * and input will time out based on the value of timeout. */ -char * tgetpass(prompt, timeout, user, host) +char * tgetpass(prompt, timeout) const char *prompt; int timeout; - char *user; - char *host; { #ifdef HAVE_TERMIOS_H struct termios term; @@ -121,7 +119,6 @@ char * tgetpass(prompt, timeout, user, host) static char buf[_PASSWD_LEN + 1]; fd_set *readfds; struct timeval tv; - char *p; /* * mask out SIGINT and SIGTSTP, should probably just catch and deal. @@ -144,30 +141,12 @@ char * tgetpass(prompt, timeout, user, host) output = stderr; } else { output = input; + setbuf(output, NULL); } - /* - * print the prompt - */ - if (prompt) { - p = (char *) prompt; - do { - /* expand %u -> username, %h -> host */ - switch (*p) { - case '%': if (user && *(p+1) == 'u') { - (void) fputs(user, output); - p++; - break; - } else if (host && *(p+1) == 'h') { - (void) fputs(host, output); - p++; - break; - } - - default: (void) fputc(*p, output); - } - } while (*(++p)); - } + /* print the prompt */ + if (prompt) + fputs(prompt, output); /* rewind if necesary */ if (input == output) { |