From: cao.leilc Date: Sat, 30 Jan 2021 02:08:56 +0000 (+0800) Subject: rgw : add the check for bucket handler if http args exist object_exclusive sub_resource X-Git-Tag: v17.1.0~2742^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=52a59ad4348344f0fee2afe714b71e3dbb7f7b6b;p=ceph.git rgw : add the check for bucket handler if http args exist object_exclusive sub_resource Fixes: https://tracker.ceph.com/issues/48727 Signed-off-by: caolei --- diff --git a/src/rgw/rgw_common.cc b/src/rgw/rgw_common.cc index b657598dba6e..3e110c48c081 100644 --- a/src/rgw/rgw_common.cc +++ b/src/rgw/rgw_common.cc @@ -838,6 +838,7 @@ void RGWHTTPArgs::append(const string& name, const string& val) val_map[name] = val; } +// when sub_resources exclusive by object are added, please remember to update obj_sub_resource in RGWHTTPArgs::exist_obj_excl_sub_resource(). if ((name.compare("acl") == 0) || (name.compare("cors") == 0) || (name.compare("notification") == 0) || diff --git a/src/rgw/rgw_common.h b/src/rgw/rgw_common.h index dd62c3e254b6..691aa84e2d83 100644 --- a/src/rgw/rgw_common.h +++ b/src/rgw/rgw_common.h @@ -353,6 +353,15 @@ class RGWHTTPArgs { bool sub_resource_exists(const char *name) const { return (sub_resources.find(name) != std::end(sub_resources)); } + bool exist_obj_excl_sub_resource() const { + const char* const obj_sub_resource[] = {"append", "torrent", "uploadId", + "partNumber", "versionId"}; + for (int i = 0; i != std::size(obj_sub_resource); i++) { + if (sub_resource_exists(obj_sub_resource[i])) return true; + } + return false; + } + std::map& get_params() { return val_map; } diff --git a/src/rgw/rgw_rest_s3.cc b/src/rgw/rgw_rest_s3.cc index 5c1a2d941214..104190dde364 100644 --- a/src/rgw/rgw_rest_s3.cc +++ b/src/rgw/rgw_rest_s3.cc @@ -4878,10 +4878,12 @@ RGWHandler_REST* RGWRESTMgr_S3::get_handler(rgw::sal::RGWRadosStore *store, } else { if (s->init_state.url_bucket.empty()) { handler = new RGWHandler_REST_Service_S3(auth_registry, enable_sts, enable_iam, enable_pubsub); - } else if (rgw::sal::RGWObject::empty(s->object.get())) { - handler = new RGWHandler_REST_Bucket_S3(auth_registry, enable_pubsub); - } else { + } else if (!rgw::sal::RGWObject::empty(s->object.get())) { handler = new RGWHandler_REST_Obj_S3(auth_registry); + } else if (s->info.args.exist_obj_excl_sub_resource()) { + return NULL; + } else { + handler = new RGWHandler_REST_Bucket_S3(auth_registry, enable_pubsub); } }