From: Pritha Srivastava Date: Thu, 17 May 2018 08:07:08 +0000 (+0530) Subject: rgw: Fixing error codes while user policy is parsed. X-Git-Tag: v14.0.1~335^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=0e9b192f9d83430b46cf772bcd72444d813476ed;p=ceph.git rgw: Fixing error codes while user policy is parsed. Signed-off-by: Pritha Srivastava --- diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index 73868467b8fa..e05af0d3e9b4 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -561,14 +561,20 @@ int rgw_build_bucket_policies(RGWRados* store, struct req_state* s) } } - try { - map 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 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 {