Navigation Menu

Skip to content

Commit

Permalink
rgw: Evaluating bucket policies also while reading permissions for an…
Browse files Browse the repository at this point in the history
… object that is non-existent.

Fixes http://tracker.ceph.com/issues/38638

Signed-off-by: Pritha Srivastava <prsrivas@redhat.com>
(cherry picked from commit 5eb50b7)

 Conflicts:
	src/rgw/rgw_op.cc
	  bucket_policy.verify_permission has slightly different arguments
  • Loading branch information
pritha-srivastava authored and Dave Holland committed Jul 23, 2019
1 parent 9fd889f commit a752b21
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/rgw/rgw_op.cc
Expand Up @@ -376,13 +376,20 @@ static int read_obj_policy(RGWRados *store,
if (ret < 0) {
return ret;
}

const rgw_user& bucket_owner = bucket_policy.get_owner().get_id();
if (bucket_owner.compare(s->user->user_id) != 0 &&
! s->auth.identity->is_admin_of(bucket_owner) &&
! bucket_policy.verify_permission(*s->auth.identity, s->perm_mask,
RGW_PERM_READ)) {
ret = -EACCES;
! s->auth.identity->is_admin_of(bucket_owner)) {
if (policy) {
auto r = policy->eval(s->env, *s->auth.identity, rgw::IAM::s3ListBucket, ARN(bucket));
if (r == Effect::Allow)
return -ENOENT;
if (r == Effect::Deny)
return -EACCES;
}
if (! bucket_policy.verify_permission(*s->auth.identity, s->perm_mask, RGW_PERM_READ))
ret = -EACCES;
else
ret = -ENOENT;
} else {
ret = -ENOENT;
}
Expand Down

0 comments on commit a752b21

Please sign in to comment.