From: Casey Bodley Date: Tue, 6 Apr 2021 19:35:54 +0000 (-0400) Subject: rgw: read_obj_policy() consults iam_user_policies on ENOENT X-Git-Tag: v17.1.0~2081^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=5dc9375fa1888242f388f8b502f445f3ddc891f7;p=ceph-ci.git rgw: read_obj_policy() consults iam_user_policies on ENOENT when the head object doesn't exist, read_obj_policy() has to decide whether to return ENOENT or EACCES when there's a bucket policy, we check whether it has s3ListBucket permissions. when there's an assumed role, we also need to check against the role's policies in s->iam_user_policies Fixes: https://tracker.ceph.com/issues/49780 Signed-off-by: Casey Bodley --- diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index f2822e372da..683947d3b97 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -488,8 +488,15 @@ static int read_obj_policy(const DoutPrefixProvider *dpp, const rgw_user& bucket_owner = bucket_policy.get_owner().get_id(); if (bucket_owner.compare(s->user->get_id()) != 0 && ! s->auth.identity->is_admin_of(bucket_owner)) { + auto r = eval_user_policies(s->iam_user_policies, s->env, + *s->auth.identity, rgw::IAM::s3ListBucket, + ARN(bucket->get_key())); + if (r == Effect::Allow) + return -ENOENT; + if (r == Effect::Deny) + return -EACCES; if (policy) { - auto r = policy->eval(s->env, *s->auth.identity, rgw::IAM::s3ListBucket, ARN(bucket->get_key())); + r = policy->eval(s->env, *s->auth.identity, rgw::IAM::s3ListBucket, ARN(bucket->get_key())); if (r == Effect::Allow) return -ENOENT; if (r == Effect::Deny)