aboutsummaryrefslogtreecommitdiffstats
path: root/wpa_supplicant
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2011-02-02 15:00:12 (GMT)
committerJouni Malinen <j@w1.fi>2011-02-02 15:00:12 (GMT)
commitd1c8ac88b9dea5925fc66a9ab8b54a4b77e353fa (patch)
treea5aec74b656b4d0527498c47b7770cc4acac2dbd /wpa_supplicant
parent0661eed204553d869ddbd3bed050385797d6fa2a (diff)
downloadhostap-d1c8ac88b9dea5925fc66a9ab8b54a4b77e353fa.zip
hostap-d1c8ac88b9dea5925fc66a9ab8b54a4b77e353fa.tar.gz
hostap-d1c8ac88b9dea5925fc66a9ab8b54a4b77e353fa.tar.bz2
DBus: Publish provisioned keys in network properties
When the network was provisioned, we need to get the keys to be able to reconnect without new provisioning. To be able to publish those keys but not normally configured ones, add a new attribute to struct wpa_ssid indicating whether or not keys may be exported. Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'wpa_supplicant')
-rw-r--r--wpa_supplicant/config.c3
-rw-r--r--wpa_supplicant/config_ssid.h8
-rw-r--r--wpa_supplicant/dbus/dbus_new_handlers.c2
-rw-r--r--wpa_supplicant/p2p_supplicant.c2
-rw-r--r--wpa_supplicant/wps_supplicant.c2
5 files changed, 16 insertions, 1 deletions
diff --git a/wpa_supplicant/config.c b/wpa_supplicant/config.c
index 1ea37d4..d732f54 100644
--- a/wpa_supplicant/config.c
+++ b/wpa_supplicant/config.c
@@ -1892,6 +1892,7 @@ int wpa_config_set(struct wpa_ssid *ssid, const char *var, const char *value,
* wpa_config_get_all - Get all options from network configuration
* @ssid: Pointer to network configuration data
* @get_keys: Determines if keys/passwords will be included in returned list
+ * (if they may be exported)
* Returns: %NULL terminated list of all set keys and their values in the form
* of [key1, val1, key2, val2, ... , NULL]
*
@@ -1907,6 +1908,8 @@ char ** wpa_config_get_all(struct wpa_ssid *ssid, int get_keys)
char **props;
int fields_num;
+ get_keys = get_keys && ssid->export_keys;
+
props = os_zalloc(sizeof(char *) * ((2 * NUM_SSID_FIELDS) + 1));
if (!props)
return NULL;
diff --git a/wpa_supplicant/config_ssid.h b/wpa_supplicant/config_ssid.h
index 38da3fc..8419f43 100644
--- a/wpa_supplicant/config_ssid.h
+++ b/wpa_supplicant/config_ssid.h
@@ -400,6 +400,14 @@ struct wpa_ssid {
* temporary - Whether this network is temporary and not to be saved
*/
int temporary;
+
+ /**
+ * export_keys - Whether keys may be exported
+ *
+ * This attribute will be set when keys are determined through
+ * WPS or similar so that they may be exported.
+ */
+ int export_keys;
};
#endif /* CONFIG_SSID_H */
diff --git a/wpa_supplicant/dbus/dbus_new_handlers.c b/wpa_supplicant/dbus/dbus_new_handlers.c
index 08cdd72..5402bff 100644
--- a/wpa_supplicant/dbus/dbus_new_handlers.c
+++ b/wpa_supplicant/dbus/dbus_new_handlers.c
@@ -2882,7 +2882,7 @@ DBusMessage * wpas_dbus_getter_network_properties(
DBusMessage *reply = NULL;
DBusMessageIter iter, variant_iter, dict_iter;
char **iterator;
- char **props = wpa_config_get_all(net->ssid, 0);
+ char **props = wpa_config_get_all(net->ssid, 1);
if (!props)
return dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY,
NULL);
diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c
index 13f9b4a..81d37e5 100644
--- a/wpa_supplicant/p2p_supplicant.c
+++ b/wpa_supplicant/p2p_supplicant.c
@@ -403,6 +403,7 @@ static void wpas_p2p_store_persistent_group(struct wpa_supplicant *wpa_s,
s->key_mgmt = WPA_KEY_MGMT_PSK;
s->proto = WPA_PROTO_RSN;
s->pairwise_cipher = WPA_CIPHER_CCMP;
+ s->export_keys = 1;
if (ssid->passphrase) {
os_free(s->passphrase);
s->passphrase = os_strdup(ssid->passphrase);
@@ -3241,6 +3242,7 @@ static int wpas_start_p2p_client(struct wpa_supplicant *wpa_s,
os_memcpy(ssid->ssid, params->ssid, params->ssid_len);
ssid->ssid_len = params->ssid_len;
ssid->p2p_group = 1;
+ ssid->export_keys = 1;
if (params->psk_set) {
os_memcpy(ssid->psk, params->psk, 32);
ssid->psk_set = 1;
diff --git a/wpa_supplicant/wps_supplicant.c b/wpa_supplicant/wps_supplicant.c
index d93db46..8100f1c 100644
--- a/wpa_supplicant/wps_supplicant.c
+++ b/wpa_supplicant/wps_supplicant.c
@@ -372,6 +372,7 @@ static int wpa_supplicant_wps_cred(void *ctx,
return -1;
}
ssid->psk_set = 1;
+ ssid->export_keys = 1;
} else if (cred->key_len >= 8 && cred->key_len < 2 * PMK_LEN) {
os_free(ssid->passphrase);
ssid->passphrase = os_malloc(cred->key_len + 1);
@@ -380,6 +381,7 @@ static int wpa_supplicant_wps_cred(void *ctx,
os_memcpy(ssid->passphrase, cred->key, cred->key_len);
ssid->passphrase[cred->key_len] = '\0';
wpa_config_update_psk(ssid);
+ ssid->export_keys = 1;
} else {
wpa_printf(MSG_ERROR, "WPS: Invalid Network Key "
"length %lu",