aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDmitry Kalinkin <dmitry.kalinkin@gmail.com>2016-07-25 18:00:08 -0400
committerDmitry Kalinkin <dkalinkin@bnl.gov>2016-07-25 18:11:46 -0400
commitf91748ba737c9d99b407572756cc003e4d956b8e (patch)
treef1ea642e616fb1e741cf23e2bbb2bf1d6a983c85 /src
parentee3032e4de439b481ce1a4bc7fd8d71ea6ed2c94 (diff)
override rx directory permissions in deletePath()
This fixes instantiation of pythonPackages.pytest that produces a directory with less permissions during one of it's tests that leads to a nix error like: error: opening directory ‘/tmp/nix-build-python2.7-pytest-2.9.2.drv-0/pytest-of-user/pytest-0/testdir/test_cache_failure_warns0/.cache’: Permission denied
Diffstat (limited to 'src')
-rw-r--r--src/libutil/util.cc9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/libutil/util.cc b/src/libutil/util.cc
index f1e714a66..95103c4e5 100644
--- a/src/libutil/util.cc
+++ b/src/libutil/util.cc
@@ -330,10 +330,11 @@ static void _deletePath(const Path & path, unsigned long long & bytesFreed)
bytesFreed += st.st_blocks * 512;
if (S_ISDIR(st.st_mode)) {
- /* Make the directory writable. */
- if (!(st.st_mode & S_IWUSR)) {
- if (chmod(path.c_str(), st.st_mode | S_IWUSR) == -1)
- throw SysError(format("making ‘%1%’ writable") % path);
+ /* Make the directory accessible. */
+ const auto PERM_MASK = S_IRUSR | S_IWUSR | S_IXUSR;
+ if ((st.st_mode & PERM_MASK) != PERM_MASK) {
+ if (chmod(path.c_str(), st.st_mode | PERM_MASK) == -1)
+ throw SysError(format("chmod ‘%1%’") % path);
}
for (auto & i : readDirectory(path))