From 79669c4b064b793f02573f74b3360649d3170da4 Mon Sep 17 00:00:00 2001 From: David Zafman Date: Thu, 7 Apr 2016 12:44:25 -0700 Subject: [PATCH] rados, test: Restrict usage of --prefix in cleanup As a precaution to using cleanup for mass deletion of other objects, only allow --prefix which begins with "benchmark_data." Signed-off-by: David Zafman --- qa/workunits/rados/test_rados_tool.sh | 5 +++++ src/common/obj_bencher.cc | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/qa/workunits/rados/test_rados_tool.sh b/qa/workunits/rados/test_rados_tool.sh index 61bcfbf8e0cce..92b81a09f4098 100755 --- a/qa/workunits/rados/test_rados_tool.sh +++ b/qa/workunits/rados/test_rados_tool.sh @@ -418,6 +418,11 @@ test_cleanup() { die "Different objects found after cleanup" fi + set +e + run_expect_fail $RADOS_TOOL -p $p cleanup --prefix illegal_prefix + run_expect_succ $RADOS_TOOL -p $p cleanup --prefix benchmark_data_otherhost + set -e + $RADOS_TOOL rmpool $p $p --yes-i-really-really-mean-it } diff --git a/src/common/obj_bencher.cc b/src/common/obj_bencher.cc index 443a98a920a61..6cb1e1e20bad7 100644 --- a/src/common/obj_bencher.cc +++ b/src/common/obj_bencher.cc @@ -1089,6 +1089,11 @@ int ObjBencher::clean_up(const std::string& orig_prefix, int concurrentios, cons const std::string run_name_meta = (run_name.empty() ? BENCH_LASTRUN_METADATA : run_name); const std::string prefix = (orig_prefix.empty() ? generate_object_prefix_nopid() : orig_prefix); + if (prefix.substr(0, BENCH_PREFIX.length()) != BENCH_PREFIX) { + cerr << "Specified --prefix invalid, it must begin with \"" << BENCH_PREFIX << "\"" << std::endl; + return -EINVAL; + } + std::list unfiltered_objects; std::set meta_namespaces, all_namespaces; -- 2.39.5