[gnome-control-center] Use a consistent set of permissions when creating directories



commit f06a349a2af856e4980c3b59e1f437bc91443c26
Author: Debarshi Ray <debarshir gnome org>
Date:   Fri Oct 4 12:10:14 2013 +0200

    Use a consistent set of permissions when creating directories
    
    https://bugzilla.gnome.org/show_bug.cgi?id=709417

 configure.ac                            |    2 ++
 panels/background/bg-pictures-source.c  |    6 ++++--
 panels/background/cc-background-panel.c |    6 +++---
 panels/sound/sound-theme-file-utils.c   |    2 +-
 4 files changed, 10 insertions(+), 6 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 1c57c99..60b9b38 100644
--- a/configure.ac
+++ b/configure.ac
@@ -27,6 +27,8 @@ GETTEXT_PACKAGE=gnome-control-center-2.0
 AC_SUBST(GETTEXT_PACKAGE)
 AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE", [Gettext package])
 
+AC_DEFINE(USER_DIR_MODE, 0700, [Permissions for creating the user's config, cache and data directories])
+
 GNOME_DEBUG_CHECK
 GNOME_COMPILE_WARNINGS([maximum])
 
diff --git a/panels/background/bg-pictures-source.c b/panels/background/bg-pictures-source.c
index 3554266..0fb6e16 100644
--- a/panels/background/bg-pictures-source.c
+++ b/panels/background/bg-pictures-source.c
@@ -20,6 +20,8 @@
  *
  */
 
+#include <config.h>
+
 #include "bg-pictures-source.h"
 
 #include "cc-background-item.h"
@@ -610,7 +612,7 @@ bg_pictures_source_init (BgPicturesSource *self)
                                             NULL);
 
   pictures_path = g_get_user_special_dir (G_USER_DIRECTORY_PICTURES);
-  g_mkdir_with_parents (pictures_path, 0700);
+  g_mkdir_with_parents (pictures_path, USER_DIR_MODE);
 
   dir = g_file_new_for_path (pictures_path);
   g_file_enumerate_children_async (dir,
@@ -633,7 +635,7 @@ bg_pictures_source_init (BgPicturesSource *self)
   g_object_unref (dir);
 
   cache_path = bg_pictures_source_get_cache_path ();
-  g_mkdir_with_parents (cache_path, 0700);
+  g_mkdir_with_parents (cache_path, USER_DIR_MODE);
 
   dir = g_file_new_for_path (cache_path);
   g_file_enumerate_children_async (dir,
diff --git a/panels/background/cc-background-panel.c b/panels/background/cc-background-panel.c
index e194c8b..80d7817 100644
--- a/panels/background/cc-background-panel.c
+++ b/panels/background/cc-background-panel.c
@@ -399,7 +399,7 @@ get_screenshot_async (CcBackgroundPanel *panel)
            data->capture_rect.width, data->capture_rect.height, data->capture_rect.x, data->capture_rect.y);
 
   path = g_build_filename (g_get_user_cache_dir (), "gnome-control-center", NULL);
-  g_mkdir_with_parents (path, 0700);
+  g_mkdir_with_parents (path, USER_DIR_MODE);
 
   tmpname = g_strdup_printf ("scr-%d.png", g_random_int ());
   g_free (panel->priv->screenshot_path);
@@ -538,7 +538,7 @@ create_save_dir (void)
                           "gnome-control-center",
                           "backgrounds",
                           NULL);
-  if (g_mkdir_with_parents (path, 0755) < 0)
+  if (g_mkdir_with_parents (path, USER_DIR_MODE) < 0)
     {
       g_warning ("Failed to create directory '%s'", path);
       g_free (path);
@@ -635,7 +635,7 @@ set_background (CcBackgroundPanel *panel,
       GdkPixbuf *pixbuf;
 
       cache_path = bg_pictures_source_get_cache_path ();
-      if (g_mkdir_with_parents (cache_path, 0755) < 0)
+      if (g_mkdir_with_parents (cache_path, USER_DIR_MODE) < 0)
         {
           g_warning ("Failed to create directory '%s'", cache_path);
           g_free (cache_path);
diff --git a/panels/sound/sound-theme-file-utils.c b/panels/sound/sound-theme-file-utils.c
index 06877c7..69f6b14 100644
--- a/panels/sound/sound-theme-file-utils.c
+++ b/panels/sound/sound-theme-file-utils.c
@@ -284,7 +284,7 @@ create_custom_theme (const char *parent)
 
         /* Create the custom directory */
         path = custom_theme_dir_path (NULL);
-        g_mkdir_with_parents (path, 0755);
+        g_mkdir_with_parents (path, USER_DIR_MODE);
         g_free (path);
 
         /* Set the data for index.theme */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]