]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: read_obj_policy() consults iam_user_policies on ENOENT 40631/head
authorCasey Bodley <cbodley@redhat.com>
Tue, 6 Apr 2021 19:35:54 +0000 (15:35 -0400)
committerCasey Bodley <cbodley@redhat.com>
Wed, 7 Apr 2021 15:19:47 +0000 (11:19 -0400)
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 <cbodley@redhat.com>
src/rgw/rgw_op.cc

index f2822e372dafe6e0ba08258482cab2f5653e2d13..683947d3b97dd94ce5e97b688760fb679f621c17 100644 (file)
@@ -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)