mirror of
https://github.com/NixOS/nix.git
synced 2025-11-09 03:56:01 +01:00
libstore: always canonicalize directory permissions
Prior to this patch, mode 0444 is not updated to 0555 for directories. That means for instance 0554 is canonicalized, but not 0444. We don't believe this has any implications for backwards compatibility, because directories do not have permissions in NAR format and so are always 0555 after deserialization, and store paths with wrong permissions can’t be copied to another host. Co-authored-by: Robert Hensing <robert@roberthensing.nl>
This commit is contained in:
parent
664f06c94c
commit
c38987e04a
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. */
|
||||
mode_t mode = st.st_mode & ~S_IFMT;
|
||||
|
||||
if (mode != 0444 && mode != 0555) {
|
||||
mode = (st.st_mode & S_IFMT) | 0444 | (st.st_mode & S_IXUSR ? 0111 : 0);
|
||||
bool isDir = S_ISDIR(st.st_mode);
|
||||
if ((mode != 0444 || isDir) && mode != 0555) {
|
||||
mode = (st.st_mode & S_IFMT) | 0444 | (st.st_mode & S_IXUSR || isDir ? 0111 : 0);
|
||||
if (chmod(path.c_str(), mode) == -1)
|
||||
throw SysError("changing mode of '%1%' to %2$o", path, mode);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue