From 88c227d90a6b7b388c5c85d72802a0ca8f05ed5c Mon Sep 17 00:00:00 2001 From: Michael Biebl Date: Thu, 13 Jan 2022 22:30:39 +0100 Subject: New upstream version 1.34.0 --- src/nmcli/agent.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'src/nmcli/agent.c') diff --git a/src/nmcli/agent.c b/src/nmcli/agent.c index a0b23dd1..bdbd6e45 100644 --- a/src/nmcli/agent.c +++ b/src/nmcli/agent.c @@ -7,9 +7,12 @@ #include #include +#if HAVE_EDITLINE_READLINE +#include +#else #include #include - +#endif #include "common.h" #include "utils.h" #include "libnmc-base/nm-secret-agent-simple.h" @@ -51,16 +54,14 @@ usage_agent_all(void) "Runs nmcli as both NetworkManager secret and a polkit agent.\n\n")); } -/* for pre-filling a string to readline prompt */ static char *pre_input_deftext; -static int -set_deftext(void) + +static int set_deftext(_NMC_RL_STARTUPHOOK_ARGS) { if (pre_input_deftext && rl_startup_hook) { rl_insert_text(pre_input_deftext); - g_free(pre_input_deftext); - pre_input_deftext = NULL; - rl_startup_hook = NULL; + nm_clear_g_free(&pre_input_deftext); + rl_startup_hook = NULL; } return 0; } @@ -83,8 +84,8 @@ get_secrets_from_user(const NmcConfig *nmc_config, g_print("%s\n", msg); if (secret->value) { /* Prefill the password if we have it. */ - rl_startup_hook = set_deftext; - pre_input_deftext = g_strdup(secret->value); + rl_startup_hook = set_deftext; + nm_strdup_reset(&pre_input_deftext, secret->value); } if (secret->no_prompt_entry_id) pwd = nmc_readline(nmc_config, "%s: ", secret->pretty_name); -- cgit 1.3.0-6-gf8a5