From fccae8dccf142d864dc557dfa1b1763af2d0249b Mon Sep 17 00:00:00 2001 From: Nizamudeen A Date: Tue, 5 Nov 2024 19:16:01 +0530 Subject: [PATCH] start-ceph: do rm -rf only when path exists start-ceph has a line to remove `rm -rf "$CEPH_CONF_PATH"/*` If someone run this script locally when he has root previllages, he could accidentally remove his `/` directory because `CEPH_CONF_PATH` will come empty and the command will become `rm -rf /*` which is like shooting yourself infinitely.. Signed-off-by: Nizamudeen A --- docker/ceph/ci/sanity-checks.sh | 5 ++++- docker/ceph/start-ceph.sh | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/docker/ceph/ci/sanity-checks.sh b/docker/ceph/ci/sanity-checks.sh index e4422090dd1..128ada783f3 100755 --- a/docker/ceph/ci/sanity-checks.sh +++ b/docker/ceph/ci/sanity-checks.sh @@ -191,7 +191,10 @@ setup_api_tests_env() { cd "$REPO_DIR"/build - rm -rf "$CEPH_CONF_PATH"/* + # if CEPH_CONF_PATH exists then remove that folder and everything in it + if [[ -d "$CEPH_CONF_PATH" ]]; then + rm -rf "$CEPH_CONF_PATH"/* + fi rm -f vstart_runner.log # vstart_runner uses /ceph/build cluster path. diff --git a/docker/ceph/start-ceph.sh b/docker/ceph/start-ceph.sh index accb8058ef2..d0a5d0fbf32 100755 --- a/docker/ceph/start-ceph.sh +++ b/docker/ceph/start-ceph.sh @@ -45,7 +45,10 @@ if [[ -n "${DASHBOARD_URL}" ]]; then exit 0 fi -rm -rf "$CEPH_CONF_PATH"/* +# if CEPH_CONF_PATH exists then remove that folder and everything in it +if [[ -d "$CEPH_CONF_PATH" ]]; then + rm -rf "$CEPH_CONF_PATH"/* +fi cd /ceph/build ../src/vstart.sh ${VSTART_OPTIONS}