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;
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;
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
// 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);
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);