]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rados, test: Restrict usage of --prefix in cleanup
authorDavid Zafman <dzafman@redhat.com>
Thu, 7 Apr 2016 19:44:25 +0000 (12:44 -0700)
committerBoris Ranto <branto@redhat.com>
Fri, 6 May 2016 11:44:16 +0000 (13:44 +0200)
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>
qa/workunits/rados/test_rados_tool.sh
src/common/obj_bencher.cc

index 61bcfbf8e0cce4063fc9c6a85071af5166b1512d..92b81a09f40980ce5e6bf940d4c7d1da534b49cc 100755 (executable)
@@ -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
 }
 
index 443a98a920a610770eb9f7ed1ad2622583042169..6cb1e1e20bad7ee90348a43789bf892582e3d4e5 100644 (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;