From 79188d679edeb6e2f7ca852fdc4224368412cb72 Mon Sep 17 00:00:00 2001 From: "Adam C. Emerson" Date: Wed, 27 Sep 2017 16:08:56 -0400 Subject: [PATCH] rgw: Check bucket GetBucketLocation in policy Add code to check s3:GetBucketLocation against bucket policy. Fixes: http://tracker.ceph.com/issues/21582 Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1493934 Signed-off-by: Adam C. Emerson --- src/rgw/rgw_op.cc | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index 39a5dee9b7158..1cfd62530d048 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -2304,11 +2304,16 @@ int RGWGetBucketLogging::verify_permission() int RGWGetBucketLocation::verify_permission() { - if (false == s->auth.identity->is_owner_of(s->bucket_owner.get_id())) { - return -EACCES; + if (s->iam_policy) { + if (s->iam_policy->eval(s->env, *s->auth.identity, + rgw::IAM::s3GetBucketLocation, + ARN(s->bucket)) == Effect::Allow) { + return 0; + } + } else if (s->auth.identity->is_owner_of(s->bucket_owner.get_id())) { + return 0; } - - return 0; + return -EACCES; } int RGWCreateBucket::verify_permission() -- 2.39.5