From: Greg Farnum Date: Fri, 29 Jul 2016 22:30:10 +0000 (-0700) Subject: client: switch path_walk() implementation to UserPerm X-Git-Tag: v11.0.1~36^2~64 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f7c5706575fd0c7b582748be7bd12a7f64de8fad;p=ceph.git client: switch path_walk() implementation to UserPerm Signed-off-by: Greg Farnum --- diff --git a/src/client/Client.cc b/src/client/Client.cc index 5f6e43b1dfe6..f11607af0ab8 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -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 diff --git a/src/client/Client.h b/src/client/Client.h index 60da3a639062..09170d22d761 100644 --- a/src/client/Client.h +++ b/src/client/Client.h @@ -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);