From: Pritha Srivastava Date: Tue, 25 Jan 2022 16:43:15 +0000 (+0530) Subject: rgw: code changes to include tenant in replicated metadata X-Git-Tag: v17.2.6~119^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=a214864409a9b02b431b4952a88f6dcde3a677f3;p=ceph.git rgw: code changes to include tenant in replicated metadata for roles. Signed-off-by: Pritha Srivastava (cherry picked from commit 0d96b29e8d5611a8a14aa20583f0feae5e5eba17) --- diff --git a/src/rgw/rgw_role.cc b/src/rgw/rgw_role.cc index 1d311e8fab7b..93cfa9e64803 100644 --- a/src/rgw/rgw_role.cc +++ b/src/rgw/rgw_role.cc @@ -39,7 +39,8 @@ const string RGWRole::role_arn_prefix = "arn:aws:iam::"; void RGWRoleInfo::dump(Formatter *f) const { encode_json("RoleId", id , f); - encode_json("RoleName", name , f); + std::string role_name = tenant + '$' + name; + encode_json("RoleName", role_name , f); encode_json("Path", path, f); encode_json("Arn", arn, f); encode_json("CreateDate", creation_date, f); @@ -68,6 +69,10 @@ void RGWRoleInfo::decode_json(JSONObj *obj) JSONDecoder::decode_json("CreateDate", creation_date, obj); JSONDecoder::decode_json("MaxSessionDuration", max_session_duration, obj); JSONDecoder::decode_json("AssumeRolePolicyDocument", trust_policy, obj); + if (auto pos = name.find('$'); pos != std::string::npos) { + tenant = name.substr(0, pos); + name = name.substr(pos+1); + } } RGWRole::RGWRole(std::string name, diff --git a/src/rgw/rgw_role.h b/src/rgw/rgw_role.h index 97f517fe0fba..ac124d777719 100644 --- a/src/rgw/rgw_role.h +++ b/src/rgw/rgw_role.h @@ -152,7 +152,7 @@ class RGWRoleMetadataObject: public RGWMetadataObject { Store* store; public: RGWRoleMetadataObject() = default; - RGWRoleMetadataObject(RGWRoleInfo info, + RGWRoleMetadataObject(RGWRoleInfo& info, const obj_version& v, real_time m, Store* store) : RGWMetadataObject(v,m), info(info), store(store) {}