about summary refs log tree commit diff
path: root/src/libutil
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2016-10-06T09·08+0200
committerGitHub <noreply@github.com>2016-10-06T09·08+0200
commitcd128f4bad0444e0c244d62dd8abe277c189e629 (patch)
treed7f07e0dc3c09b3d791e6a1d5ba9dd7eec8a4b82 /src/libutil
parentc6a929986aa25860cd93da9b7ab4488144934ead (diff)
parentf91748ba737c9d99b407572756cc003e4d956b8e (diff)
Merge pull request #998 from veprbl/rx_chmod_fix
override rx directory permissions in deletePath()
Diffstat (limited to 'src/libutil')
-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 e2f5b087f13f..1f923fe6bc0f 100644
--- a/src/libutil/util.cc
+++ b/src/libutil/util.cc
@@ -339,10 +339,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))