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: v17.1.0~1338^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=3c99ac14080c9f5b1611c9bbe4a223a9fd2927a0;p=ceph.git rgw : add check for tenant provided in RGWCreateRole Fixes: https://tracker.ceph.com/issues/51206 Signed-off-by: caolei --- diff --git a/src/rgw/rgw_rest_role.cc b/src/rgw/rgw_rest_role.cc index a542804220d9..0abf9155b17b 100644 --- a/src/rgw/rgw_rest_role.cc +++ b/src/rgw/rgw_rest_role.cc @@ -131,11 +131,18 @@ void RGWCreateRole::execute(optional_yield y) if (op_ret < 0) { return; } + std::string user_tenant = s->user->get_tenant(); std::unique_ptr role = store->get_role(role_name, - s->user->get_tenant(), + user_tenant, role_path, trust_policy, 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(s, true, y); if (op_ret == -EEXIST) {