From: Casey Bodley Date: Thu, 16 Nov 2023 18:33:30 +0000 (-0500) Subject: rgw/acl/swift: format_container_acls() as free function X-Git-Tag: v19.0.0~9^2~13 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ade871e280cdfe0057e8f0b1f6ab0b3d152cc1f2;p=ceph.git rgw/acl/swift: format_container_acls() as free function Signed-off-by: Casey Bodley --- diff --git a/src/rgw/rgw_acl_swift.cc b/src/rgw/rgw_acl_swift.cc index 4bf0ba925177..e948e859162b 100644 --- a/src/rgw/rgw_acl_swift.cc +++ b/src/rgw/rgw_acl_swift.cc @@ -226,15 +226,10 @@ void merge_policy(uint32_t rw_mask, const RGWAccessControlPolicy& src, } } -} // namespace rgw::swift - -void RGWAccessControlPolicy_SWIFT::to_str(string& read, string& write) +void format_container_acls(const RGWAccessControlPolicy& policy, + std::string& read, std::string& write) { - multimap& m = acl.get_grant_map(); - multimap::iterator iter; - - for (iter = m.begin(); iter != m.end(); ++iter) { - ACLGrant& grant = iter->second; + for (const auto& [k, grant] : policy.get_acl().get_grant_map()) { const uint32_t perm = grant.get_permission().get_permissions(); rgw_user id; string url_spec; @@ -269,6 +264,8 @@ void RGWAccessControlPolicy_SWIFT::to_str(string& read, string& write) } } +} // namespace rgw::swift + void RGWAccessControlPolicy_SWIFTAcct::add_grants(const DoutPrefixProvider *dpp, rgw::sal::Driver* driver, const std::vector& uids, diff --git a/src/rgw/rgw_acl_swift.h b/src/rgw/rgw_acl_swift.h index bf983ba2b8c2..8bc70eac7b0e 100644 --- a/src/rgw/rgw_acl_swift.h +++ b/src/rgw/rgw_acl_swift.h @@ -32,12 +32,14 @@ int create_container_policy(const DoutPrefixProvider *dpp, void merge_policy(uint32_t rw_mask, const RGWAccessControlPolicy& src, RGWAccessControlPolicy& dest); +/// Format the policy in terms of X-Container-Read/X-Container-Write strings. +void format_container_acls(const RGWAccessControlPolicy& policy, + std::string& read, std::string& write); + } // namespace rgw::swift class RGWAccessControlPolicy_SWIFT : public RGWAccessControlPolicy { -public: - void to_str(std::string& read, std::string& write); }; class RGWAccessControlPolicy_SWIFTAcct : public RGWAccessControlPolicy diff --git a/src/rgw/rgw_rest_swift.cc b/src/rgw/rgw_rest_swift.cc index b486042e00f8..930156d4b512 100644 --- a/src/rgw/rgw_rest_swift.cc +++ b/src/rgw/rgw_rest_swift.cc @@ -470,10 +470,8 @@ static void dump_container_metadata(req_state *s, } if (rgw::sal::Object::empty(s->object.get())) { - auto swift_policy = \ - static_cast(s->bucket_acl.get()); std::string read_acl, write_acl; - swift_policy->to_str(read_acl, write_acl); + rgw::swift::format_container_acls(*s->bucket_acl, read_acl, write_acl); if (read_acl.size()) { dump_header(s, "X-Container-Read", read_acl);