From 7c3e1d926a9056227d65945eb65b4348dc21248b Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Fri, 15 Dec 2017 17:05:24 +0100 Subject: clients/cli: don't store a password in history History is probably even not useful at all outside the interactive edit mode, but that is another story. This just avoids awkward surprises, such as: https://bugzilla.gnome.org/show_bug.cgi?id=791200 --- clients/cli/common.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/clients/cli/common.c b/clients/cli/common.c index f785e2c568..4c15463d34 100644 --- a/clients/cli/common.c +++ b/clients/cli/common.c @@ -892,6 +892,8 @@ nmc_readline_echo (gboolean echo_on, const char *prompt_fmt, ...) va_list args; char *prompt, *str; struct termios termios_orig, termios_new; + HISTORY_STATE *saved_history; + HISTORY_STATE passwd_history = { 0, }; va_start (args, prompt_fmt); prompt = g_strdup_vprintf (prompt_fmt, args); @@ -899,6 +901,8 @@ nmc_readline_echo (gboolean echo_on, const char *prompt_fmt, ...) /* Disable echoing characters */ if (!echo_on) { + saved_history = history_get_history_state (); + history_set_history_state (&passwd_history); tcgetattr (STDIN_FILENO, &termios_orig); termios_new = termios_orig; termios_new.c_lflag &= ~(ECHO); @@ -914,6 +918,7 @@ nmc_readline_echo (gboolean echo_on, const char *prompt_fmt, ...) tcsetattr (STDIN_FILENO, TCSADRAIN, &termios_orig); /* New line - setting ECHONL | ICANON did not help */ fprintf (stdout, "\n"); + history_set_history_state (saved_history); } return str; -- cgit v1.2.1