clients: don't show "(null)" prompt for secrets

If the caller doesn't provide a message, simply don't show it.
This commit is contained in:
Beniamino Galvani 2016-09-09 21:45:45 +02:00
parent b28b2ba8a9
commit a80af27fc9
2 changed files with 6 additions and 3 deletions

View file

@ -96,7 +96,8 @@ get_secrets_from_user (const char *request_id,
char *pwd = NULL;
/* Ask user for the password */
g_print ("%s\n", msg);
if (msg)
g_print ("%s\n", msg);
if (secret->value) {
/* Prefill the password if we have it. */
rl_startup_hook = set_deftext;

View file

@ -1058,13 +1058,15 @@ get_secrets_from_user (const char *request_id,
nmc_rl_pre_input_deftext = g_strdup (secret->value);
}
}
g_print ("%s\n", msg);
if (msg)
g_print ("%s\n", msg);
pwd = nmc_readline_echo (secret->password ? echo_on : TRUE,
"%s (%s): ", secret->name, secret->prop_name);
if (!pwd)
pwd = g_strdup ("");
} else {
g_print ("%s\n", msg);
if (msg)
g_print ("%s\n", msg);
g_printerr (_("Warning: password for '%s' not given in 'passwd-file' "
"and nmcli cannot ask without '--ask' option.\n"),
secret->prop_name);