From: Greg Farnum Date: Thu, 28 Jul 2016 23:26:06 +0000 (-0700) Subject: client: switch make_request implementation and verify_reply_trace to UserPerm X-Git-Tag: v11.0.1~36^2~67 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=16b3fce662035d636c457f8e484174cbd7a0fcdd;p=ceph.git client: switch make_request implementation and verify_reply_trace to UserPerm Signed-off-by: Greg Farnum --- diff --git a/src/client/Client.cc b/src/client/Client.cc index 335bd7be159..1c2311a802d 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -1509,14 +1509,13 @@ void Client::dump_mds_requests(Formatter *f) int Client::verify_reply_trace(int r, MetaRequest *request, MClientReply *reply, InodeRef *ptarget, bool *pcreated, - int uid, int gid) + const UserPerm& perms) { // check whether this request actually did the create, and set created flag bufferlist extra_bl; inodeno_t created_ino; bool got_created_ino = false; ceph::unordered_map::iterator p; - UserPerm perms(uid, gid); extra_bl.claim(reply->get_extra_bl()); if (extra_bl.length() >= 8) { @@ -1594,15 +1593,14 @@ int Client::verify_reply_trace(int r, * a request). * * @param request the MetaRequest to execute - * @param uid uid to execute as - * @param gid gid to execute as + * @param perms The user uid/gid to execute as (eventually, full group lists?) * @param ptarget [optional] address to store a pointer to the target inode we want to create or operate on * @param pcreated [optional; required if ptarget] where to store a bool of whether our create atomically created a file * @param use_mds [optional] prefer a specific mds (-1 for default) * @param pdirbl [optional; disallowed if ptarget] where to pass extra reply payload to the caller */ -int Client::make_request(MetaRequest *request, - int uid, int gid, +int Client::make_request(MetaRequest *request, + const UserPerm& perms, InodeRef *ptarget, bool *pcreated, int use_mds, bufferlist *pdirbl) @@ -1621,13 +1619,8 @@ int Client::make_request(MetaRequest *request, if (oldest_tid == 0 && request->get_op() != CEPH_MDS_OP_SETFILELOCK) oldest_tid = tid; - if (uid < 0) - uid = get_uid(); - if (gid < 0) - gid = get_gid(); - - request->set_caller_uid(uid); - request->set_caller_gid(gid); + request->set_caller_uid(perms.uid()); + request->set_caller_gid(perms.gid()); if (cct->_conf->client_inject_fixed_oldest_tid) { ldout(cct, 20) << __func__ << " injecting fixed oldest_client_tid(1)" << dendl; @@ -1731,7 +1724,7 @@ int Client::make_request(MetaRequest *request, request->dispatch_cond = 0; if (r >= 0 && ptarget) - r = verify_reply_trace(r, request, reply, ptarget, pcreated, uid, gid); + r = verify_reply_trace(r, request, reply, ptarget, pcreated, perms); if (pdirbl) pdirbl->claim(reply->get_extra_bl()); diff --git a/src/client/Client.h b/src/client/Client.h index fd8b0d8e8a5..145bfca48cc 100644 --- a/src/client/Client.h +++ b/src/client/Client.h @@ -374,22 +374,21 @@ protected: void dump_mds_requests(Formatter *f); void dump_mds_sessions(Formatter *f); - int make_request(MetaRequest *req, int uid, int gid, - //MClientRequest *req, int uid, int gid, + int make_request(MetaRequest *req, const UserPerm& perms, InodeRef *ptarget = 0, bool *pcreated = 0, int use_mds=-1, bufferlist *pdirbl=0); - - int make_request(MetaRequest *req, const UserPerm& perm, + int make_request(MetaRequest *req, int uid, int gid, InodeRef *ptarget = 0, bool *pcreated = 0, int use_mds=-1, bufferlist *pdirbl=0) { - return make_request(req, perm.uid(), perm.gid(), ptarget, pcreated, - use_mds, pdirbl); + UserPerm perms(uid, gid); + return make_request(req, perms, ptarget, pcreated, use_mds, pdirbl); } void put_request(MetaRequest *request); void unregister_request(MetaRequest *request); int verify_reply_trace(int r, MetaRequest *request, MClientReply *reply, - InodeRef *ptarget, bool *pcreated, int uid, int gid); + InodeRef *ptarget, bool *pcreated, + const UserPerm& perms); void encode_cap_releases(MetaRequest *request, mds_rank_t mds); int encode_inode_release(Inode *in, MetaRequest *req, mds_rank_t mds, int drop,