diff options
author | Daniel Stenberg <daniel@haxx.se> | 2003-10-17 07:04:56 +0000 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2003-10-17 07:04:56 +0000 |
commit | 8823679e70b14332baff04d95ffd57fe54e5181d (patch) | |
tree | 80a0a3459ad567f853952adf652b1fc003a002fb /src | |
parent | 722ece40550f2b6c505b39726f9dc8856ecd924b (diff) |
made the password prompt nicer
Diffstat (limited to 'src')
-rw-r--r-- | src/main.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/main.c b/src/main.c index 4165d2a3b..54b973775 100644 --- a/src/main.c +++ b/src/main.c @@ -1051,24 +1051,34 @@ static void cleanarg(char *str) #endif } -static void checkpasswd(const char *prompt, char **userpwd) +static void checkpasswd(const char *kind, /* for what purpose */ + char **userpwd) /* pointer to allocated string */ { char *ptr = strchr(*userpwd, ':'); if(!ptr) { /* no password present, prompt for one */ char passwd[256]=""; + char prompt[256]; int passwdlen; int userlen = strlen(*userpwd); char *ptr; + /* build a nice-looking prompt */ + curl_msnprintf(prompt, sizeof(prompt), + "Enter %s password for user '%s':", + kind, *userpwd); + + /* get password */ getpass_r(prompt, passwd, sizeof(passwd)); passwdlen = strlen(passwd); + /* extend the allocated memory are to fit the password too */ ptr = realloc(*userpwd, passwdlen + 1 + /* an extra for the colon */ userlen + 1); /* an extra for the zero */ if(ptr) { + /* append the password separated with a colon */ ptr[userlen]=':'; memcpy(&ptr[userlen+1], passwd, passwdlen+1); *userpwd = ptr; @@ -1834,13 +1844,13 @@ static ParameterError getparameter(char *flag, /* f or -long-flag */ /* user:password */ GetStr(&config->userpwd, nextarg); cleanarg(nextarg); - checkpasswd("Enter host password:", &config->userpwd); + checkpasswd("host", &config->userpwd); break; case 'U': /* Proxy user:password */ GetStr(&config->proxyuserpwd, nextarg); cleanarg(nextarg); - checkpasswd("Enter proxy password:", &config->proxyuserpwd); + checkpasswd("proxy", &config->proxyuserpwd); break; case 'v': config->conf ^= CONF_VERBOSE; /* talk a lot */ |