network: Reload settings in network_sync_psk

Reload the network settings from disk before calling
storage_network_sync in network_sync_psk to avoid potentially
overwriting changes made to the storage by user since the connection
attempt started.  This won't account for all situations but it
covers some of them and doesn't cost us much.
This commit is contained in:
Andrew Zaborowski 2018-08-10 03:00:46 +02:00 committed by Denis Kenzior
parent 3065e0768c
commit abeed797c0
1 changed files with 7 additions and 2 deletions

View File

@ -427,17 +427,22 @@ static int network_load_psk(struct network *network)
void network_sync_psk(struct network *network)
{
char *hex;
struct l_settings *fs_settings;
if (!network->update_psk)
return;
network->update_psk = false;
fs_settings = storage_network_open(SECURITY_PSK, network->info->ssid);
hex = l_util_hexstring(network->psk, 32);
l_settings_set_value(network->settings, "Security",
"PreSharedKey", hex);
l_settings_set_value(fs_settings, "Security", "PreSharedKey", hex);
l_free(hex);
storage_network_sync(SECURITY_PSK, network->info->ssid,
network->settings);
storage_network_sync(SECURITY_PSK, network->info->ssid, fs_settings);
l_settings_free(fs_settings);
}
int network_autoconnect(struct network *network, struct scan_bss *bss)