]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
D-Bus: Hotspot 2.0 credentials with multiple domains
authorDamien Dejean <damiendejean@chromium.org>
Thu, 28 Jul 2022 08:19:18 +0000 (08:19 +0000)
committerJouni Malinen <j@w1.fi>
Sun, 27 Nov 2022 12:18:53 +0000 (14:18 +0200)
Add the support of multiple domains for interworking credentials in
D-Bus API AddCred() using an array of strings.

Signed-off-by: Damien Dejean <damiendejean@chromium.org>
tests/hwsim/test_dbus.py
wpa_supplicant/dbus/dbus_new_handlers.c

index adff78fafd119ccd06b103fb5fd2c398ed49ee9d..a61211fe15817e69aa3b7d7bf7d7c332ef4926a9 100644 (file)
@@ -6102,7 +6102,7 @@ def test_dbus_creds(dev, apdev):
     (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0])
     iface = dbus.Interface(if_obj, WPAS_DBUS_IFACE)
 
-    args = {'domain': 'server.w1.fi',
+    args = {'domain': ['server.w1.fi','server2.w1.fi'],
             'realm': 'server.w1.fi',
             'home_ois': '50a9bf',
             'required_home_ois': '23bf50',
@@ -6118,6 +6118,8 @@ def test_dbus_creds(dev, apdev):
         if k == 'password':
             continue
         prop = dev[0].get_cred(0, k)
+        if isinstance(v, list):
+            v = '\n'.join(v)
         if prop != v:
             raise Exception('Credential add failed: %s does not match %s' % (prop, v))
 
index e63e2209eda635a02287a53e2a98e72c9d20f9c8..a8146dd08d00b7ee1ccf791d4fd9a9daf7deabfd 100644 (file)
@@ -412,6 +412,40 @@ static dbus_bool_t set_cred_properties(struct wpa_supplicant *wpa_s,
                                          entry.int32_value);
                        if (os_snprintf_error(size, ret))
                                goto error;
+               } else if (entry.type == DBUS_TYPE_ARRAY &&
+                          entry.array_type == DBUS_TYPE_STRING) {
+                       dbus_uint32_t i;
+
+                       if (entry.array_len <= 0)
+                               goto error;
+
+                       for (i = 0; i < entry.array_len; i++) {
+                               if (should_quote_opt(entry.key)) {
+                                       size = os_strlen(entry.strarray_value[i]);
+
+                                       size += 3;
+                                       value = os_zalloc(size);
+                                       if (!value)
+                                               goto error;
+
+                                       ret = os_snprintf(value, size, "\"%s\"",
+                                                         entry.strarray_value[i]);
+                                       if (os_snprintf_error(size, ret))
+                                               goto error;
+                               } else {
+                                       value = os_strdup(entry.strarray_value[i]);
+                                       if (!value)
+                                               goto error;
+                               }
+
+                               ret = wpa_config_set_cred(cred, entry.key, value, 0);
+                               if (ret < 0)
+                                       goto error;
+                               os_free(value);
+                               value = NULL;
+                       }
+                       wpa_dbus_dict_entry_clear(&entry);
+                       continue;
                } else {
                        goto error;
                }