registry: Fix permissions if umask is broken

Fixes: #564056.
This commit is contained in:
David Schleef 2010-12-04 21:06:34 -08:00
parent 9ae630c73d
commit 5cdcdaee07

View 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;