3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-26 02:19:26 +01:00

client: Respond to invalid agent requests

This allows to send an error back to iwd, instead of returning NULL
and waiting for iwd to timeout on agent request.
This commit is contained in:
Tim Kourt 2019-10-25 13:32:06 -07:00 committed by Denis Kenzior
parent cfdb33f710
commit b808816efe

View File

@ -59,6 +59,14 @@ static struct l_dbus_message *agent_reply_canceled(
"Error: %s", text); "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, static struct l_dbus_message *agent_error(struct l_dbus_message *message,
const char *text) const char *text)
{ {
@ -121,11 +129,11 @@ static struct l_dbus_message *request_passphrase_method_call(
l_dbus_message_get_arguments(message, "o", &path); l_dbus_message_get_arguments(message, "o", &path);
if (!path) if (!path)
return NULL; return agent_reply_failed(message, "Invalid argument");
proxy = proxy_interface_find(IWD_NETWORK_INTERFACE, path); proxy = proxy_interface_find(IWD_NETWORK_INTERFACE, path);
if (!proxy) if (!proxy)
return NULL; return agent_reply_failed(message, "Invalid network object");
display("Type the network passphrase for %s.\n", display("Type the network passphrase for %s.\n",
proxy_interface_get_identity_str(proxy)); 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); l_dbus_message_get_arguments(message, "o", &path);
if (!path) if (!path)
return NULL; return agent_reply_failed(message, "Invalid argument");
proxy = proxy_interface_find(IWD_NETWORK_INTERFACE, path); proxy = proxy_interface_find(IWD_NETWORK_INTERFACE, path);
if (!proxy) if (!proxy)
return NULL; return agent_reply_failed(message, "Invalid network object");
display("Type the passphrase for the network encrypted private key for " display("Type the passphrase for the network encrypted private key for "
"%s.\n", proxy_interface_get_identity_str(proxy)); "%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); l_dbus_message_get_arguments(message, "o", &path);
if (!path) if (!path)
return NULL; return agent_reply_failed(message, "Invalid argument");
proxy = proxy_interface_find(IWD_NETWORK_INTERFACE, path); proxy = proxy_interface_find(IWD_NETWORK_INTERFACE, path);
if (!proxy) if (!proxy)
return NULL; return agent_reply_failed(message, "Invalid network object");
display("Type the network credentials for %s.\n", display("Type the network credentials for %s.\n",
proxy_interface_get_identity_str(proxy)); 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); l_dbus_message_get_arguments(message, "os", &path, &username);
if (!path || !username) if (!path || !username)
return NULL; return agent_reply_failed(message, "Invalid argument");
proxy = proxy_interface_find(IWD_NETWORK_INTERFACE, path); proxy = proxy_interface_find(IWD_NETWORK_INTERFACE, path);
if (!proxy) if (!proxy)
return NULL; return agent_reply_failed(message, "Invalid network object");
display("Type the network password for %s.\n", display("Type the network password for %s.\n",
proxy_interface_get_identity_str(proxy)); proxy_interface_get_identity_str(proxy));