D-Bus: Hotspot 2.0 credentials with multiple domains

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>
This commit is contained in:
Damien Dejean 2022-07-28 08:19:18 +00:00 committed by Jouni Malinen
parent 2f739c71ce
commit f5ce680ee6
2 changed files with 37 additions and 1 deletions

View file

@ -6102,7 +6102,7 @@ def test_dbus_creds(dev, apdev):
(bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0]) (bus, wpas_obj, path, if_obj) = prepare_dbus(dev[0])
iface = dbus.Interface(if_obj, WPAS_DBUS_IFACE) 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', 'realm': 'server.w1.fi',
'home_ois': '50a9bf', 'home_ois': '50a9bf',
'required_home_ois': '23bf50', 'required_home_ois': '23bf50',
@ -6118,6 +6118,8 @@ def test_dbus_creds(dev, apdev):
if k == 'password': if k == 'password':
continue continue
prop = dev[0].get_cred(0, k) prop = dev[0].get_cred(0, k)
if isinstance(v, list):
v = '\n'.join(v)
if prop != v: if prop != v:
raise Exception('Credential add failed: %s does not match %s' % (prop, v)) raise Exception('Credential add failed: %s does not match %s' % (prop, v))

View file

@ -412,6 +412,40 @@ static dbus_bool_t set_cred_properties(struct wpa_supplicant *wpa_s,
entry.int32_value); entry.int32_value);
if (os_snprintf_error(size, ret)) if (os_snprintf_error(size, ret))
goto error; 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 { } else {
goto error; goto error;
} }