Added username in password prompt.

git-svn-id: https://proxytunnel.svn.sourceforge.net/svnroot/proxytunnel/trunk/proxytunnel@213 bc163920-b10d-0410-b2c5-a5491ca2ceef
This commit is contained in:
Dag Wieers 2008-01-27 16:18:18 +00:00
parent 168cb51ddb
commit 87c75b32ff
3 changed files with 11 additions and 4 deletions

View file

@ -333,7 +333,7 @@ int main( int argc, char *argv[] ) {
/* If the usename is given, but password is not, prompt for it */
if( args_info.user_given && !args_info.pass_given ) {
char *cp;
cp = getpass_x ("Enter local proxy password:");
cp = getpass_x ("Enter local proxy password for user %s: ", args_info.user_arg);
if (cp != NULL && strlen (cp) > 0) {
args_info.pass_arg = strdup (cp);
args_info.pass_given = 1;
@ -343,7 +343,7 @@ int main( int argc, char *argv[] ) {
if( args_info.remuser_given && !args_info.rempass_given ) {
char *cp;
cp = getpass_x ("Enter remote proxy password:");
cp = getpass_x ("Enter remote proxy password for user %s: ", args_info.remuser_arg);
if (cp != NULL && strlen (cp) > 0) {
args_info.rempass_arg = strdup (cp);
args_info.rempass_given = 1;

View file

@ -37,7 +37,7 @@ size_t strlcpy(char *dst, const char *src, size_t siz);
size_t strzcat(char *dst, char *format, ...);
int main( int argc, char *argv[] );
char * readpassphrase(const char *, char *, size_t, int);
char * getpass_x(const char *prompt);
char * getpass_x(const char *format, ...);
/* Globals */
int read_fd; /* The file descriptor to read from */

View file

@ -191,8 +191,15 @@ restart:
return(nr == -1 ? NULL : buf);
}
char * getpass_x(const char *prompt) {
char * getpass_x(const char *format, ...) {
static char buf[_PASSWORD_LEN + 1];
char *prompt = malloc(SIZE);
va_list ap;
va_start(ap, format);
vsnprintf(prompt, SIZE, format, ap);
va_end(ap);
return(readpassphrase(prompt, buf, sizeof(buf), RPP_ECHO_OFF));
}