From: David Zafman Date: Thu, 7 Apr 2016 19:44:25 +0000 (-0700) Subject: rados, test: Restrict usage of --prefix in cleanup X-Git-Tag: v11.0.0~685 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=79669c4b064b793f02573f74b3360649d3170da4;p=ceph.git 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 --- diff --git a/qa/workunits/rados/test_rados_tool.sh b/qa/workunits/rados/test_rados_tool.sh index 61bcfbf8e0cc..92b81a09f409 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 443a98a920a6..6cb1e1e20bad 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;