From d291e664aeb987a0c2f236205a521d7f282c33d1 Mon Sep 17 00:00:00 2001 From: Greg Farnum Date: Fri, 5 Aug 2016 17:20:32 -0700 Subject: [PATCH] MClientRequest: include the full gid list of the caller Signed-off-by: Greg Farnum --- src/client/Client.cc | 3 +++ src/messages/MClientRequest.h | 21 +++++++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/client/Client.cc b/src/client/Client.cc index 85df5afb614..c3ce432be22 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -2169,6 +2169,9 @@ MClientRequest* Client::build_client_request(MetaRequest *request) req->set_data(request->data); req->set_retry_attempt(request->retry_attempt++); req->head.num_fwd = request->num_fwd; + const gid_t *_gids; + int gid_count = request->perms.get_gids(&_gids); + req->set_gid_list(gid_count, _gids); return req; } diff --git a/src/messages/MClientRequest.h b/src/messages/MClientRequest.h index 1c374591057..60133427243 100644 --- a/src/messages/MClientRequest.h +++ b/src/messages/MClientRequest.h @@ -46,7 +46,7 @@ // metadata ops. class MClientRequest : public Message { - static const int HEAD_VERSION = 3; + static const int HEAD_VERSION = 4; static const int COMPAT_VERSION = 1; public: @@ -75,6 +75,7 @@ public: // path arguments filepath path, path2; + vector gid_list; @@ -136,6 +137,12 @@ public: void set_string2(const char *s) { path2.set_path(s, 0); } void set_caller_uid(unsigned u) { head.caller_uid = u; } void set_caller_gid(unsigned g) { head.caller_gid = g; } + void set_gid_list(int count, const gid_t *gids) { + gid_list.reserve(count); + for (int i = 0; i < count; ++i) { + gid_list.push_back(gids[i]); + } + } void set_dentry_wanted() { head.flags = head.flags | CEPH_MDS_FLAG_WANT_DENTRY; } @@ -150,6 +157,7 @@ public: int get_op() const { return head.op; } unsigned get_caller_uid() const { return head.caller_uid; } unsigned get_caller_gid() const { return head.caller_gid; } + const vector& get_caller_gid_list() const { return gid_list; } const string& get_path() const { return path.get_path(); } const filepath& get_filepath() const { return path; } @@ -166,6 +174,8 @@ public: ::decode_nohead(head.num_releases, releases, p); if (header.version >= 2) ::decode(stamp, p); + if (header.version >= 4) // epoch 3 was for a ceph_mds_request_args change + ::decode(gid_list, p); } void encode_payload(uint64_t features) { @@ -175,6 +185,7 @@ public: ::encode(path2, payload); ::encode_nohead(releases, payload); ::encode(stamp, payload); + ::encode(gid_list, payload); } const char *get_type_name() const { return "creq"; } @@ -218,7 +229,13 @@ public: out << " RETRY=" << (int)head.num_retry; if (get_flags() & CEPH_MDS_FLAG_REPLAY) out << " REPLAY"; - out << ")"; + out << " caller_uid=" << head.caller_uid + << ", caller_gid=" << head.caller_gid + << '{'; + for (auto i = gid_list.begin(); i != gid_list.end(); ++i) + out << *i << ','; + out << '}' + << ")"; } };