Skip to content

Commit

Permalink
start-ceph: do rm -rf only when path exists
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
nizamial09 committed Nov 5, 2024
1 parent 1438cae commit fccae8d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion docker/ceph/ci/sanity-checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 4 additions & 1 deletion docker/ceph/start-ceph.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit fccae8d

Please sign in to comment.