From 5c5a553ca62c7b701d965773e7a63d5fddabc3e0 Mon Sep 17 00:00:00 2001 From: Ikey Doherty Date: Thu, 11 May 2017 12:48:11 +0100 Subject: [PATCH] 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] --- src/settings/plugins/keyfile/nms-keyfile-writer.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/settings/plugins/keyfile/nms-keyfile-writer.c b/src/settings/plugins/keyfile/nms-keyfile-writer.c index 92ed2849b5..1a68e5dc06 100644 --- a/src/settings/plugins/keyfile/nms-keyfile-writer.c +++ b/src/settings/plugins/keyfile/nms-keyfile-writer.c @@ -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. */