From 9f710a8c84a67a42765e3379a5543ac5f6322c8b Mon Sep 17 00:00:00 2001 From: Florent Rougon Date: Mon, 29 Jun 2020 16:04:23 +0200 Subject: [PATCH] download_and_compile.sh: add safety net in _cleanup() Make sure $INSTALL_DIR is really a harmless 'install' directory before calling 'rm -rf' on it. --- download_and_compile.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/download_and_compile.sh b/download_and_compile.sh index 17e82e0..463e43e 100755 --- a/download_and_compile.sh +++ b/download_and_compile.sh @@ -218,8 +218,14 @@ function _cleanup(){ fgdata_moved=1 fi - _printLog "Deleting install directories ($INSTALL_DIR)..." - rm -rf "$INSTALL_DIR" + if [[ "$(basename "$INSTALL_DIR")" -eq "install" ]]; then + _printLog "Deleting install directories ($INSTALL_DIR)..." + rm -rf "$INSTALL_DIR" + else + _printLog "${PROGNAME}: unexpected value for \$INSTALL_DIR: '$INSTALL_DIR'." + _printLog "Refusing to recursively delete it. Aborting; please report." + exit 1 + fi if [[ $fgdata_moved -eq 1 ]]; then mkdir -p "$INSTALL_DIR_FGFS"