diff options
author | Thomas Haller <thaller@redhat.com> | 2019-01-30 12:34:55 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2019-02-14 08:00:29 +0100 |
commit | 55ce9d9de920cf7dd347df8a839829114596160d (patch) | |
tree | 1fa839a5832621c38c98524585ff5bf29cef1410 /clients | |
parent | ead7c00348989e639d8121de1cf8e549dc75df52 (diff) | |
download | NetworkManager-55ce9d9de920cf7dd347df8a839829114596160d.tar.gz |
clients/secret-agent: allow suppressing prompting the entry-id when requesting secrets
When asking for the preshared-key for WireGuard peers, the secret request
will be very verbose with redundant information. Allow suppressing the entry
id from the prompt.
Diffstat (limited to 'clients')
-rw-r--r-- | clients/cli/agent.c | 5 | ||||
-rw-r--r-- | clients/cli/common.c | 17 | ||||
-rw-r--r-- | clients/common/nm-secret-agent-simple.h | 3 |
3 files changed, 18 insertions, 7 deletions
diff --git a/clients/cli/agent.c b/clients/cli/agent.c index a18eecc52d..6c116153ac 100644 --- a/clients/cli/agent.c +++ b/clients/cli/agent.c @@ -104,7 +104,10 @@ get_secrets_from_user (const NmcConfig *nmc_config, rl_startup_hook = set_deftext; pre_input_deftext = g_strdup (secret->value); } - pwd = nmc_readline (nmc_config, "%s (%s): ", secret->pretty_name, secret->entry_id); + if (secret->no_prompt_entry_id) + pwd = nmc_readline (nmc_config, "%s: ", secret->pretty_name); + else + pwd = nmc_readline (nmc_config, "%s (%s): ", secret->pretty_name, secret->entry_id); /* No password provided, cancel the secrets. */ if (!pwd) diff --git a/clients/cli/common.c b/clients/cli/common.c index b3342c1935..50dd0eb5cb 100644 --- a/clients/cli/common.c +++ b/clients/cli/common.c @@ -685,6 +685,8 @@ get_secrets_from_user (const NmcConfig *nmc_config, pwd = g_strdup (pwd); } else { if (ask) { + gboolean echo_on; + if (secret->value) { if (!g_strcmp0 (secret->vpn_type, NM_DBUS_INTERFACE ".openconnect")) { /* Do not present and ask user for openconnect secrets, we already have them */ @@ -697,11 +699,16 @@ get_secrets_from_user (const NmcConfig *nmc_config, } if (msg) g_print ("%s\n", msg); - pwd = nmc_readline_echo (nmc_config, - secret->is_secret - ? nmc_config->show_secrets - : TRUE, - "%s (%s): ", secret->pretty_name, secret->entry_id); + + echo_on = secret->is_secret + ? nmc_config->show_secrets + : TRUE; + + if (secret->no_prompt_entry_id) + pwd = nmc_readline_echo (nmc_config, echo_on, "%s: ", secret->pretty_name); + else + pwd = nmc_readline_echo (nmc_config, echo_on, "%s (%s): ", secret->pretty_name, secret->entry_id); + if (!pwd) pwd = g_strdup (""); } else { diff --git a/clients/common/nm-secret-agent-simple.h b/clients/common/nm-secret-agent-simple.h index 1ee3ede09a..3e61dace4c 100644 --- a/clients/common/nm-secret-agent-simple.h +++ b/clients/common/nm-secret-agent-simple.h @@ -33,7 +33,8 @@ typedef struct { const char *entry_id; char *value; const char *vpn_type; - gboolean is_secret; + bool is_secret:1; + bool no_prompt_entry_id:1; } NMSecretAgentSimpleSecret; #define NM_SECRET_AGENT_ENTRY_ID_PREFX_VPN_SECRETS "vpn.secrets." |