All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/5] client: Consolidate cancelation replies
@ 2019-10-25 20:32 Tim Kourt
  2019-10-25 20:32 ` [PATCH 2/5] client: Modify error handler to return cancelation msg Tim Kourt
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Tim Kourt @ 2019-10-25 20:32 UTC (permalink / raw)
  To: iwd

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

---
 client/agent.c | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/client/agent.c b/client/agent.c
index 8af714a2..b80e5727 100644
--- a/client/agent.c
+++ b/client/agent.c
@@ -50,6 +50,15 @@ static struct pending_op {
 	struct l_queue *saved_input;
 } pending_op;
 
+static struct l_dbus_message *agent_reply_canceled(
+						struct l_dbus_message *message,
+						const char *text)
+{
+	return l_dbus_message_new_error(message,
+					IWD_AGENT_INTERFACE ".Error.Canceled",
+					"Error: %s", text);
+}
+
 static struct l_dbus_message *agent_error(const char *text)
 {
 	display_error(text);
@@ -342,9 +351,8 @@ static void process_input_username_password(const char *prompt)
 	if (l_queue_isempty(pending_op.saved_input)) {
 		/* received username */
 		if (!strlen(prompt)) {
-			reply = l_dbus_message_new_error(pending_message,
-					IWD_AGENT_INTERFACE ".Error.Canceled",
-					"Canceled by user");
+			reply = agent_reply_canceled(pending_message,
+							"Canceled by user");
 			goto send_reply;
 		}
 
@@ -372,9 +380,8 @@ static void process_input_passphrase(const char *prompt)
 	struct l_dbus_message *reply;
 
 	if (!strlen(prompt)) {
-		reply = l_dbus_message_new_error(pending_message,
-					IWD_AGENT_INTERFACE ".Error.Canceled",
-					"Canceled by user");
+		reply = agent_reply_canceled(pending_message,
+							"Canceled by user");
 		goto send_reply;
 	}
 
-- 
2.13.6

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

* [PATCH 2/5] client: Modify error handler to return cancelation msg
  2019-10-25 20:32 [PATCH 1/5] client: Consolidate cancelation replies Tim Kourt
@ 2019-10-25 20:32 ` Tim Kourt
  2019-10-25 20:32 ` [PATCH 3/5] client: Respond to invalid agent requests Tim Kourt
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Tim Kourt @ 2019-10-25 20:32 UTC (permalink / raw)
  To: iwd

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

This allows to send cancelation error back to iwd, instead of
returning NULL and waiting for iwd to timeout on agent request.
---
 client/agent.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/client/agent.c b/client/agent.c
index b80e5727..503418a0 100644
--- a/client/agent.c
+++ b/client/agent.c
@@ -59,7 +59,8 @@ static struct l_dbus_message *agent_reply_canceled(
 					"Error: %s", text);
 }
 
-static struct l_dbus_message *agent_error(const char *text)
+static struct l_dbus_message *agent_error(struct l_dbus_message *message,
+							const char *text)
 {
 	display_error(text);
 
@@ -69,7 +70,7 @@ static struct l_dbus_message *agent_error(const char *text)
 		l_main_quit();
 	}
 
-	return NULL;
+	return agent_reply_canceled(message, text);
 }
 
 static struct l_dbus_message *release_method_call(struct l_dbus *dbus,
@@ -114,7 +115,7 @@ static struct l_dbus_message *request_passphrase_method_call(
 		return reply;
 
 	if (command_option_get(COMMAND_OPTION_DONTASK, NULL))
-		return agent_error("No passphrase is provided as "
+		return agent_error(message, "No passphrase is provided as "
 					"'--"COMMAND_OPTION_PASSPHRASE"' "
 						"command-line option.\n");
 
@@ -152,7 +153,7 @@ static struct l_dbus_message *request_private_key_passphrase_method_call(
 		return reply;
 
 	if (command_option_get(COMMAND_OPTION_DONTASK, NULL))
-		return agent_error("No passphrase is provided as "
+		return agent_error(message, "No passphrase is provided as "
 					"'--"COMMAND_OPTION_PASSPHRASE"' "
 						"command-line option.\n");
 
@@ -211,7 +212,8 @@ static struct l_dbus_message *request_username_and_password_method_call(
 		return reply;
 
 	if (command_option_get(COMMAND_OPTION_DONTASK, NULL))
-		return agent_error("No username or password is provided as "
+		return agent_error(message, "No username or password is "
+					"provided as "
 					"'--"COMMAND_OPTION_USERNAME"' or "
 					"'--"COMMAND_OPTION_PASSWORD"' "
 						"command-line option.\n");
@@ -268,7 +270,7 @@ static struct l_dbus_message *request_user_password_method_call(
 		return reply;
 
 	if (command_option_get(COMMAND_OPTION_DONTASK, NULL))
-		return agent_error("No password is provided as "
+		return agent_error(message, "No password is provided as "
 					"'--"COMMAND_OPTION_PASSWORD"' "
 					"command-line option.\n");
 
-- 
2.13.6

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

* [PATCH 3/5] client: Respond to invalid agent requests
  2019-10-25 20:32 [PATCH 1/5] client: Consolidate cancelation replies Tim Kourt
  2019-10-25 20:32 ` [PATCH 2/5] client: Modify error handler to return cancelation msg Tim Kourt
@ 2019-10-25 20:32 ` Tim Kourt
  2019-10-25 20:32 ` [PATCH 4/5] client: Fail on requests with invalid arguments Tim Kourt
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Tim Kourt @ 2019-10-25 20:32 UTC (permalink / raw)
  To: iwd

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

This allows to send an error back to iwd, instead of returning NULL
and waiting for iwd to timeout on agent request.
---
 client/agent.c | 24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/client/agent.c b/client/agent.c
index 503418a0..40e123d8 100644
--- a/client/agent.c
+++ b/client/agent.c
@@ -59,6 +59,14 @@ static struct l_dbus_message *agent_reply_canceled(
 					"Error: %s", text);
 }
 
+static struct l_dbus_message *agent_reply_failed(struct l_dbus_message *message,
+							const char *text)
+{
+	return l_dbus_message_new_error(message,
+					IWD_AGENT_INTERFACE ".Error.Failed",
+					"Error: %s", text);
+}
+
 static struct l_dbus_message *agent_error(struct l_dbus_message *message,
 							const char *text)
 {
@@ -121,11 +129,11 @@ static struct l_dbus_message *request_passphrase_method_call(
 
 	l_dbus_message_get_arguments(message, "o", &path);
 	if (!path)
-		return NULL;
+		return agent_reply_failed(message, "Invalid argument");
 
 	proxy = proxy_interface_find(IWD_NETWORK_INTERFACE, path);
 	if (!proxy)
-		return NULL;
+		return agent_reply_failed(message, "Invalid network object");
 
 	display("Type the network passphrase for %s.\n",
 				proxy_interface_get_identity_str(proxy));
@@ -159,11 +167,11 @@ static struct l_dbus_message *request_private_key_passphrase_method_call(
 
 	l_dbus_message_get_arguments(message, "o", &path);
 	if (!path)
-		return NULL;
+		return agent_reply_failed(message, "Invalid argument");
 
 	proxy = proxy_interface_find(IWD_NETWORK_INTERFACE, path);
 	if (!proxy)
-		return NULL;
+		return agent_reply_failed(message, "Invalid network object");
 
 	display("Type the passphrase for the network encrypted private key for "
 			"%s.\n", proxy_interface_get_identity_str(proxy));
@@ -220,11 +228,11 @@ static struct l_dbus_message *request_username_and_password_method_call(
 
 	l_dbus_message_get_arguments(message, "o", &path);
 	if (!path)
-		return NULL;
+		return agent_reply_failed(message, "Invalid argument");
 
 	proxy = proxy_interface_find(IWD_NETWORK_INTERFACE, path);
 	if (!proxy)
-		return NULL;
+		return agent_reply_failed(message, "Invalid network object");
 
 	display("Type the network credentials for %s.\n",
 				proxy_interface_get_identity_str(proxy));
@@ -276,11 +284,11 @@ static struct l_dbus_message *request_user_password_method_call(
 
 	l_dbus_message_get_arguments(message, "os", &path, &username);
 	if (!path || !username)
-		return NULL;
+		return agent_reply_failed(message, "Invalid argument");
 
 	proxy = proxy_interface_find(IWD_NETWORK_INTERFACE, path);
 	if (!proxy)
-		return NULL;
+		return agent_reply_failed(message, "Invalid network object");
 
 	display("Type the network password for %s.\n",
 				proxy_interface_get_identity_str(proxy));
-- 
2.13.6

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

* [PATCH 4/5] client: Fail on requests with invalid arguments
  2019-10-25 20:32 [PATCH 1/5] client: Consolidate cancelation replies Tim Kourt
  2019-10-25 20:32 ` [PATCH 2/5] client: Modify error handler to return cancelation msg Tim Kourt
  2019-10-25 20:32 ` [PATCH 3/5] client: Respond to invalid agent requests Tim Kourt
@ 2019-10-25 20:32 ` Tim Kourt
  2019-10-25 20:32 ` [PATCH 5/5] doc: Update agent API with possible errors Tim Kourt
  2019-10-28 15:49 ` [PATCH 1/5] client: Consolidate cancelation replies Denis Kenzior
  4 siblings, 0 replies; 6+ messages in thread
From: Tim Kourt @ 2019-10-25 20:32 UTC (permalink / raw)
  To: iwd

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

---
 client/agent.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/client/agent.c b/client/agent.c
index 40e123d8..78499419 100644
--- a/client/agent.c
+++ b/client/agent.c
@@ -127,7 +127,9 @@ static struct l_dbus_message *request_passphrase_method_call(
 					"'--"COMMAND_OPTION_PASSPHRASE"' "
 						"command-line option.\n");
 
-	l_dbus_message_get_arguments(message, "o", &path);
+	if (!l_dbus_message_get_arguments(message, "o", &path))
+		return agent_reply_failed(message, "Invalid argument");
+
 	if (!path)
 		return agent_reply_failed(message, "Invalid argument");
 
@@ -165,7 +167,9 @@ static struct l_dbus_message *request_private_key_passphrase_method_call(
 					"'--"COMMAND_OPTION_PASSPHRASE"' "
 						"command-line option.\n");
 
-	l_dbus_message_get_arguments(message, "o", &path);
+	if (!l_dbus_message_get_arguments(message, "o", &path))
+		return agent_reply_failed(message, "Invalid argument");
+
 	if (!path)
 		return agent_reply_failed(message, "Invalid argument");
 
@@ -226,7 +230,9 @@ static struct l_dbus_message *request_username_and_password_method_call(
 					"'--"COMMAND_OPTION_PASSWORD"' "
 						"command-line option.\n");
 
-	l_dbus_message_get_arguments(message, "o", &path);
+	if (!l_dbus_message_get_arguments(message, "o", &path))
+		return agent_reply_failed(message, "Invalid argument");
+
 	if (!path)
 		return agent_reply_failed(message, "Invalid argument");
 
@@ -282,7 +288,9 @@ static struct l_dbus_message *request_user_password_method_call(
 					"'--"COMMAND_OPTION_PASSWORD"' "
 					"command-line option.\n");
 
-	l_dbus_message_get_arguments(message, "os", &path, &username);
+	if (!l_dbus_message_get_arguments(message, "os", &path, &username))
+		return agent_reply_failed(message, "Invalid arguments");
+
 	if (!path || !username)
 		return agent_reply_failed(message, "Invalid argument");
 
-- 
2.13.6

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

* [PATCH 5/5] doc: Update agent API with possible errors
  2019-10-25 20:32 [PATCH 1/5] client: Consolidate cancelation replies Tim Kourt
                   ` (2 preceding siblings ...)
  2019-10-25 20:32 ` [PATCH 4/5] client: Fail on requests with invalid arguments Tim Kourt
@ 2019-10-25 20:32 ` Tim Kourt
  2019-10-28 15:49 ` [PATCH 1/5] client: Consolidate cancelation replies Denis Kenzior
  4 siblings, 0 replies; 6+ messages in thread
From: Tim Kourt @ 2019-10-25 20:32 UTC (permalink / raw)
  To: iwd

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

---
 doc/agent-api.txt | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/doc/agent-api.txt b/doc/agent-api.txt
index ef80499e..5200dfb5 100644
--- a/doc/agent-api.txt
+++ b/doc/agent-api.txt
@@ -43,6 +43,7 @@ Methods		void Release()
 			a network and passphrase is required.
 
 			Possible Errors: net.connman.iwd.Agent.Error.Canceled
+					 net.connman.iwd.Agent.Error.Failed
 
 		string RequestPrivateKeyPassphrase(object network)
 
@@ -52,6 +53,7 @@ Methods		void Release()
 			obtain that private key's encryption passphrase.
 
 			Possible Errors: net.connman.iwd.Agent.Error.Canceled
+					 net.connman.iwd.Agent.Error.Failed
 
 		(string, string) RequestUserNameAndPassword(object network)
 
@@ -60,6 +62,7 @@ Methods		void Release()
 			user name and password.
 
 			Possible Errors: net.connman.iwd.Agent.Error.Canceled
+					 net.connman.iwd.Agent.Error.Failed
 
 		string RequestUserPassword(object network, string user)
 
@@ -69,6 +72,7 @@ Methods		void Release()
 			in the parameter.
 
 			Possible Errors: net.connman.iwd.Agent.Error.Canceled
+					 net.connman.iwd.Agent.Error.Failed
 
 		void Cancel(string reason)
 
-- 
2.13.6

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

* Re: [PATCH 1/5] client: Consolidate cancelation replies
  2019-10-25 20:32 [PATCH 1/5] client: Consolidate cancelation replies Tim Kourt
                   ` (3 preceding siblings ...)
  2019-10-25 20:32 ` [PATCH 5/5] doc: Update agent API with possible errors Tim Kourt
@ 2019-10-28 15:49 ` Denis Kenzior
  4 siblings, 0 replies; 6+ messages in thread
From: Denis Kenzior @ 2019-10-28 15:49 UTC (permalink / raw)
  To: iwd

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

Hi Tim,

On 10/25/19 3:32 PM, Tim Kourt wrote:
> ---
>   client/agent.c | 19 +++++++++++++------
>   1 file changed, 13 insertions(+), 6 deletions(-)
> 

Patches 1-4 applied, thanks

Regards,
-Denis

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

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

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-25 20:32 [PATCH 1/5] client: Consolidate cancelation replies Tim Kourt
2019-10-25 20:32 ` [PATCH 2/5] client: Modify error handler to return cancelation msg Tim Kourt
2019-10-25 20:32 ` [PATCH 3/5] client: Respond to invalid agent requests Tim Kourt
2019-10-25 20:32 ` [PATCH 4/5] client: Fail on requests with invalid arguments Tim Kourt
2019-10-25 20:32 ` [PATCH 5/5] doc: Update agent API with possible errors Tim Kourt
2019-10-28 15:49 ` [PATCH 1/5] client: Consolidate cancelation replies 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.