mirror of
https://github.com/moparisthebest/curl
synced 2024-12-22 16:18:48 -05:00
tool_paramhlp: Added URL index to password prompt for multiple operations
This commit is contained in:
parent
013e9a11ff
commit
f3bae6ed73
@ -1838,11 +1838,12 @@ int operate(struct Configurable *config, int argc, argv_item_t argv[])
|
|||||||
}
|
}
|
||||||
/* Perform the main operations */
|
/* Perform the main operations */
|
||||||
else {
|
else {
|
||||||
|
size_t count = 0;
|
||||||
struct Configurable *operation = config;
|
struct Configurable *operation = config;
|
||||||
|
|
||||||
/* Get the required aguments for each operation */
|
/* Get the required aguments for each operation */
|
||||||
while(!result && operation) {
|
while(!result && operation) {
|
||||||
result = get_args(operation);
|
result = get_args(operation, count++);
|
||||||
|
|
||||||
operation = operation->next;
|
operation = operation->next;
|
||||||
}
|
}
|
||||||
|
@ -366,7 +366,9 @@ ParameterError str2offset(curl_off_t *val, const char *str)
|
|||||||
return PARAM_BAD_NUMERIC;
|
return PARAM_BAD_NUMERIC;
|
||||||
}
|
}
|
||||||
|
|
||||||
static CURLcode checkpasswd(const char *kind, /* for what purpose */
|
static CURLcode checkpasswd(const char *kind, /* for what purpose */
|
||||||
|
const size_t index, /* operation index */
|
||||||
|
const bool last, /* TRUE if last operation */
|
||||||
char **userpwd) /* pointer to allocated string */
|
char **userpwd) /* pointer to allocated string */
|
||||||
{
|
{
|
||||||
char *psep;
|
char *psep;
|
||||||
@ -393,9 +395,15 @@ static CURLcode checkpasswd(const char *kind, /* for what purpose */
|
|||||||
*osep = '\0';
|
*osep = '\0';
|
||||||
|
|
||||||
/* build a nice-looking prompt */
|
/* build a nice-looking prompt */
|
||||||
curlx_msnprintf(prompt, sizeof(prompt),
|
if(!index && last)
|
||||||
"Enter %s password for user '%s':",
|
curlx_msnprintf(prompt, sizeof(prompt),
|
||||||
kind, *userpwd);
|
"Enter %s password for user '%s':",
|
||||||
|
kind, *userpwd);
|
||||||
|
else
|
||||||
|
curlx_msnprintf(prompt, sizeof(prompt),
|
||||||
|
"Enter %s password for user '%s' on URL #%"
|
||||||
|
CURL_FORMAT_CURL_OFF_TU ":",
|
||||||
|
kind, *userpwd, index + 1);
|
||||||
|
|
||||||
/* get password */
|
/* get password */
|
||||||
getpass_r(prompt, passwd, sizeof(passwd));
|
getpass_r(prompt, passwd, sizeof(passwd));
|
||||||
@ -473,20 +481,21 @@ static char *my_useragent(void)
|
|||||||
return strdup(CURL_NAME "/" CURL_VERSION);
|
return strdup(CURL_NAME "/" CURL_VERSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
CURLcode get_args(struct Configurable *config)
|
CURLcode get_args(struct Configurable *config, const size_t index)
|
||||||
{
|
{
|
||||||
CURLcode result = CURLE_OK;
|
CURLcode result = CURLE_OK;
|
||||||
|
bool last = (config->next ? FALSE : TRUE);
|
||||||
|
|
||||||
/* Check we have a password for the given host user */
|
/* Check we have a password for the given host user */
|
||||||
if(config->userpwd && !config->xoauth2_bearer) {
|
if(config->userpwd && !config->xoauth2_bearer) {
|
||||||
result = checkpasswd("host", &config->userpwd);
|
result = checkpasswd("host", index, last, &config->userpwd);
|
||||||
if(result)
|
if(result)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check we have a password for the given proxy user */
|
/* Check we have a password for the given proxy user */
|
||||||
if(config->proxyuserpwd) {
|
if(config->proxyuserpwd) {
|
||||||
result = checkpasswd("proxy", &config->proxyuserpwd);
|
result = checkpasswd("proxy", index, last, &config->proxyuserpwd);
|
||||||
if(result)
|
if(result)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ long proto2num(struct Configurable *config, long *val, const char *str);
|
|||||||
|
|
||||||
ParameterError str2offset(curl_off_t *val, const char *str);
|
ParameterError str2offset(curl_off_t *val, const char *str);
|
||||||
|
|
||||||
CURLcode get_args(struct Configurable *config);
|
CURLcode get_args(struct Configurable *config, const size_t index);
|
||||||
|
|
||||||
ParameterError add2list(struct curl_slist **list, const char *ptr);
|
ParameterError add2list(struct curl_slist **list, const char *ptr);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user