From 7cff3136f5c79589a79bb4e4976a64c6f78b498b Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Mon, 25 Feb 2019 08:35:12 +0100 Subject: [PATCH 1/2] supplicant: clarify ready_count usage (cherry picked from commit cab17ff8e0f4935cd3a4b8564edd1ed765987d9f) --- src/supplicant/nm-supplicant-interface.c | 28 +++++++++++++----------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/supplicant/nm-supplicant-interface.c b/src/supplicant/nm-supplicant-interface.c index 82354df01b..16c247ccab 100644 --- a/src/supplicant/nm-supplicant-interface.c +++ b/src/supplicant/nm-supplicant-interface.c @@ -1638,6 +1638,21 @@ on_iface_proxy_acquired (GDBusProxy *proxy, GAsyncResult *result, gpointer user_ NULL, NULL); + /* Check whether NetworkReply and AP mode are supported. + * ready_count was initialized to 1 in interface_add_done(). + */ + g_dbus_proxy_call (priv->iface_proxy, + "NetworkReply", + g_variant_new ("(oss)", + "/fff", + "foobar", + "foobar"), + G_DBUS_CALL_FLAGS_NONE, + -1, + priv->init_cancellable, + (GAsyncReadyCallback) iface_check_netreply_cb, + self); + /* Initialize global PMF setting to 'optional' */ priv->ready_count++; g_dbus_proxy_call (priv->iface_proxy, @@ -1652,19 +1667,6 @@ on_iface_proxy_acquired (GDBusProxy *proxy, GAsyncResult *result, gpointer user_ (GAsyncReadyCallback) iface_set_pmf_cb, self); - /* Check whether NetworkReply and AP mode are supported */ - g_dbus_proxy_call (priv->iface_proxy, - "NetworkReply", - g_variant_new ("(oss)", - "/fff", - "foobar", - "foobar"), - G_DBUS_CALL_FLAGS_NONE, - -1, - priv->init_cancellable, - (GAsyncReadyCallback) iface_check_netreply_cb, - self); - if (priv->ap_support == NM_SUPPLICANT_FEATURE_UNKNOWN) { /* If the global supplicant capabilities property is not present, we can * fall back to checking whether the ProbeRequest method is supported. If From b837561bb6fc09d4134ac8c5c6dc5ac1885ebf62 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Mon, 25 Feb 2019 08:38:22 +0100 Subject: [PATCH 2/2] supplicant: fix setting pmf when the supplicant doesn't advertise support wpa_supplicant only advertises pmf support since commit [1], which is after 2.6. When using a version without that commit (for example, plain 2.6), we would unconditionally set the global Pmf property to 1 (optional) and then skip setting the per-network property. The result was that pmf was enabled without the possibility to disable it by user. The correct behavior is instead to disable pmf on such versions. [1] https://w1.fi/cgit/hostap/commit/?id=3cdb4ac074f76accf24a51d143db545afad2c90b https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/129 (cherry picked from commit 560a35dd433cd6bf2268aaf757fda798f35712fe) --- src/supplicant/nm-supplicant-interface.c | 31 ++++++++++++------------ 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/supplicant/nm-supplicant-interface.c b/src/supplicant/nm-supplicant-interface.c index 16c247ccab..f46689eb02 100644 --- a/src/supplicant/nm-supplicant-interface.c +++ b/src/supplicant/nm-supplicant-interface.c @@ -728,9 +728,8 @@ iface_set_pmf_cb (GDBusProxy *proxy, GAsyncResult *result, gpointer user_data) self = NM_SUPPLICANT_INTERFACE (user_data); - /* This can fail if the supplicant doesn't support PMF */ if (error) - _LOGD ("failed to set Pmf=1: %s", error->message); + _LOGW ("failed to set Pmf=1: %s", error->message); iface_check_ready (self); } @@ -1653,19 +1652,21 @@ on_iface_proxy_acquired (GDBusProxy *proxy, GAsyncResult *result, gpointer user_ (GAsyncReadyCallback) iface_check_netreply_cb, self); - /* Initialize global PMF setting to 'optional' */ - priv->ready_count++; - g_dbus_proxy_call (priv->iface_proxy, - DBUS_INTERFACE_PROPERTIES ".Set", - g_variant_new ("(ssv)", - WPAS_DBUS_IFACE_INTERFACE, - "Pmf", - g_variant_new_string ("1")), - G_DBUS_CALL_FLAGS_NONE, - -1, - priv->init_cancellable, - (GAsyncReadyCallback) iface_set_pmf_cb, - self); + if (priv->pmf_support == NM_SUPPLICANT_FEATURE_YES) { + /* Initialize global PMF setting to 'optional' */ + priv->ready_count++; + g_dbus_proxy_call (priv->iface_proxy, + DBUS_INTERFACE_PROPERTIES ".Set", + g_variant_new ("(ssv)", + WPAS_DBUS_IFACE_INTERFACE, + "Pmf", + g_variant_new_string ("1")), + G_DBUS_CALL_FLAGS_NONE, + -1, + priv->init_cancellable, + (GAsyncReadyCallback) iface_set_pmf_cb, + self); + } if (priv->ap_support == NM_SUPPLICANT_FEATURE_UNKNOWN) { /* If the global supplicant capabilities property is not present, we can