Skip to content

Commit

Permalink
Merge pull request #46078 from kotreshhr/fuse-directory-dacs-issue
Browse files Browse the repository at this point in the history
client/fuse: Fix directory DACs overriding for root

Reviewed-by: Venky Shankar <vshankar@redhat.com>
Reviewed-by: Ramana Raja <rraja@redhat.com>
  • Loading branch information
vshankar committed Jun 7, 2022
2 parents 37a466b + 2e1f43c commit 45c9fd6
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
1 change: 1 addition & 0 deletions qa/suites/fs/permission/tasks/cfuse_workunit_misc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ tasks:
all:
- fs/misc/acl.sh
- fs/misc/chmod.sh
- fs/misc/dac_override.sh
19 changes: 19 additions & 0 deletions qa/workunits/fs/misc/dac_override.sh
Original file line number Diff line number Diff line change
@@ -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}
6 changes: 4 additions & 2 deletions src/client/Client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5737,8 +5737,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;
}
Expand Down

0 comments on commit 45c9fd6

Please sign in to comment.