]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: add detailed error message for PutACLs 30385/head
authorEnming Zhang <zvampirem77@gmail.com>
Sat, 14 Sep 2019 09:31:20 +0000 (02:31 -0700)
committerEnming Zhang <zvampirem77@gmail.com>
Wed, 18 Sep 2019 07:52:16 +0000 (00:52 -0700)
Keep the error messages same with AWS S3

Signed-off-by: Enming Zhang <zvampirem77@gmail.com>
src/rgw/rgw_acl_s3.cc
src/rgw/rgw_acl_s3.h
src/rgw/rgw_op.cc

index 4ee67c879455035d12d6a1f22309630ac1b7941e..fb1383c4f4e9ad11146b6d038b0fa7a0293a9a2d 100644 (file)
@@ -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;
         }
       }
index df2e11ffe476a1a14c6b8121469b1d0feacf0ac3..7d6af264154c579d7ff5c58ac212e164bef35d97 100644 (file)
@@ -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) {
index cb96094f92a99fb5640a3a05c19f0994ce239dcb..b4f957bc28cb79f2c941ad280feabb20ea8524b9 100644 (file)
@@ -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;