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.
This commit is contained in:
Thomas Haller 2019-01-30 12:34:55 +01:00
parent ead7c00348
commit 55ce9d9de9
3 changed files with 18 additions and 7 deletions

View file

@ -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)

View file

@ -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 {

View file

@ -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."