From 2285ad24ab9fd995b845d5ac2b5ccab6f18439bf Mon Sep 17 00:00:00 2001 From: Andrew Zaborowski Date: Tue, 7 Jun 2016 05:29:51 +0200 Subject: [PATCH] network: Create a settings file on connection Make sure networks of all 4 security types have a settings file created or updated with a new modification time on a successful connect so that autoconnect and network sorting works for networks other than PSK too. By doing this on storage_network_touch failure we make sure we don't overwrite anything dropped into the settings directory while we were connecting. --- src/network.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/network.c b/src/network.c index ca68b92d..2d48bc7d 100644 --- a/src/network.c +++ b/src/network.c @@ -154,7 +154,19 @@ bool network_connected(struct network *network) goto fail; err = storage_network_touch(strtype, network->ssid); - if (err < 0) + if (err == -ENOENT) { + /* + * Write an empty settings file to keep track of the + * last connected time. This will also make iwd autoconnect + * to this network in the future. + * Current policy is that network becomes a Known Network + * only on a successful connect. + */ + if (!network_settings_load(network)) + goto fail; + + storage_network_sync(strtype, network->ssid, network->settings); + } else goto fail; err = storage_network_get_mtime(strtype, network->ssid,