From 0d96b29e8d5611a8a14aa20583f0feae5e5eba17 Mon Sep 17 00:00:00 2001 From: Pritha Srivastava Date: Tue, 25 Jan 2022 22:13:15 +0530 Subject: [PATCH] rgw: code changes to include tenant in replicated metadata for roles. Signed-off-by: Pritha Srivastava --- src/rgw/rgw_role.cc | 7 ++++++- src/rgw/rgw_role.h | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/rgw/rgw_role.cc b/src/rgw/rgw_role.cc index 1d311e8fab7bb..93cfa9e648035 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 97f517fe0fbad..ac124d777719c 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) {} -- 2.39.5