mirror of
https://github.com/NixOS/nix.git
synced 2025-11-15 06:52:43 +01:00
Merge pull request #13526 from philiptaron/issue-12786/canonicaliseTimestampAndPermissions-on-dir-better
libstore: always canonicalize directory permissions
This commit is contained in:
commit
55f6ff36c2
1 changed files with 3 additions and 3 deletions
|
|
@ -21,9 +21,9 @@ static void canonicaliseTimestampAndPermissions(const Path & path, const struct
|
||||||
|
|
||||||
/* Mask out all type related bits. */
|
/* Mask out all type related bits. */
|
||||||
mode_t mode = st.st_mode & ~S_IFMT;
|
mode_t mode = st.st_mode & ~S_IFMT;
|
||||||
|
bool isDir = S_ISDIR(st.st_mode);
|
||||||
if (mode != 0444 && mode != 0555) {
|
if ((mode != 0444 || isDir) && mode != 0555) {
|
||||||
mode = (st.st_mode & S_IFMT) | 0444 | (st.st_mode & S_IXUSR ? 0111 : 0);
|
mode = (st.st_mode & S_IFMT) | 0444 | (st.st_mode & S_IXUSR || isDir ? 0111 : 0);
|
||||||
if (chmod(path.c_str(), mode) == -1)
|
if (chmod(path.c_str(), mode) == -1)
|
||||||
throw SysError("changing mode of '%1%' to %2$o", path, mode);
|
throw SysError("changing mode of '%1%' to %2$o", path, mode);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue