From 8ae1e3d5dc323542e7def06a42deea62c7ba7027 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sun, 28 Dec 2008 16:54:44 -0500 Subject: [PATCH] Explicitly chmod() directories (bug #18934) Two changes: - after mkdir(), we immediately chmod(), such that we are not affected by stupid umask's. - if a directory we want to use is not writable but exists, we try a chmod on it. This is to recover from stupid umask's having affected us with older versions. --- src/fccache.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/fccache.c b/src/fccache.c index b5aa4ea..53df860 100644 --- a/src/fccache.c +++ b/src/fccache.c @@ -817,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); @@ -849,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; @@ -866,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); -- 2.39.2