From: Greg Farnum Date: Wed, 3 Aug 2016 21:57:02 +0000 (-0700) Subject: client: switch Inode::check_mode() to UserPerm X-Git-Tag: v11.0.1~36^2~21 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=8295afa3f0dfefa399b263fd4b2acbbf1c03e5d3;p=ceph.git client: switch Inode::check_mode() to UserPerm Signed-off-by: Greg Farnum --- diff --git a/src/client/Client.cc b/src/client/Client.cc index e3e2e374c336..dc05c98426bc 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -5035,7 +5035,7 @@ int Client::inode_permission(Inode *in, const UserPerm& perms, unsigned want) } // check permissions before doing anything else - if (!in->check_mode(perms.uid(), groups, want)) + if (!in->check_mode(perms, want)) return -EACCES; return 0; } diff --git a/src/client/Inode.cc b/src/client/Inode.cc index 06e111c19b3f..0a324aa637d8 100644 --- a/src/client/Inode.cc +++ b/src/client/Inode.cc @@ -331,12 +331,12 @@ Dir *Inode::open_dir() return dir; } -bool Inode::check_mode(uid_t ruid, UserGroups& groups, unsigned want) +bool Inode::check_mode(const UserPerm& perms, unsigned want) { - if (uid == ruid) { + if (uid == perms.uid()) { // if uid is owner, owner entry determines access want = want << 6; - } else if (groups.is_in(gid)) { + } else if (perms.gid_in_groups(gid)) { // if a gid or sgid matches the owning group, group entry determines access want = want << 3; } diff --git a/src/client/Inode.h b/src/client/Inode.h index 2c74b8b1e641..de07ff210200 100644 --- a/src/client/Inode.h +++ b/src/client/Inode.h @@ -260,7 +260,7 @@ struct Inode { } }; - bool check_mode(uid_t uid, UserGroups& groups, unsigned want); + bool check_mode(const UserPerm& perms, unsigned want); // CAPS -------- void get_open_ref(int mode);