From: yuliyang Date: Fri, 5 Nov 2021 07:40:44 +0000 (+0100) Subject: rgw: fix UploadPartCopy error code when src object not exist and src bucket not exist X-Git-Tag: v16.2.15~132^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=96b19a900e596304ea27b6e790ce77a16c442d5a;p=ceph.git rgw: fix UploadPartCopy error code when src object not exist and src bucket not exist fix https://tracker.ceph.com/issues/53181 Signed-off-by: yuliyang (cherry picked from commit 0804104ec01cd6acb57fd5c764bf1cfa47ff9a16) --- diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index e2d74d9cedd..1ecab3171d7 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -450,10 +450,10 @@ static int read_obj_policy(const DoutPrefixProvider *dpp, map& bucket_attrs, RGWAccessControlPolicy* acl, string *storage_class, - boost::optional& policy, + boost::optional& policy, rgw::sal::RGWBucket* bucket, rgw::sal::RGWObject* object, - optional_yield y, + optional_yield y, bool copy_src=false) { string upload_id; @@ -3578,6 +3578,9 @@ int RGWPutObj::init_processing(optional_yield y) { &bucket, y); if (ret < 0) { ldpp_dout(this, 5) << __func__ << "(): get_bucket() returned ret=" << ret << dendl; + if (ret == -ENOENT) { + ret = -ERR_NO_SUCH_BUCKET; + } return ret; } @@ -3645,9 +3648,9 @@ int RGWPutObj::verify_permission(optional_yield y) cs_object->set_prefetch_data(s->obj_ctx); /* check source object permissions */ - if (read_obj_policy(this, store, s, copy_source_bucket_info, cs_attrs, &cs_acl, nullptr, - policy, cs_bucket.get(), cs_object.get(), y, true) < 0) { - return -EACCES; + if (ret = read_obj_policy(this, store, s, copy_source_bucket_info, cs_attrs, &cs_acl, nullptr, + policy, cs_bucket.get(), cs_object.get(), y, true); ret < 0) { + return ret; } /* admin request overrides permission checks */