From: Greg Farnum Date: Wed, 27 Jul 2016 01:24:05 +0000 (-0700) Subject: client: always pass a UserPerm to ll_lookup X-Git-Tag: v11.0.1~36^2~89 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=aaf6915484a2e0b6ee514b7c2ab53bccab407f56;p=ceph.git client: always pass a UserPerm to ll_lookup Signed-off-by: Greg Farnum --- diff --git a/src/client/Client.cc b/src/client/Client.cc index dd21a26deda0..209c32e19085 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -9508,7 +9508,7 @@ Inode *Client::open_snapdir(Inode *diri) } int Client::ll_lookup(Inode *parent, const char *name, struct stat *attr, - Inode **out, int uid, int gid) + Inode **out, const UserPerm& perms) { Mutex::Locker lock(client_lock); ldout(cct, 3) << "ll_lookup " << parent << " " << name << dendl; @@ -9517,7 +9517,7 @@ int Client::ll_lookup(Inode *parent, const char *name, struct stat *attr, int r = 0; if (!cct->_conf->fuse_default_permissions) { - r = may_lookup(parent, uid, gid); + r = may_lookup(parent, perms); if (r < 0) return r; } @@ -9525,7 +9525,7 @@ int Client::ll_lookup(Inode *parent, const char *name, struct stat *attr, string dname(name); InodeRef in; - r = _lookup(parent, dname, CEPH_STAT_CAP_INODE_ALL, &in, uid, gid); + r = _lookup(parent, dname, CEPH_STAT_CAP_INODE_ALL, &in, perms); if (r < 0) { attr->st_ino = 0; goto out; diff --git a/src/client/Client.h b/src/client/Client.h index 977bdc454889..0d1199cf648c 100644 --- a/src/client/Client.h +++ b/src/client/Client.h @@ -1137,7 +1137,7 @@ public: Inode *ll_get_inode(ino_t ino); Inode *ll_get_inode(vinodeno_t vino); int ll_lookup(Inode *parent, const char *name, struct stat *attr, - Inode **out, int uid = -1, int gid = -1); + Inode **out, const UserPerm& perms); bool ll_forget(Inode *in, int count); bool ll_put(Inode *in); int ll_getattr(Inode *in, struct stat *st, int uid = -1, int gid = -1); diff --git a/src/client/SyntheticClient.cc b/src/client/SyntheticClient.cc index ca18cc0ba182..3950d4ad7620 100644 --- a/src/client/SyntheticClient.cc +++ b/src/client/SyntheticClient.cc @@ -1024,7 +1024,7 @@ int SyntheticClient::play_trace(Trace& t, string& prefix, bool metadata_only) client->mkdir(prefix.c_str(), 0755, perms); struct stat attr; i1 = client->ll_get_inode(vinodeno_t(1, CEPH_NOSNAP)); - if (client->ll_lookup(i1, prefix.c_str(), &attr, &i2) == 0) { + if (client->ll_lookup(i1, prefix.c_str(), &attr, &i2, perms) == 0) { ll_inos[1] = attr.st_ino; dout(5) << "'root' ino is " << inodeno_t(attr.st_ino) << dendl; client->ll_put(i1); @@ -1229,7 +1229,7 @@ int SyntheticClient::play_trace(Trace& t, string& prefix, bool metadata_only) struct stat attr; if (ll_inos.count(i)) { i1 = client->ll_get_inode(vinodeno_t(ll_inos[i],CEPH_NOSNAP)); - if (client->ll_lookup(i1, name, &attr, &i2) == 0) + if (client->ll_lookup(i1, name, &attr, &i2, perms) == 0) ll_inos[r] = attr.st_ino; client->ll_put(i1); } diff --git a/src/client/fuse_ll.cc b/src/client/fuse_ll.cc index e08b73a34456..b7c77dd23b4a 100644 --- a/src/client/fuse_ll.cc +++ b/src/client/fuse_ll.cc @@ -111,9 +111,10 @@ static void fuse_ll_lookup(fuse_req_t req, fuse_ino_t parent, const char *name) struct fuse_entry_param fe; Inode *i2, *i1 = cfuse->iget(parent); // see below int r; + UserPerm perms(ctx->uid, ctx->gid); memset(&fe, 0, sizeof(fe)); - r = cfuse->client->ll_lookup(i1, name, &fe.attr, &i2, ctx->uid, ctx->gid); + r = cfuse->client->ll_lookup(i1, name, &fe.attr, &i2, perms); if (r >= 0) { fe.ino = cfuse->make_fake_ino(fe.attr.st_ino, fe.attr.st_dev); fe.attr.st_rdev = new_encode_dev(fe.attr.st_rdev); diff --git a/src/libcephfs.cc b/src/libcephfs.cc index dd50890e2e72..8b33e90809a9 100644 --- a/src/libcephfs.cc +++ b/src/libcephfs.cc @@ -1383,7 +1383,8 @@ extern "C" int ceph_ll_lookup(class ceph_mount_info *cmount, struct stat *attr, Inode **out, int uid, int gid) { - return (cmount->get_client())->ll_lookup(parent, name, attr, out, uid, gid); + UserPerm perms(uid, gid); + return (cmount->get_client())->ll_lookup(parent, name, attr, out, perms); } extern "C" int ceph_ll_put(class ceph_mount_info *cmount, Inode *in)