From: Enming Zhang Date: Sat, 14 Sep 2019 09:31:20 +0000 (-0700) Subject: rgw: add detailed error message for PutACLs X-Git-Tag: v15.1.0~895^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f749a702ce141fc0868f8f22fc9ed17d14cd0fe5;p=ceph.git rgw: add detailed error message for PutACLs Keep the error messages same with AWS S3 Signed-off-by: Enming Zhang --- diff --git a/src/rgw/rgw_acl_s3.cc b/src/rgw/rgw_acl_s3.cc index 4ee67c879455..fb1383c4f4e9 100644 --- a/src/rgw/rgw_acl_s3.cc +++ b/src/rgw/rgw_acl_s3.cc @@ -474,7 +474,8 @@ int RGWAccessControlPolicy_S3::create_from_headers(RGWUserCtl *user_ctl, const R /* can only be called on object that was parsed */ -int RGWAccessControlPolicy_S3::rebuild(RGWUserCtl *user_ctl, ACLOwner *owner, RGWAccessControlPolicy& dest) +int RGWAccessControlPolicy_S3::rebuild(RGWUserCtl *user_ctl, ACLOwner *owner, RGWAccessControlPolicy& dest, + std::string &err_msg) { if (!owner) return -EINVAL; @@ -489,6 +490,7 @@ int RGWAccessControlPolicy_S3::rebuild(RGWUserCtl *user_ctl, ACLOwner *owner, RG RGWUserInfo owner_info; if (user_ctl->get_info_by_uid(owner->get_id(), &owner_info, null_yield) < 0) { ldout(cct, 10) << "owner info does not exist" << dendl; + err_msg = "Invalid id"; return -EINVAL; } ACLOwner& dest_owner = dest.get_owner(); @@ -522,6 +524,7 @@ int RGWAccessControlPolicy_S3::rebuild(RGWUserCtl *user_ctl, ACLOwner *owner, RG ldout(cct, 10) << "grant user email=" << email << dendl; if (user_ctl->get_info_by_email(email, &grant_user, null_yield) < 0) { ldout(cct, 10) << "grant user email not found or other error" << dendl; + err_msg = "The e-mail address you provided does not match any account on record."; return -ERR_UNRESOLVABLE_EMAIL; } uid = grant_user.user_id; @@ -531,12 +534,14 @@ int RGWAccessControlPolicy_S3::rebuild(RGWUserCtl *user_ctl, ACLOwner *owner, RG if (type.get_type() == ACL_TYPE_CANON_USER) { if (!src_grant.get_id(uid)) { ldout(cct, 0) << "ERROR: src_grant.get_id() failed" << dendl; + err_msg = "Invalid id"; return -EINVAL; } } if (grant_user.user_id.empty() && user_ctl->get_info_by_uid(uid, &grant_user, null_yield) < 0) { ldout(cct, 10) << "grant user does not exist:" << uid << dendl; + err_msg = "Invalid id"; return -EINVAL; } else { ACLPermission& perm = src_grant.get_permission(); @@ -557,6 +562,7 @@ int RGWAccessControlPolicy_S3::rebuild(RGWUserCtl *user_ctl, ACLOwner *owner, RG ldout(cct, 10) << "new grant: " << uri << dendl; } else { ldout(cct, 10) << "bad grant group:" << (int)src_grant.get_group() << dendl; + err_msg = "Invalid group uri"; return -EINVAL; } } diff --git a/src/rgw/rgw_acl_s3.h b/src/rgw/rgw_acl_s3.h index df2e11ffe476..7d6af264154c 100644 --- a/src/rgw/rgw_acl_s3.h +++ b/src/rgw/rgw_acl_s3.h @@ -83,7 +83,8 @@ public: bool xml_end(const char *el) override; void to_xml(ostream& out); - int rebuild(RGWUserCtl *user_ctl, ACLOwner *owner, RGWAccessControlPolicy& dest); + int rebuild(RGWUserCtl *user_ctl, ACLOwner *owner, RGWAccessControlPolicy& dest, + std::string &err_msg); bool compare_group_name(string& id, ACLGroupTypeEnum group) override; virtual int create_canned(ACLOwner& _owner, ACLOwner& bucket_owner, const string& canned_acl) { diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index cb96094f92a9..b4f957bc28cb 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -5339,7 +5339,7 @@ void RGWPutACLs::execute() *_dout << dendl; } - op_ret = policy->rebuild(store->ctl()->user, &owner, new_policy); + op_ret = policy->rebuild(store->ctl()->user, &owner, new_policy, s->err.message); if (op_ret < 0) return;