From 8295afa3f0dfefa399b263fd4b2acbbf1c03e5d3 Mon Sep 17 00:00:00 2001 From: Greg Farnum Date: Wed, 3 Aug 2016 14:57:02 -0700 Subject: [PATCH] client: switch Inode::check_mode() to UserPerm Signed-off-by: Greg Farnum --- src/client/Client.cc | 2 +- src/client/Inode.cc | 6 +++--- src/client/Inode.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) 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); -- 2.47.3