[PATCH] D-Bus: hs20 credentials with multiple domains

Damien Dejean damiendejean at chromium.org
Thu Jul 28 01:19:18 PDT 2022


Adds the support of multiple domains for interworking credentials in
D-Bus API.

Signed-off-by: Damien Dejean <damiendejean at chromium.org>
---
 tests/hwsim/test_dbus.py                |  2 +-
 wpa_supplicant/dbus/dbus_new_handlers.c | 32 +++++++++++++++++++++++++
 2 files changed, 33 insertions(+), 1 deletion(-)

diff --git a/tests/hwsim/test_dbus.py b/tests/hwsim/test_dbus.py
index fe59e1856..2c0f2e99e 100644
--- a/tests/hwsim/test_dbus.py
+++ b/tests/hwsim/test_dbus.py
@@ -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',
             'roaming_consortium': '50a9bf',
             'required_roaming_consortium': '23bf50',
diff --git a/wpa_supplicant/dbus/dbus_new_handlers.c b/wpa_supplicant/dbus/dbus_new_handlers.c
index 0b1002bf1..9ba7fde17 100644
--- a/wpa_supplicant/dbus/dbus_new_handlers.c
+++ b/wpa_supplicant/dbus/dbus_new_handlers.c
@@ -412,6 +412,38 @@ 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) {
+			if (entry.array_len <= 0)
+				goto error;
+
+			for (int 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;
 		}
-- 
2.37.1.359.gd136c6c3e2-goog




More information about the Hostap mailing list