]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
rgw: Fixing error codes while user policy is parsed.
authorPritha Srivastava <prsrivas@redhat.com>
Thu, 17 May 2018 08:07:08 +0000 (13:37 +0530)
committerPritha Srivastava <prsrivas@redhat.com>
Mon, 2 Jul 2018 10:12:07 +0000 (15:42 +0530)
Signed-off-by: Pritha Srivastava <prsrivas@redhat.com>
src/rgw/rgw_op.cc

index 73868467b8fae88b93ce38ba571789d59455afd1..e05af0d3e9b4233a725ed9159dc3823d67689f4c 100644 (file)
@@ -561,14 +561,20 @@ int rgw_build_bucket_policies(RGWRados* store, struct req_state* s)
     }
   }
 
-  try {
-    map<string, bufferlist> uattrs;
-    if (ret = rgw_get_user_attrs_by_uid(store, s->user->user_id, uattrs); ! ret) {
-      s->iam_user_policies = get_iam_user_policy_from_attr(s->cct, store, uattrs, s->user->user_id.tenant);
+  if (! s->user->user_id.empty()) {
+    try {
+      map<string, bufferlist> uattrs;
+      if (ret = rgw_get_user_attrs_by_uid(store, s->user->user_id, uattrs); ! ret) {
+        s->iam_user_policies = get_iam_user_policy_from_attr(s->cct, store, uattrs, s->user->user_id.tenant);
+      } else {
+        if (ret == -ENOENT)
+          ret = 0;
+        else ret = -EACCES;
+      }
+    } catch (const std::exception& e) {
+      lderr(s->cct) << "Error reading IAM User Policy: " << e.what() << dendl;
+      ret = -EACCES;
     }
-  } catch (const std::exception& e) {
-    lderr(s->cct) << "Error reading IAM User Policy: " << e.what() << dendl;
-    ret = -EACCES;
   }
 
   try {