From 5db5c9f8bec17cc9e7991db2404e47a33ca67e5b Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Thu, 12 May 2016 15:13:06 -0400 Subject: [PATCH] rgw: RGWZoneGroup::add_zone rejects duplicate zone names Fixes: http://tracker.ceph.com/issues/15613 Signed-off-by: Casey Bodley --- src/rgw/rgw_rados.cc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 7121045c36476..b6884930d32f3 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -238,6 +238,20 @@ int RGWZoneGroup::equals(const string& other_zonegroup) const int RGWZoneGroup::add_zone(const RGWZoneParams& zone_params, bool *is_master, bool *read_only, const list& endpoints) { + auto& zone_id = zone_params.get_id(); + auto& zone_name = zone_params.get_name(); + + // check for duplicate zone name on insert + if (!zones.count(zone_id)) { + for (const auto& zone : zones) { + if (zone.second.name == zone_name) { + ldout(cct, 0) << "ERROR: found existing zone name " << zone_name + << " (" << zone.first << ") in zonegroup " << get_name() << dendl; + return -EEXIST; + } + } + } + if (is_master && *is_master) { if (!master_zone.empty() && master_zone != zone_params.get_id()) { ldout(cct, 0) << "NOTICE: overriding master zone: " << master_zone << dendl; -- 2.39.5