diff options
author | Andrew Zaborowski <andrew.zaborowski@intel.com> | 2018-06-15 06:36:35 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2018-06-22 16:46:05 +0200 |
commit | 1e5e143679ad19bc36ab641fc6d5c7d00288e165 (patch) | |
tree | dda9f291da504279b2b1297dd499040360124f73 /src/devices/wifi/nm-iwd-manager.c | |
parent | 5c747f729c186d3aeaa06ca473884b807b7a481d (diff) |
iwd: handle new secret request types from IWD agent
The IWD DBus interface currently
(https://git.kernel.org/pub/scm/network/wireless/iwd.git/tree/doc/agent-api.txt?id=38952813dddd776f66d2ed5e88eca9a892964c06)
knows about 3 secret types related to 802.1x authentication in addition
to the PSK secret request. Add support for the new methods and the new
secret types in NM's implementation of the IWD secret agent. Note that
the secret types are mapped to NMSetting8021x property keys and they are
then sent to the NM Secret Agent in the hints parameter to GetSecrets,
this will need support in the NM clients as the exact usage of the
hints parameter is specified a little ambiguously, but this seems to be
one of the permitted usages.
Rework the IWD agent interface info initialization to use NM convenience
macros.
(cherry picked from commit 74d9e04a66dce87cddee6476cdbd244e83ae6379)
Diffstat (limited to 'src/devices/wifi/nm-iwd-manager.c')
-rw-r--r-- | src/devices/wifi/nm-iwd-manager.c | 118 |
1 files changed, 62 insertions, 56 deletions
diff --git a/src/devices/wifi/nm-iwd-manager.c b/src/devices/wifi/nm-iwd-manager.c index 39db3a04c..daa796cbb 100644 --- a/src/devices/wifi/nm-iwd-manager.c +++ b/src/devices/wifi/nm-iwd-manager.c @@ -84,12 +84,12 @@ G_DEFINE_TYPE (NMIwdManager, nm_iwd_manager, G_TYPE_OBJECT) /*****************************************************************************/ static void -psk_agent_dbus_method_cb (GDBusConnection *connection, - const gchar *sender, const gchar *object_path, - const gchar *interface_name, const gchar *method_name, - GVariant *parameters, - GDBusMethodInvocation *invocation, - gpointer user_data) +agent_dbus_method_cb (GDBusConnection *connection, + const gchar *sender, const gchar *object_path, + const gchar *interface_name, const gchar *method_name, + GVariant *parameters, + GDBusMethodInvocation *invocation, + gpointer user_data) { NMIwdManager *self = user_data; NMIwdManagerPrivate *priv = NM_IWD_MANAGER_GET_PRIVATE (self); @@ -104,7 +104,10 @@ psk_agent_dbus_method_cb (GDBusConnection *connection, if (!nm_streq0 (g_dbus_object_manager_client_get_name_owner (omc), sender)) goto return_error; - g_variant_get (parameters, "(&o)", &network_path); + if (!strcmp (method_name, "RequestUserPassword")) + g_variant_get (parameters, "(&os)", &network_path, NULL); + else + g_variant_get (parameters, "(&o)", &network_path); network = g_dbus_object_manager_get_interface (priv->object_manager, network_path, @@ -145,7 +148,7 @@ psk_agent_dbus_method_cb (GDBusConnection *connection, goto return_error; } - if (nm_device_iwd_agent_psk_query (NM_DEVICE_IWD (device), invocation)) + if (nm_device_iwd_agent_query (NM_DEVICE_IWD (device), invocation)) return; _LOGE ("Device %s did not handle the IWD Agent request", ifname); @@ -154,56 +157,59 @@ return_error: /* IWD doesn't look at the specific error */ g_dbus_method_invocation_return_error_literal (invocation, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INVALID_CONNECTION, - "No PSK available for this connection"); + "Secrets not available for this connection"); } +static const GDBusInterfaceInfo iwd_agent_iface_info = NM_DEFINE_GDBUS_INTERFACE_INFO_INIT ( + "net.connman.iwd.Agent", + .methods = NM_DEFINE_GDBUS_METHOD_INFOS ( + NM_DEFINE_GDBUS_METHOD_INFO ( + "RequestPassphrase", + .in_args = NM_DEFINE_GDBUS_ARG_INFOS ( + NM_DEFINE_GDBUS_ARG_INFO ("network", "o"), + ), + .out_args = NM_DEFINE_GDBUS_ARG_INFOS ( + NM_DEFINE_GDBUS_ARG_INFO ("passphrase", "s"), + ), + ), + NM_DEFINE_GDBUS_METHOD_INFO ( + "RequestPrivateKeyPassphrase", + .in_args = NM_DEFINE_GDBUS_ARG_INFOS ( + NM_DEFINE_GDBUS_ARG_INFO ("network", "o"), + ), + .out_args = NM_DEFINE_GDBUS_ARG_INFOS ( + NM_DEFINE_GDBUS_ARG_INFO ("passphrase", "s"), + ), + ), + NM_DEFINE_GDBUS_METHOD_INFO ( + "RequestUserNameAndPassword", + .in_args = NM_DEFINE_GDBUS_ARG_INFOS ( + NM_DEFINE_GDBUS_ARG_INFO ("network", "o"), + ), + .out_args = NM_DEFINE_GDBUS_ARG_INFOS ( + NM_DEFINE_GDBUS_ARG_INFO ("user", "s"), + NM_DEFINE_GDBUS_ARG_INFO ("password", "s"), + ), + ), + NM_DEFINE_GDBUS_METHOD_INFO ( + "RequestUserPassword", + .in_args = NM_DEFINE_GDBUS_ARG_INFOS ( + NM_DEFINE_GDBUS_ARG_INFO ("network", "o"), + NM_DEFINE_GDBUS_ARG_INFO ("user", "s"), + ), + .out_args = NM_DEFINE_GDBUS_ARG_INFOS ( + NM_DEFINE_GDBUS_ARG_INFO ("password", "s"), + ), + ), + ), +); + static guint -psk_agent_export (GDBusConnection *connection, gpointer user_data, +iwd_agent_export (GDBusConnection *connection, gpointer user_data, gchar **agent_path, GError **error) { - static const GDBusArgInfo request_passphrase_arg_network = { - -1, - (gchar *) "network", - (gchar *) "o", - NULL, - }; - static const GDBusArgInfo *const request_passphrase_in_args[] = { - &request_passphrase_arg_network, - NULL, - }; - static const GDBusArgInfo request_passphrase_arg_passphrase = { - -1, - (gchar *) "passphrase", - (gchar *) "s", - NULL, - }; - static const GDBusArgInfo *const request_passphrase_out_args[] = { - &request_passphrase_arg_passphrase, - NULL, - }; - static const GDBusMethodInfo request_passphrase_info = { - -1, - (gchar *) "RequestPassphrase", - (GDBusArgInfo **) &request_passphrase_in_args, - (GDBusArgInfo **) &request_passphrase_out_args, - NULL, - }; - static const GDBusMethodInfo *const method_info[] = { - &request_passphrase_info, - NULL, - }; - static GDBusInterfaceInfo interface_info = { - -1, - (gchar *) "net.connman.iwd.Agent", - (GDBusMethodInfo **) &method_info, - NULL, - NULL, - NULL, - }; - static GDBusInterfaceVTable vtable = { - psk_agent_dbus_method_cb, - NULL, - NULL, + static const GDBusInterfaceVTable vtable = { + .method_call = agent_dbus_method_cb, }; gchar path[50]; @@ -221,8 +227,8 @@ psk_agent_export (GDBusConnection *connection, gpointer user_data, nm_sprintf_buf (path, "/agent/%u", rnd); id = g_dbus_connection_register_object (connection, path, - &interface_info, &vtable, - user_data, NULL, error); + NM_UNCONST_PTR (GDBusInterfaceInfo, &iwd_agent_iface_info), + &vtable, user_data, NULL, error); if (id) *agent_path = g_strdup (path); @@ -549,7 +555,7 @@ got_object_manager (GObject *object, GAsyncResult *result, gpointer user_data) connection = g_dbus_object_manager_client_get_connection (G_DBUS_OBJECT_MANAGER_CLIENT (object_manager)); - priv->agent_id = psk_agent_export (connection, self, + priv->agent_id = iwd_agent_export (connection, self, &priv->agent_path, &error); if (!priv->agent_id) { _LOGE ("failed to export the IWD Agent: PSK/8021x WiFi networks will not work: %s", |