registry: Fix permissions if umask is broken
authorDavid Schleef <ds@schleef.org>
Sun, 5 Dec 2010 05:06:34 +0000 (21:06 -0800)
committerDavid Schleef <ds@schleef.org>
Sun, 5 Dec 2010 05:08:21 +0000 (21:08 -0800)
Fixes: #564056.

gst/gstregistrybinary.c

index fee7ec7..54f9abb 100644 (file)
@@ -177,11 +177,19 @@ gst_registry_binary_cache_init (GstRegistry * registry, const char *location)
   cache->tmp_location = g_strconcat (location, ".tmpXXXXXX", NULL);
   cache->cache_fd = g_mkstemp (cache->tmp_location);
   if (cache->cache_fd == -1) {
+    int ret;
+    GStatBuf statbuf;
     gchar *dir;
 
     /* oops, I bet the directory doesn't exist */
     dir = g_path_get_dirname (location);
     g_mkdir_with_parents (dir, 0777);
+
+    ret = g_stat (dir, &statbuf);
+    if (ret != -1 && (statbuf.st_mode & 0700) != 0700) {
+      g_chmod (dir, 0700);
+    }
+
     g_free (dir);
 
     /* the previous g_mkstemp call overwrote the XXXXXX placeholder ... */
@@ -195,6 +203,11 @@ gst_registry_binary_cache_init (GstRegistry * registry, const char *location)
       g_slice_free (BinaryRegistryCache, cache);
       return NULL;
     }
+
+    ret = g_stat (cache->tmp_location, &statbuf);
+    if (ret != -1 && (statbuf.st_mode & 0600) != 0600) {
+      g_chmod (cache->tmp_location, 0600);
+    }
   }
 
   return cache;