]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
client/fuse: Fix directory DACs overriding for root 46596/head
authorKotresh HR <khiremat@redhat.com>
Thu, 28 Apr 2022 10:31:48 +0000 (16:01 +0530)
committerKotresh HR <khiremat@redhat.com>
Thu, 9 Jun 2022 11:10:40 +0000 (16:40 +0530)
DACs are overridable for directories. For files,
Read/write DACs are always overridable but executable
DACs are overridable when there is at least one exec bit
set.

The files and directory DACS overriding were handled the
same way for root which is incorrect. This patch fixes
DACs overriding as described above for the root.

Fixes: https://tracker.ceph.com/issues/55313
Signed-off-by: Kotresh HR <khiremat@redhat.com>
(cherry picked from commit 2e1f43c99b1818c2ffde64f5b01083c1907a9f87)

qa/suites/fs/permission/tasks/cfuse_workunit_misc.yaml
qa/workunits/fs/misc/dac_override.sh [new file with mode: 0755]
src/client/Client.cc

index 6ff6195bfb473959daeaa716863598307b93df9d..ca026c45ff1ec3c49ecf3768d28e14dc84e0ad97 100644 (file)
@@ -9,3 +9,4 @@ tasks:
       all:
         - fs/misc/acl.sh
         - fs/misc/chmod.sh
+        - fs/misc/dac_override.sh
diff --git a/qa/workunits/fs/misc/dac_override.sh b/qa/workunits/fs/misc/dac_override.sh
new file mode 100755 (executable)
index 0000000..dfb1a90
--- /dev/null
@@ -0,0 +1,19 @@
+#!/bin/sh -x
+
+expect_failure() {
+       if "$@"; then return 1; else return 0; fi
+}
+
+set -e
+
+mkdir -p testdir
+file=test_chmod.$$
+
+echo "foo" > testdir/${file}
+sudo chmod 600 testdir
+
+# only root can read
+expect_failure cat testdir/${file}
+
+# directory read/write DAC override for root should allow read
+sudo cat testdir/${file}
index 1250249b65c0b0f8223da1a1796c08a671cbbb7b..86b1bb7fe881f80742f6e2fb433b57fcfa6a1546 100644 (file)
@@ -5615,8 +5615,10 @@ void Client::handle_cap_grant(MetaSession *session, Inode *in, Cap *cap, const M
 int Client::inode_permission(Inode *in, const UserPerm& perms, unsigned want)
 {
   if (perms.uid() == 0) {
-    // Executable are overridable when there is at least one exec bit set
-    if((want & MAY_EXEC) && !(in->mode & S_IXUGO))
+    // For directories, DACs are overridable.
+    // For files, Read/write DACs are always overridable but executable DACs are
+    // overridable when there is at least one exec bit set
+    if(!S_ISDIR(in->mode) && (want & MAY_EXEC) && !(in->mode & S_IXUGO))
       return -CEPHFS_EACCES;
     return 0;
   }