]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
dbus: Apply PMK properties immediately
authorBeniamino Galvani <bgalvani@redhat.com>
Mon, 3 Oct 2022 07:09:28 +0000 (09:09 +0200)
committerJouni Malinen <j@w1.fi>
Sat, 5 Nov 2022 15:49:41 +0000 (17:49 +0200)
Currently, PMK parameters in the WPA state machine are set from
configuration only when the interface is initialized. If those
parameters are changed later via D-Bus, the new values don't have any
effect.

Call wpa_sm_set_param() when PMK-related D-Bus properties are changed
to immediately apply the new value; the control interface also does
something similar.

Signed-off-by: Beniamino Galvani <bgalvani@redhat.com>
wpa_supplicant/dbus/dbus_new_handlers.c

index 26f7738d45c1b62b69c87ce27d94eac1dce1697f..7b9cf2884c06659aa1f1927826d7f64345054637 100644 (file)
@@ -4324,6 +4324,7 @@ dbus_bool_t wpas_dbus_setter_iface_global(
        const char *new_value = NULL;
        char buf[250];
        size_t combined_len;
+       int wpa_sm_param;
        int ret;
 
        if (!wpas_dbus_simple_property_setter(iter, error, DBUS_TYPE_STRING,
@@ -4342,6 +4343,35 @@ dbus_bool_t wpas_dbus_setter_iface_global(
        if (!new_value[0])
                new_value = "NULL";
 
+       wpa_sm_param = -1;
+       if (os_strcmp(property_desc->data, "dot11RSNAConfigPMKLifetime") == 0)
+               wpa_sm_param = RSNA_PMK_LIFETIME;
+       else if (os_strcmp(property_desc->data,
+                          "dot11RSNAConfigPMKReauthThreshold") == 0)
+               wpa_sm_param = RSNA_PMK_REAUTH_THRESHOLD;
+       else if (os_strcmp(property_desc->data, "dot11RSNAConfigSATimeout") == 0)
+               wpa_sm_param = RSNA_SA_TIMEOUT;
+
+       if (wpa_sm_param != -1) {
+               char *end;
+               int val;
+
+               val = strtol(new_value, &end, 0);
+               if (*end) {
+                       dbus_set_error(error, DBUS_ERROR_INVALID_ARGS,
+                                      "Invalid value for property %s",
+                                      property_desc->dbus_property);
+                       return FALSE;
+               }
+
+               if (wpa_sm_set_param(wpa_s->wpa, wpa_sm_param, val)) {
+                       dbus_set_error(error, DBUS_ERROR_INVALID_ARGS,
+                                      "Failed to apply interface property %s",
+                                      property_desc->dbus_property);
+                       return FALSE;
+               }
+       }
+
        ret = os_snprintf(buf, combined_len, "%s=%s", property_desc->data,
                          new_value);
        if (os_snprintf_error(combined_len, ret)) {