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.
This commit is contained in:
Behdad Esfahbod 2008-12-28 16:54:44 -05:00
parent b6cf885a0a
commit 8ae1e3d5dc
1 changed files with 11 additions and 3 deletions

View File

@ -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);