From: Pritha Srivastava Date: Thu, 23 Feb 2017 09:28:06 +0000 (+0530) Subject: rgw: Added code to allow tenant name as part of role name also. X-Git-Tag: v12.1.0~10^2~82^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=9027b253bc68067d9d75cd19515767e28c7846f2;p=ceph.git rgw: Added code to allow tenant name as part of role name also. Signed-off-by: Pritha Srivastava --- diff --git a/src/rgw/rgw_role.cc b/src/rgw/rgw_role.cc index 2089f83c259c..236fe6e6aa44 100644 --- a/src/rgw/rgw_role.cc +++ b/src/rgw/rgw_role.cc @@ -209,6 +209,8 @@ int RGWRole::get_by_id() if (ret < 0) { return ret; } + + return 0; } int RGWRole::update() @@ -381,11 +383,22 @@ bool RGWRole::validate_input() return false; } - std::regex regex_path("(\/[!-~]+\/)|(\/)"); + std::regex regex_path("(/[!-~]+/)|(/)"); if (! std::regex_match(path,regex_path)) { ldout(cct, 0) << "ERROR: Invalid chars in path " << dendl; return false; } + + return true; +} + +void RGWRole::extract_name_tenant(const std::string& str) +{ + size_t pos = str.find('$'); + if (pos != std::string::npos) { + tenant = str.substr(0, pos); + name = str.substr(pos + 1); + } } void RGWRole::update_trust_policy(string& trust_policy) diff --git a/src/rgw/rgw_role.h b/src/rgw/rgw_role.h index b6ec5fed021b..bccb576ed2d8 100644 --- a/src/rgw/rgw_role.h +++ b/src/rgw/rgw_role.h @@ -29,6 +29,7 @@ class RGWRole int read_info(); void set_id(const string& id) { this->id = id; } bool validate_input(); + void extract_name_tenant(const std::string& str); public: RGWRole(CephContext *cct, @@ -45,6 +46,7 @@ public: tenant(std::move(tenant)) { if (this->path.empty()) this->path = "/"; + extract_name_tenant(this->name); } RGWRole(CephContext *cct, @@ -54,7 +56,9 @@ public: : cct(cct), store(store), name(std::move(name)), - tenant(std::move(tenant)) {} + tenant(std::move(tenant)) { + extract_name_tenant(this->name); + } RGWRole(CephContext *cct, RGWRados *store,