From abeed797c052b832622dc092ebe2e03d784ed3cc Mon Sep 17 00:00:00 2001 From: Andrew Zaborowski Date: Fri, 10 Aug 2018 03:00:46 +0200 Subject: [PATCH] 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. --- src/network.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/network.c b/src/network.c index e5d1fb1e..7a0895da 100644 --- a/src/network.c +++ b/src/network.c @@ -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)