From: cao.leilc Date: Thu, 17 Jun 2021 12:04:23 +0000 (+0800) Subject: rgw : add check for tenant provided in RGWCreateRole X-Git-Tag: v15.2.15~11^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=db98361578ecc48ce76a2d734e1d201f6cf7772f;p=ceph.git rgw : add check for tenant provided in RGWCreateRole Fixes: https://tracker.ceph.com/issues/51206 Signed-off-by: caolei (cherry picked from commit 3c99ac14080c9f5b1611c9bbe4a223a9fd2927a0) Conflicts: src/rgw/rgw_rest_role.cc - Octopus constructs role explicitly vs. using store->get_role(), and does not wrap in a unique_ptr --- diff --git a/src/rgw/rgw_rest_role.cc b/src/rgw/rgw_rest_role.cc index cb3b2c8566bd..473e670d02ba 100644 --- a/src/rgw/rgw_rest_role.cc +++ b/src/rgw/rgw_rest_role.cc @@ -129,8 +129,15 @@ void RGWCreateRole::execute() if (op_ret < 0) { return; } + std::string user_tenant = s->user->get_tenant(); RGWRole role(s->cct, store->getRados()->pctl, role_name, role_path, trust_policy, - s->user->get_tenant(), max_session_duration); + user_tenant, max_session_duration); + if (!user_tenant.empty() && role.get_tenant() != user_tenant) { + ldpp_dout(this, 20) << "ERROR: the tenant provided in the role name does not match with the tenant of the user creating the role" + << dendl; + op_ret = -EINVAL; + return; + } op_ret = role.create(true); if (op_ret == -EEXIST) {