From: Radoslaw Zarzynski Date: Fri, 23 Jun 2017 14:28:41 +0000 (-0400) Subject: rgw: omit X-Account-Access-Control if there is no grant to serialize. X-Git-Tag: v12.1.2~1^2~9^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d4afae826ec4c71a613c902e94ecca15d56e9c57;p=ceph.git rgw: omit X-Account-Access-Control if there is no grant to serialize. Fixes: http://tracker.ceph.com/issues/20395 Signed-off-by: Radoslaw Zarzynski --- diff --git a/src/rgw/rgw_acl_swift.cc b/src/rgw/rgw_acl_swift.cc index 15fec030534..71f32a69528 100644 --- a/src/rgw/rgw_acl_swift.cc +++ b/src/rgw/rgw_acl_swift.cc @@ -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 RGWAccessControlPolicy_SWIFTAcct::to_str() const { std::vector admin; std::vector 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(); } diff --git a/src/rgw/rgw_acl_swift.h b/src/rgw/rgw_acl_swift.h index 883b623af18..87bdb608f4e 100644 --- a/src/rgw/rgw_acl_swift.h +++ b/src/rgw/rgw_acl_swift.h @@ -9,6 +9,8 @@ #include #include +#include + #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 to_str() const; }; #endif diff --git a/src/rgw/rgw_rest_swift.cc b/src/rgw/rgw_rest_swift.cc index a3ccdca781a..db6d3872cc8 100644 --- a/src/rgw/rgw_rest_swift.cc +++ b/src/rgw/rgw_rest_swift.cc @@ -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)); } }