From: Yehuda Sadeh Date: Wed, 31 Oct 2018 22:16:28 +0000 (-0700) Subject: rgw: check that placement rule is valid if bucket exists X-Git-Tag: v14.1.0~314^2~38 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=2a8e8a98d8c56cc374ec671846a20e2b0484bc75;p=ceph.git rgw: check that placement rule is valid if bucket exists Signed-off-by: Yehuda Sadeh --- diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index 30282babbf23..fea79e9cecfd 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -660,6 +660,11 @@ int rgw_build_bucket_policies(RGWRados* store, struct req_state* s) if (s->bucket_exists) { s->dest_placement.storage_class = s->info.storage_class; s->dest_placement.inherit_from(s->bucket_info.placement_rule); + + if (!store->svc.zone->get_zone_params().valid_placement(s->dest_placement)) { + ldpp_dout(s, 0) << "NOTICE: invalid dest placement: " << s->dest_placement.to_str() << dendl; + return -EINVAL; + } } } diff --git a/src/rgw/rgw_zone.h b/src/rgw/rgw_zone.h index adee749d6574..6f1bd64378a8 100644 --- a/src/rgw/rgw_zone.h +++ b/src/rgw/rgw_zone.h @@ -209,6 +209,9 @@ public: } bool exists(const string& sc) const { + if (sc.empty()) { + return true; + } auto iter = m.find(sc); return (iter != m.end()); } @@ -521,6 +524,14 @@ struct RGWZoneParams : RGWSystemMetaObj { } return true; } + + bool valid_placement(const rgw_placement_rule& rule) const { + auto iter = placement_pools.find(rule.name); + if (iter == placement_pools.end()) { + return false; + } + return iter->second.storage_class_exists(rule.storage_class); + } }; WRITE_CLASS_ENCODER(RGWZoneParams)