bd1e7a
From 32ed752130bcbccc008819a7f1ea27651c601ee2 Mon Sep 17 00:00:00 2001
bd1e7a
From: Matthias Clasen <mclasen@redhat.com>
bd1e7a
Date: Tue, 22 Jan 2019 13:26:31 -0500
bd1e7a
Subject: [PATCH 9/9] keyfile settings: Use tighter permissions
bd1e7a
bd1e7a
When creating directories, create them with 700 permissions,
bd1e7a
instead of 777.
bd1e7a
bd1e7a
Closes: #1658
bd1e7a
---
bd1e7a
 gio/gkeyfilesettingsbackend.c | 5 +++--
bd1e7a
 1 file changed, 3 insertions(+), 2 deletions(-)
bd1e7a
bd1e7a
diff --git a/gio/gkeyfilesettingsbackend.c b/gio/gkeyfilesettingsbackend.c
bd1e7a
index f5358818e..3d793f5a8 100644
bd1e7a
--- a/gio/gkeyfilesettingsbackend.c
bd1e7a
+++ b/gio/gkeyfilesettingsbackend.c
bd1e7a
@@ -113,7 +113,8 @@ g_keyfile_settings_backend_keyfile_write (GKeyfileSettingsBackend *kfsb)
bd1e7a
 
bd1e7a
   contents = g_key_file_to_data (kfsb->keyfile, &length, NULL);
bd1e7a
   g_file_replace_contents (kfsb->file, contents, length, NULL, FALSE,
bd1e7a
-                           G_FILE_CREATE_REPLACE_DESTINATION,
bd1e7a
+                           G_FILE_CREATE_REPLACE_DESTINATION |
bd1e7a
+                           G_FILE_CREATE_PRIVATE,
bd1e7a
                            NULL, NULL, NULL);
bd1e7a
 
bd1e7a
   compute_checksum (kfsb->digest, contents, length);
bd1e7a
@@ -708,7 +709,7 @@ g_keyfile_settings_backend_constructed (GObject *object)
bd1e7a
   kfsb->permission = g_simple_permission_new (TRUE);
bd1e7a
 
bd1e7a
   kfsb->dir = g_file_get_parent (kfsb->file);
bd1e7a
-  g_file_make_directory_with_parents (kfsb->dir, NULL, NULL);
bd1e7a
+  g_mkdir_with_parents (g_file_peek_path (kfsb->dir), 0700);
bd1e7a
 
bd1e7a
   kfsb->file_monitor = g_file_monitor (kfsb->file, G_FILE_MONITOR_NONE, NULL, NULL);
bd1e7a
   kfsb->dir_monitor = g_file_monitor (kfsb->dir, G_FILE_MONITOR_NONE, NULL, NULL);
bd1e7a
-- 
bd1e7a
2.28.0