settings: ensure the keyfile storage directory actually exists

When first trying to write out the connections we need to ensure that the
keyfile directory exists, as the /etc/ tree may be either stateless or
reset initially.

Creating the directory on demand ensures that we have a chance for our
writes to actually work.

[lkundrak@v3.sk: dropped a comment for what seems obvious, minor style
fixes]
This commit is contained in:
Ikey Doherty 2017-05-11 12:48:11 +01:00 committed by Lubomir Rintel
parent 4adda2b79a
commit 5c5a553ca6

View file

@ -213,6 +213,10 @@ _internal_write_connection (NMConnection *connection,
if (!data)
return FALSE;
if (!g_file_test (keyfile_dir, G_FILE_TEST_IS_DIR))
g_mkdir_with_parents (keyfile_dir, 0755);
/* If we have existing file path, use it. Else generate one from
* connection's ID.
*/