client: double password prompt
cover client: double password prompt
I am sending this as an RFC as readline magic is not something I am at all familiar with. The patch seems to fix the issue, but its not exactly clear to me why. I would like to get eyes on this to ensure I'm not breaking something unrelated.
The documentation for rl_redisplay() says:
"Change what's displayed on the screen to reflect the current contents of rl_line_buffer."
My guess is that rl_line_buffer already contains the "Password:" prompt, and inside display_agent_prompt we call rl_redisplay, then set then rl_set_prompt which causes the duplicate. Removing rl_redisplay completely causes problems with single prompt scenarios like PSK networks so the only way to avoid the call in this multi prompt situation is to add a flag and let the caller decide.
James Prestwood (1):
client: fix double password prompt
client/agent.c | 10 +++++----- client/display.c | 6 ++++-- client/display.h | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-)
Signature · 1 line
2.26.2
RFC 1/1 client: fix double password prompt
For username/password prompts the password portion was appearing on screen twice:
Username: myuser(a)example.com
Password: Password:
This appears to be caused by the call to rl_redisplay() in cases where there was a previous prompt ("Username" in this case). This patch adds a flag to disply_agent_prompt which avoids this call if that flag is set.
--- client/agent.c | 10 +++++----- client/display.c | 6 ++++-- client/display.h | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-)
client/agent.c +5 -5
@@ -139,7 +139,7 @@ static struct l_dbus_message *request_passphrase_method_call(display ("Type the network passphrase for %s.\n" ,proxy_interface_get_identity_str (proxy)); -display_agent_prompt (PROMPT_PASSPHRASE , true); +display_agent_prompt (PROMPT_PASSPHRASE , true, true); pending_op.type =AGENT_OP_TYPE_PASSPHRASE ; pending_op.last_label =PROMPT_PASSPHRASE ;
@@ -179,7 +179,7 @@ static struct l_dbus_message *request_private_key_passphrase_method_call(display ("Type the passphrase for the network encrypted private key for " "%s.\n" ,proxy_interface_get_identity_str (proxy)); -display_agent_prompt (PROMPT_PASSPHRASE , true); +display_agent_prompt (PROMPT_PASSPHRASE , true, true); pending_op.type =AGENT_OP_TYPE_PASSPHRASE ; pending_op.last_label =PROMPT_PASSPHRASE ;
@@ -242,7 +242,7 @@ static struct l_dbus_message *request_username_and_password_method_call(display ("Type the network credentials for %s.\n" ,proxy_interface_get_identity_str (proxy)); -display_agent_prompt (PROMPT_USERNAME , false); +display_agent_prompt (PROMPT_USERNAME , false, true); pending_op.type =AGENT_OP_TYPE_UNAME_PASSWORD ; pending_op.last_label =PROMPT_USERNAME ;
@@ -306,7 +306,7 @@ static struct l_dbus_message *request_user_password_method_call(display ("%s" , username_prompt);l_free (username_prompt); -display_agent_prompt (PROMPT_PASSWORD , true); +display_agent_prompt (PROMPT_PASSWORD , true, true); pending_op.type =AGENT_OP_TYPE_PASSWORD ; pending_op.last_label =PROMPT_PASSWORD ;
@@ -379,7 +379,7 @@ static void process_input_username_password(const char *prompt)/* received username */ l_queue_push_tail (pending_op.saved_input,l_strdup (prompt)); -display_agent_prompt (PROMPT_PASSWORD , true); +display_agent_prompt (PROMPT_PASSWORD , true, false); pending_op.last_label =PROMPT_PASSWORD ;return ;
client/display.c +4 -2
@@ -590,7 +590,7 @@ void display_disable_cmd_prompt(void)rl_redisplay (); } -void display_agent_prompt (const char *label,bool mask_input) +void display_agent_prompt (const char *label,bool mask_input,bool redisplay) {char *prompt;
@@ -613,7 +613,9 @@ void display_agent_prompt(const char *label, bool mask_input) agent_saved_input->line =rl_copy_text (0 , rl_end);rl_set_prompt ("" );rl_replace_line ("" ,0 ); -rl_redisplay (); + +if (redisplay) +rl_redisplay (); rl_erase_empty_line =0 ;rl_set_prompt (prompt);
client/display.h +1 -1
@@ -51,7 +51,7 @@ void display_refresh_set_cmd(const char *family, const char *entity,void display_enable_cmd_prompt (void );void display_disable_cmd_prompt (void ); -void display_agent_prompt (const char *label,bool mask_input); +void display_agent_prompt (const char *label,bool mask_input,bool redisplay);void display_agent_prompt_release (const char *label);bool display_agent_is_active (void );
Signature · 1 line
2.26.2