This allows to send error back to iwd, instead of returning NULL
and waiting for iwd to timeout on agent request.
---
client/agent.c | 22 ++++++++++++++++------
1 file changed, 16 insertions(+), 6 deletions(-)
diff --git a/client/agent.c b/client/agent.c
index 5ed6538f..c8da72dc 100644
--- a/client/agent.c
+++ b/client/agent.c
@@ -50,7 +50,16 @@ static struct pending_op {
struct l_queue *saved_input;
} pending_op;
-static struct l_dbus_message *agent_error(const char *text)
+static struct l_dbus_message *agent_error_reply(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)
{
display_error(text);
@@ -60,7 +69,7 @@ static struct l_dbus_message *agent_error(const char *text)
l_main_quit();
}
- return NULL;
+ return agent_error_reply(message, text);
}
static struct l_dbus_message *release_method_call(struct l_dbus *dbus,
@@ -108,7 +117,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");
@@ -149,7 +158,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 +220,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");
@@ -271,7 +281,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
Show replies by date
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 | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/client/agent.c b/client/agent.c
index c8da72dc..4d23e05e 100644
--- a/client/agent.c
+++ b/client/agent.c
@@ -123,11 +123,11 @@ static struct l_dbus_message *request_passphrase_method_call(
l_dbus_message_get_arguments(message, "o", &path);
if (!path)
- return NULL;
+ return agent_error_reply(message, "Invalid argument");
proxy = proxy_interface_find(IWD_NETWORK_INTERFACE, path);
if (!proxy)
- return NULL;
+ return agent_error_reply(message, "Invalid network object");
display("Type the network passphrase for %s.\n",
proxy_interface_get_identity_str(proxy));
@@ -164,11 +164,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_error_reply(message, "Invalid argument");
proxy = proxy_interface_find(IWD_NETWORK_INTERFACE, path);
if (!proxy)
- return NULL;
+ return agent_error_reply(message, "Invalid network object");
display("Type the passphrase for the network encrypted private key for "
"%s.\n", proxy_interface_get_identity_str(proxy));
@@ -228,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_error_reply(message, "Invalid argument");
proxy = proxy_interface_find(IWD_NETWORK_INTERFACE, path);
if (!proxy)
- return NULL;
+ return agent_error_reply(message, "Invalid network object");
display("Type the network credentials for %s.\n",
proxy_interface_get_identity_str(proxy));
@@ -287,11 +287,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_error_reply(message, "Invalid argument");
proxy = proxy_interface_find(IWD_NETWORK_INTERFACE, path);
if (!proxy)
- return NULL;
+ return agent_error_reply(message, "Invalid network object");
display("Type the network password for %s.\n",
proxy_interface_get_identity_str(proxy));
--
2.13.6
This assumes that iwd will never send the errors as agent requests,
therefore, eliminate the unnecessary checks.
---
client/agent.c | 12 ------------
1 file changed, 12 deletions(-)
diff --git a/client/agent.c b/client/agent.c
index 4d23e05e..52cb85cf 100644
--- a/client/agent.c
+++ b/client/agent.c
@@ -109,9 +109,6 @@ static struct l_dbus_message *request_passphrase_method_call(
struct l_dbus_message *reply;
const char *path;
- if (dbus_message_has_error(message))
- return NULL;
-
reply = request_passphrase_command_option(message);
if (reply)
return reply;
@@ -150,9 +147,6 @@ static struct l_dbus_message
*request_private_key_passphrase_method_call(
struct l_dbus_message *reply;
const char *path;
- if (dbus_message_has_error(message))
- return NULL;
-
reply = request_passphrase_command_option(message);
if (reply)
return reply;
@@ -212,9 +206,6 @@ static struct l_dbus_message
*request_username_and_password_method_call(
struct l_dbus_message *reply;
const char *path;
- if (dbus_message_has_error(message))
- return NULL;
-
reply = request_username_and_password_command_option(message);
if (reply)
return reply;
@@ -273,9 +264,6 @@ static struct l_dbus_message *request_user_password_method_call(
const char *username;
char *username_prompt;
- if (dbus_message_has_error(message))
- return NULL;
-
reply = request_user_password_command_option(message);
if (reply)
return reply;
--
2.13.6
Hi Tim,
On 10/24/19 2:53 PM, Tim Kourt wrote:
This assumes that iwd will never send the errors as agent requests,
therefore, eliminate the unnecessary checks.
---
client/agent.c | 12 ------------
1 file changed, 12 deletions(-)
Applied, thanks.
Regards,
-Denis
---
client/agent.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/client/agent.c b/client/agent.c
index 52cb85cf..0bda42ea 100644
--- a/client/agent.c
+++ b/client/agent.c
@@ -118,7 +118,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_error_reply(message, "Invalid argument");
+
if (!path)
return agent_error_reply(message, "Invalid argument");
@@ -156,7 +158,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_error_reply(message, "Invalid argument");
+
if (!path)
return agent_error_reply(message, "Invalid argument");
@@ -217,7 +221,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_error_reply(message, "Invalid argument");
+
if (!path)
return agent_error_reply(message, "Invalid argument");
@@ -273,7 +279,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_error_reply(message, "Invalid arguments");
+
if (!path || !username)
return agent_error_reply(message, "Invalid argument");
--
2.13.6