From a80af27fc930936cbdd2646a64b66359d09a603b Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Fri, 9 Sep 2016 21:45:45 +0200 Subject: [PATCH] clients: don't show "(null)" prompt for secrets If the caller doesn't provide a message, simply don't show it. --- clients/cli/agent.c | 3 ++- clients/cli/common.c | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/clients/cli/agent.c b/clients/cli/agent.c index e876d26227..9211d9a0fb 100644 --- a/clients/cli/agent.c +++ b/clients/cli/agent.c @@ -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; diff --git a/clients/cli/common.c b/clients/cli/common.c index f1ec46a11e..62cd6c9c77 100644 --- a/clients/cli/common.c +++ b/clients/cli/common.c @@ -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);