From 58e37b4ab73ede930af39c4582b1661ddc495726 Mon Sep 17 00:00:00 2001 From: Claudiu Cristea Date: Tue, 6 Jul 2021 09:49:53 +0300 Subject: [PATCH] ISAICP-6567: Check that --snapshot dir is an absolute path. See the POSIX def https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html\#tag_03_02 --- scripts/solr/restore_solr.sh | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/scripts/solr/restore_solr.sh b/scripts/solr/restore_solr.sh index df279c0b7e..b078b6beca 100755 --- a/scripts/solr/restore_solr.sh +++ b/scripts/solr/restore_solr.sh @@ -57,27 +57,13 @@ if ! [[ $TIMEOUT =~ ${TIMEOUT_PATTERN} ]] ; then error "Timeout needs to be numeric!"; fi -if [ "${CORE}" == '' ] || [ "${SNAPSHOT_NAME}" == '' ]; then +if [ "${CORE}" == '' ] || [ "${SNAPSHOT_DIR}" == '' ] || [ "${SNAPSHOT_NAME}" == '' ]; then show_help; exit 1; fi -# Assume the current dir if no snapshot dir has been passed. -if [ "${SNAPSHOT_DIR}" == '' ]; then - SNAPSHOT_DIR=${CURRENT_DIR} -fi - -if [ ! -d "${SNAPSHOT_DIR}" ]; then - error "The '${SNAPSHOT_DIR}' directory doesn't exist!"; -fi - -# Normalize the snapshot dir to an absolute path. -cd ${SNAPSHOT_DIR} -SNAPSHOT_DIR=$(pwd) -cd ${CURRENT_DIR} - -if [ ! -d "${SNAPSHOT_DIR}/snapshot.${SNAPSHOT_NAME}" ]; then - error "The '${SNAPSHOT_DIR}' directory doesn't contain a '${SNAPSHOT_NAME}' snapshot!"; +if [ ! -z "${SNAPSHOT_DIR%%/*}" ] || ! pathchk -p "${SNAPSHOT_DIR}"; then + error "The --snapshot-dir path should be absolute!" fi CORE_EXISTS=`curl -sS "${SOLR_SERVER_URL}/admin/cores?action=STATUS&core=${CORE}&wt=xml" |grep -o ''`