]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw_rest_user_policy: [55603] Fix Get & List User Policy responses 47235/head
authorSumedh A. Kulkarni <sumedh.a.kulkarni@seagate.com>
Thu, 28 Apr 2022 06:39:44 +0000 (00:39 -0600)
committerCory Snyder <csnyder@iland.com>
Fri, 22 Jul 2022 08:22:09 +0000 (04:22 -0400)
GetUserPolicy & ListUserPolicies responses has few mistakes/typos if compared
with aws documentation of the API's.
While using `aws iam` cli the mistakes in the response schema causes the
blank/incorrect response output.
Correcting the same with the patch.

Fixes: https://tracker.ceph.com/issues/55603
Signed-off-by: Sumedh A. Kulkarni <sumedh.a.kulkarni@seagate.com>
(cherry picked from commit 4b8c66a074f3491129e1864388f980b812f47752)

Conflicts:
src/rgw/rgw_rest_user_policy.cc

Cherry-pick notes:
- Conflict due to try/catch block in RGWListUserPolicies::execute not present in Quincy

src/rgw/rgw_rest_user_policy.cc

index a552f3b2b2a2ed4d2d38ddf5b165ee5757bc8694..f6c7d2314dc09fb4f013cf340fd6eb8cd8c3c553 100644 (file)
@@ -25,9 +25,9 @@ using rgw::IAM::Policy;
 
 void RGWRestUserPolicy::dump(Formatter *f) const
 {
-  encode_json("Policyname", policy_name , f);
-  encode_json("Username", user_name , f);
-  encode_json("Policydocument", policy, f);
+  encode_json("PolicyName", policy_name , f);
+  encode_json("UserName", user_name , f);
+  encode_json("PolicyDocument", policy, f);
 }
 
 void RGWRestUserPolicy::send_response()
@@ -276,14 +276,20 @@ void RGWListUserPolicies::execute(optional_yield y)
       s->formatter->close_section();
       s->formatter->open_object_section("ListUserPoliciesResult");
       bufferlist bl = it->second;
-      decode(policies, bl);
+      try {
+        decode(policies, bl);
+      } catch (buffer::error& err) {
+        ldpp_dout(this, 0) << "ERROR: failed to decode user policies" << dendl;
+        op_ret = -EIO;
+        return;
+      }
+      s->formatter->open_object_section("PolicyNames");
       for (const auto& p : policies) {
-        s->formatter->open_object_section("PolicyNames");
         s->formatter->dump_string("member", p.first);
-        s->formatter->close_section();
       }
       s->formatter->close_section();
       s->formatter->close_section();
+      s->formatter->close_section();
     } else {
       ldpp_dout(this, 0) << "ERROR: RGW_ATTR_USER_POLICY not found" << dendl;
       op_ret = -ERR_NO_SUCH_ENTITY;