mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2025-01-02 17:42:34 +01:00
wsc: Properly write provisioning files with a passphrase
Credentials obtained can now be either in passphrase or PSK form. Prior to commit7a9891dbef
, passphrase credentials were always converted to PSK form by invoking crypto_psk_from_passphrase. This was changed in order to support WPA3 networks. Unfortunately the provisioning logic was never properly updated. Fix that, and also try to not overwrite any existing settings in case WSC is providing credentials for networks that are already known. Fixes:7a9891dbef
("wsc: store plain text passphrase if available")
This commit is contained in:
parent
3f1e4cce65
commit
10e5bee5ef
31
src/wsc.c
31
src/wsc.c
@ -28,6 +28,7 @@
|
||||
#include <stdio.h>
|
||||
#include <ell/ell.h>
|
||||
|
||||
#include "ell/useful.h"
|
||||
#include "src/missing.h"
|
||||
#include "src/module.h"
|
||||
#include "src/dbus.h"
|
||||
@ -40,7 +41,6 @@
|
||||
#include "src/util.h"
|
||||
#include "src/handshake.h"
|
||||
#include "src/eap-wsc.h"
|
||||
#include "src/crypto.h"
|
||||
#include "src/common.h"
|
||||
#include "src/storage.h"
|
||||
#include "src/iwd.h"
|
||||
@ -525,21 +525,40 @@ static void wsc_store_credentials(struct wsc_credentials_info *creds,
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
/* We don't store any non-open/psk credentials */
|
||||
for (i = 0; i < n_creds; i++) {
|
||||
enum security security = creds[i].security;
|
||||
const char *ssid = creds[i].ssid;
|
||||
struct l_settings *settings = l_settings_new();
|
||||
_auto_(l_settings_free) struct l_settings *settings =
|
||||
l_settings_new();
|
||||
_auto_(l_free) char *path =
|
||||
storage_get_network_file_path(security, ssid);
|
||||
|
||||
l_debug("Storing credential for '%s(%s)'", ssid,
|
||||
security_to_str(security));
|
||||
if (l_settings_load_from_file(settings, path)) {
|
||||
/*
|
||||
* Nothing to do,
|
||||
* so don't overwrite any existing settings
|
||||
*/
|
||||
if (security == SECURITY_NONE)
|
||||
continue;
|
||||
|
||||
if (security == SECURITY_PSK)
|
||||
/* Remove any existing Security keys */
|
||||
l_settings_remove_group(settings, "Security");
|
||||
}
|
||||
|
||||
if (security == SECURITY_PSK) {
|
||||
if (creds[i].has_passphrase)
|
||||
l_settings_set_string(settings, "Security",
|
||||
"Passphrase", creds[i].passphrase);
|
||||
else
|
||||
l_settings_set_bytes(settings, "Security",
|
||||
"PreSharedKey", creds[i].psk,
|
||||
sizeof(creds[i].psk));
|
||||
}
|
||||
|
||||
l_debug("Storing credential for '%s(%s)'", ssid,
|
||||
security_to_str(security));
|
||||
storage_network_sync(security, ssid, settings);
|
||||
l_settings_free(settings);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user