]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
client: switch inode_permission() to UserPerm-based (over UserGroups)
authorGreg Farnum <gfarnum@redhat.com>
Wed, 3 Aug 2016 21:27:02 +0000 (14:27 -0700)
committerGreg Farnum <gfarnum@redhat.com>
Wed, 21 Sep 2016 23:33:55 +0000 (16:33 -0700)
Signed-off-by: Greg Farnum <gfarnum@redhat.com>
src/client/Client.cc
src/client/Client.h

index 915a2d8bd7871312e3ad4f728fcf308cf4a801e2..e3e2e374c336c5ae18371fbe4ca90849a9210b1c 100644 (file)
@@ -5020,19 +5020,22 @@ int Client::_getgrouplist(gid_t** sgids, int uid, int gid)
 #endif
 }
 
-int Client::inode_permission(Inode *in, uid_t uid, UserGroups& groups, unsigned want)
+int Client::inode_permission(Inode *in, const UserPerm& perms, unsigned want)
 {
-  if (uid == 0)
+  if (perms.uid() == 0)
     return 0;
+  
+  RequestUserGroups groups(perms.uid(), perms.gid());
+  init_groups(&groups);
 
-  if (uid != in->uid && (in->mode & S_IRWXG)) {
-    int ret = _posix_acl_permission(in, uid, groups, want);
+  if (perms.uid() != in->uid && (in->mode & S_IRWXG)) {
+    int ret = _posix_acl_permission(in, perms.uid(), groups, want);
     if (ret != -EAGAIN)
       return ret;
   }
 
   // check permissions before doing anything else
-  if (!in->check_mode(uid, groups, want))
+  if (!in->check_mode(perms.uid(), groups, want))
     return -EACCES;
   return 0;
 }
index c94517f13db6840f50961a5e99faef5ee75164cf..304160e6eb26af69a5df1e9165489bdb0c5d915e 100644 (file)
@@ -846,7 +846,7 @@ private:
   friend class RequestUserGroups;
   void init_groups(RequestUserGroups *groups);
 
-  int inode_permission(Inode *in, uid_t uid, UserGroups& groups, unsigned want);
+  int inode_permission(Inode *in, const UserPerm& perms, unsigned want);
   int xattr_permission(Inode *in, const char *name, unsigned want,
                       const UserPerm& perms);
   int may_setattr(Inode *in, struct stat *st, int mask, const UserPerm& perms);
@@ -856,12 +856,6 @@ private:
   int may_delete(Inode *dir, const char *name, const UserPerm& perms);
   int may_hardlink(Inode *in, const UserPerm& perms);
 
-  int inode_permission(Inode *in, const UserPerm& perms, unsigned want) {
-    RequestUserGroups groups(perms.uid(), perms.gid());
-    init_groups(&groups);
-    return inode_permission(in, perms.uid(), groups, want);
-  }
-
   int _getattr_for_perm(Inode *in, const UserPerm& perms);
   int _getgrouplist(gid_t **sgids, int uid, int gid);