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 ... */
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;