]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw/acl/swift: format_container_acls() as free function
authorCasey Bodley <cbodley@redhat.com>
Thu, 16 Nov 2023 18:33:30 +0000 (13:33 -0500)
committerCasey Bodley <cbodley@redhat.com>
Thu, 30 Nov 2023 15:40:45 +0000 (10:40 -0500)
Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/rgw/rgw_acl_swift.cc
src/rgw/rgw_acl_swift.h
src/rgw/rgw_rest_swift.cc

index 4bf0ba9251774ad91c99ffc5185f2bc62c8a9e12..e948e859162bfd5967f5d94d3d3dc0fe3ce1e6eb 100644 (file)
@@ -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<string, ACLGrant>& m = acl.get_grant_map();
-  multimap<string, ACLGrant>::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<std::string>& uids,
index bf983ba2b8c277331dde78c891c2940aa0f2297c..8bc70eac7b0ef0263776531287bd242753713a53 100644 (file)
@@ -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
index b486042e00f855bcfecbe246417b9e0f5452e542..930156d4b5127933b4954af04b8fa15e00b046fe 100644 (file)
@@ -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<RGWAccessControlPolicy_SWIFT*>(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);