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 <dzafman@redhat.com>
This commit is contained in:
David Zafman 2016-04-07 12:44:25 -07:00 committed by Boris Ranto
parent 4e0b0d9a7e
commit 79669c4b06
2 changed files with 10 additions and 0 deletions

View File

@ -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
}

View File

@ -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<Object> unfiltered_objects;
std::set<std::string> meta_namespaces, all_namespaces;