All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] client: Cancel agent prompt with CTRL+D
@ 2019-10-28 17:29 Tim Kourt
  2019-10-28 19:57 ` Denis Kenzior
  0 siblings, 1 reply; 2+ messages in thread
From: Tim Kourt @ 2019-10-28 17:29 UTC (permalink / raw)
  To: iwd

[-- Attachment #1: Type: text/plain, Size: 2609 bytes --]

Previously, CTRL+D used to cause termination of the client. Now, the
command will cancel the agent’s prompts in agent mod. In regular mode
the behavior is unchanged.
---
 client/agent.c   | 28 +++++++++++++++++++---------
 client/display.c |  8 ++++----
 2 files changed, 23 insertions(+), 13 deletions(-)

diff --git a/client/agent.c b/client/agent.c
index 78499419..16bc3c4f 100644
--- a/client/agent.c
+++ b/client/agent.c
@@ -366,14 +366,17 @@ static void process_input_username_password(const char *prompt)
 	struct l_dbus_message *reply;
 	char *username;
 
-	if (l_queue_isempty(pending_op.saved_input)) {
-		/* received username */
-		if (!strlen(prompt)) {
-			reply = agent_reply_canceled(pending_message,
+	if (!prompt || !strlen(prompt)) {
+		reply = agent_reply_canceled(pending_message,
 							"Canceled by user");
-			goto send_reply;
-		}
 
+		l_queue_clear(pending_op.saved_input, l_free);
+
+		goto send_reply;
+	}
+
+	if (l_queue_isempty(pending_op.saved_input)) {
+		/* received username */
 		l_queue_push_tail(pending_op.saved_input, l_strdup(prompt));
 
 		display_agent_prompt(PROMPT_PASSWORD, true);
@@ -397,7 +400,7 @@ static void process_input_passphrase(const char *prompt)
 {
 	struct l_dbus_message *reply;
 
-	if (!strlen(prompt)) {
+	if (!prompt || !strlen(prompt)) {
 		reply = agent_reply_canceled(pending_message,
 							"Canceled by user");
 		goto send_reply;
@@ -412,11 +415,18 @@ send_reply:
 
 static void process_input_password(const char *prompt)
 {
-	struct l_dbus_message *reply =
-			l_dbus_message_new_method_return(pending_message);
+	struct l_dbus_message *reply;
+
+	if (!prompt || !strlen(prompt)) {
+		reply = agent_reply_canceled(pending_message,
+							"Canceled by user");
+		goto send_reply;
+	}
 
+	reply = l_dbus_message_new_method_return(pending_message);
 	l_dbus_message_set_arguments(reply, "s", prompt);
 
+send_reply:
 	agent_send_reply(reply);
 }
 
diff --git a/client/display.c b/client/display.c
index c08183da..cd17ad84 100644
--- a/client/display.c
+++ b/client/display.c
@@ -465,6 +465,10 @@ static void readline_callback(char *prompt)
 
 	HIST_ENTRY *previous_prompt;
 
+	if (agent_prompt(masked_input.use_mask ?
+					masked_input.passphrase : prompt))
+		goto done;
+
 	if (!prompt) {
 		display_quit();
 
@@ -473,10 +477,6 @@ static void readline_callback(char *prompt)
 		return;
 	}
 
-	if (agent_prompt(masked_input.use_mask ?
-					masked_input.passphrase : prompt))
-		goto done;
-
 	if (!strlen(prompt))
 		goto done;
 
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] client: Cancel agent prompt with CTRL+D
  2019-10-28 17:29 [PATCH] client: Cancel agent prompt with CTRL+D Tim Kourt
@ 2019-10-28 19:57 ` Denis Kenzior
  0 siblings, 0 replies; 2+ messages in thread
From: Denis Kenzior @ 2019-10-28 19:57 UTC (permalink / raw)
  To: iwd

[-- Attachment #1: Type: text/plain, Size: 427 bytes --]

Hi Tim,

On 10/28/19 12:29 PM, Tim Kourt wrote:
> Previously, CTRL+D used to cause termination of the client. Now, the
> command will cancel the agent’s prompts in agent mod. In regular mode
> the behavior is unchanged.
> ---
>   client/agent.c   | 28 +++++++++++++++++++---------
>   client/display.c |  8 ++++----
>   2 files changed, 23 insertions(+), 13 deletions(-)
> 

Applied, thanks.

Regards,
-Denis

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-10-28 19:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-28 17:29 [PATCH] client: Cancel agent prompt with CTRL+D Tim Kourt
2019-10-28 19:57 ` Denis Kenzior

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.