]> git.wh0rd.org - fontconfig.git/blobdiff - src/fccache.c
Explicitly chmod() directories (bug #18934)
[fontconfig.git] / src / fccache.c
index c7a2dcdc0fbc9ca18654bcc06426e5dab45a6fac..53df860bd3f7b649513a8a1a68bb47947c8dbfe8 100644 (file)
@@ -85,7 +85,7 @@ typedef __int64 INT64;
  * just use the UTC timestamps from NTFS, converted to the Unix epoch.
  */
 
-static int
+int
 FcStat (const char *file, struct stat *statb)
 {
     WIN32_FILE_ATTRIBUTE_DATA wfad;
@@ -131,11 +131,6 @@ FcStat (const char *file, struct stat *statb)
     
     return 0;
 }
-
-#else
-
-#define FcStat stat
-
 #endif
 
 static const char bin2hex[] = { '0', '1', '2', '3',
@@ -822,9 +817,9 @@ FcMakeDirectory (const FcChar8 *dir)
     if (!parent)
        return FcFalse;
     if (access ((char *) parent, F_OK) == 0)
-       ret = mkdir ((char *) dir, 0777) == 0;
+       ret = mkdir ((char *) dir, 0755) == 0 && chmod ((char *) dir, 0755) == 0;
     else if (access ((char *) parent, F_OK) == -1)
-       ret = FcMakeDirectory (parent) && (mkdir ((char *) dir, 0777) == 0);
+       ret = FcMakeDirectory (parent) && (mkdir ((char *) dir, 0755) == 0) && chmod ((char *) dir, 0755) == 0;
     else
        ret = FcFalse;
     FcStrFree (parent);
@@ -854,7 +849,7 @@ FcDirCacheWrite (FcCache *cache, FcConfig *config)
     if (!list)
        return FcFalse;
     while ((test_dir = FcStrListNext (list))) {
-       if (access ((char *) test_dir, W_OK) == 0)
+       if (access ((char *) test_dir, W_OK|X_OK) == 0)
        {
            cache_dir = test_dir;
            break;
@@ -871,6 +866,14 @@ FcDirCacheWrite (FcCache *cache, FcConfig *config)
                    break;
                }
            }
+           /*
+            * Otherwise, try making it writable
+            */
+           else if (chmod ((char *) test_dir, 0755) == 0)
+           {
+               cache_dir = test_dir;
+               break;
+           }
        }
     }
     FcStrListDone (list);