]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
client: switch path_walk() implementation to UserPerm
authorGreg Farnum <gfarnum@redhat.com>
Fri, 29 Jul 2016 22:30:10 +0000 (15:30 -0700)
committerGreg Farnum <gfarnum@redhat.com>
Wed, 21 Sep 2016 23:33:49 +0000 (16:33 -0700)
Signed-off-by: Greg Farnum <gfarnum@redhat.com>
src/client/Client.cc
src/client/Client.h

index 5f6e43b1dfe6346759a43d02848925e76a78f84f..f11607af0ab8e06858ebdea4d4adf80e51da8930 100644 (file)
@@ -5994,8 +5994,8 @@ int Client::get_or_create(Inode *dir, const char* name,
   return 0;
 }
 
-int Client::path_walk(const filepath& origpath, InodeRef *end, bool followsym,
-                     int uid, int gid)
+int Client::path_walk(const filepath& origpath, InodeRef *end,
+                     const UserPerm& perms, bool followsym)
 {
   filepath path = origpath;
   InodeRef cur;
@@ -6005,11 +6005,6 @@ int Client::path_walk(const filepath& origpath, InodeRef *end, bool followsym,
     cur = cwd;
   assert(cur);
 
-  if (uid < 0)
-    uid = get_uid();
-  if (gid < 0)
-    gid = get_gid();
-
   ldout(cct, 10) << "path_walk " << path << dendl;
 
   int symlinks = 0;
@@ -6022,12 +6017,12 @@ int Client::path_walk(const filepath& origpath, InodeRef *end, bool followsym,
     ldout(cct, 20) << "  (path is " << path << ")" << dendl;
     InodeRef next;
     if (cct->_conf->client_permissions) {
-      int r = may_lookup(cur.get(), uid, gid);
+      int r = may_lookup(cur.get(), perms);
       if (r < 0)
        return r;
       caps = CEPH_CAP_AUTH_SHARED;
     }
-    int r = _lookup(cur.get(), dname, caps, &next, uid, gid);
+    int r = _lookup(cur.get(), dname, caps, &next, perms);
     if (r < 0)
       return r;
     // only follow trailing symlink if followsym.  always follow
index 60da3a639062bafbc22d6292356f65e62c533d9f..09170d22d761df08485e374b695def52f07c2bc8 100644 (file)
@@ -540,11 +540,14 @@ protected:
 
   // path traversal for high-level interface
   InodeRef cwd;
-  int path_walk(const filepath& fp, InodeRef *end, bool followsym=true,
-               int uid=-1, int gid=-1);
   int path_walk(const filepath& fp, InodeRef *end, const UserPerm& perms,
-               bool followsym=true) {
-    return path_walk(fp, end, followsym, perms.uid(), perms.gid());
+               bool followsym=true);
+  int path_walk(const filepath& fp, InodeRef *end, bool followsym=true,
+               int uid=-1, int gid=-1) {
+    if (uid < 0) uid = get_uid();
+    if (gid < 0) gid = get_gid();
+    UserPerm perms(uid, gid);
+    return path_walk(fp, end, perms, followsym);
   }
 
   int fill_stat(Inode *in, struct stat *st, frag_info_t *dirstat=0, nest_info_t *rstat=0);
@@ -782,11 +785,6 @@ private:
 
   int _lookup(Inode *dir, const string& dname, int mask, InodeRef *target,
              const UserPerm& perm);
-  int _lookup(Inode *dir, const string& dname, int mask, InodeRef *target,
-             int uid, int gid) {
-    UserPerm perms(uid, gid);
-    return _lookup(dir, dname, mask, target, perms);
-  }
 
   int _link(Inode *in, Inode *dir, const char *name, const UserPerm& perm,
            InodeRef *inp = 0);