]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: omit X-Account-Access-Control if there is no grant to serialize. 15883/head
authorRadoslaw Zarzynski <rzarzyns@redhat.com>
Fri, 23 Jun 2017 14:28:41 +0000 (10:28 -0400)
committerRadoslaw Zarzynski <rzarzyns@redhat.com>
Fri, 23 Jun 2017 14:44:05 +0000 (10:44 -0400)
Fixes: http://tracker.ceph.com/issues/20395
Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
src/rgw/rgw_acl_swift.cc
src/rgw/rgw_acl_swift.h
src/rgw/rgw_rest_swift.cc

index 15fec03053479c20717ff5388e29fbe14d47e5a3..71f32a69528fb3921669a0085c1f47160111c9b2 100644 (file)
@@ -371,7 +371,7 @@ bool RGWAccessControlPolicy_SWIFTAcct::create(RGWRados * const store,
   return true;
 }
 
-void RGWAccessControlPolicy_SWIFTAcct::to_str(std::string& acl_str) const
+boost::optional<std::string> RGWAccessControlPolicy_SWIFTAcct::to_str() const
 {
   std::vector<std::string> admin;
   std::vector<std::string> readwrite;
@@ -403,6 +403,12 @@ void RGWAccessControlPolicy_SWIFTAcct::to_str(std::string& acl_str) const
     }
   }
 
+  /* If there is no grant to serialize, let's exit earlier to not return
+   * an empty JSON object which brakes the functional tests of Swift. */
+  if (admin.empty() && readwrite.empty() && readonly.empty()) {
+    return boost::none;
+  }
+
   /* Serialize the groups. */
   JSONFormatter formatter;
 
@@ -421,5 +427,5 @@ void RGWAccessControlPolicy_SWIFTAcct::to_str(std::string& acl_str) const
   std::ostringstream oss;
   formatter.flush(oss);
 
-  acl_str = oss.str();
+  return oss.str();
 }
index 883b623af182a1bc2e7ff1daa668dbcd6a00208a..87bdb608f4e2560eaee153469322394b24f50eb8 100644 (file)
@@ -9,6 +9,8 @@
 #include <string>
 #include <include/types.h>
 
+#include <boost/optional.hpp>
+
 #include "rgw_acl.h"
 
 class RGWAccessControlPolicy_SWIFT : public RGWAccessControlPolicy
@@ -48,6 +50,6 @@ public:
               const rgw_user& id,
               const std::string& name,
               const std::string& acl_str);
-  void to_str(std::string& acl) const;
+  boost::optional<std::string> to_str() const;
 };
 #endif
index a3ccdca781a634bb58c2fa1d7ed52ec1e9db3636..db6d3872cc806001b8f9dc0a606a036a3e641288 100644 (file)
@@ -130,10 +130,9 @@ static void dump_account_metadata(struct req_state * const s,
   }
 
   /* Dump account ACLs */
-  string acct_acl;
-  policy.to_str(acct_acl);
-  if (acct_acl.size()) {
-    dump_header(s, "X-Account-Access-Control", std::move(acct_acl));
+  auto account_acls = policy.to_str();
+  if (account_acls) {
+    dump_header(s, "X-Account-Access-Control", std::move(*account_acls));
   }
 }