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.
This commit is contained in:
Andrew Zaborowski 2016-06-07 05:29:51 +02:00 committed by Denis Kenzior
parent 33d2ae60e9
commit 2285ad24ab
1 changed files with 13 additions and 1 deletions

View File

@ -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,