From fdc1c255dd765c5ec7d504c0c35a1ee3e3918bf7 Mon Sep 17 00:00:00 2001 From: Matt Benjamin Date: Thu, 10 Jan 2019 18:05:23 -0500 Subject: [PATCH] rgw: lifcycle: don't reject compound rules with empty prefix A rule containing a tag filter but no constraining prefix is legal, as is a sequence of >1 such rules. Signed-off-by: Matt Benjamin --- src/rgw/rgw_lc.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/rgw/rgw_lc.cc b/src/rgw/rgw_lc.cc index fe056655e2a..d4b558dbcf6 100644 --- a/src/rgw/rgw_lc.cc +++ b/src/rgw/rgw_lc.cc @@ -90,8 +90,14 @@ bool RGWLifecycleConfiguration::_add_rule(LCRule *rule) if (rule->get_filter().has_tags()){ op.obj_tags = rule->get_filter().get_tags(); } - auto ret = prefix_map.emplace(std::move(prefix), std::move(op)); - return ret.second; + + /* prefix is optional, update prefix map only if prefix...exists */ + if (!prefix.empty()) { + auto ret = prefix_map.emplace(std::move(prefix), std::move(op)); + return ret.second; + } + + return true; } int RGWLifecycleConfiguration::check_and_add_rule(LCRule *rule) -- 2.39.5