From 5cdcdaee07c1f81a0abdd3885050118474e6c079 Mon Sep 17 00:00:00 2001 From: David Schleef Date: Sat, 4 Dec 2010 21:06:34 -0800 Subject: [PATCH] registry: Fix permissions if umask is broken Fixes: #564056. --- gst/gstregistrybinary.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/gst/gstregistrybinary.c b/gst/gstregistrybinary.c index fee7ec7..54f9abb 100644 --- a/gst/gstregistrybinary.c +++ b/gst/gstregistrybinary.c @@ -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; -- 2.7.4