From a05f5f1827e35fb51f62f0cc4e7cc9c6b7ae87ee Mon Sep 17 00:00:00 2001 From: Shunsuke Kimura Date: Fri, 28 Mar 2025 17:14:14 +0900 Subject: [PATCH] kata-deploy: add INSTALLATION_PREFIX validation INSTALLATION_PREFIX must begin with a "/" because it is being concatenated with /host. If there is no /, displays a message and makes an error. Fixes: #11096 Signed-off-by: Shunsuke Kimura --- tools/packaging/kata-deploy/scripts/kata-deploy.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/packaging/kata-deploy/scripts/kata-deploy.sh b/tools/packaging/kata-deploy/scripts/kata-deploy.sh index 7352f6b6d..75d9709a7 100755 --- a/tools/packaging/kata-deploy/scripts/kata-deploy.sh +++ b/tools/packaging/kata-deploy/scripts/kata-deploy.sh @@ -66,6 +66,9 @@ INSTALLATION_PREFIX="${INSTALLATION_PREFIX:-}" default_dest_dir="/opt/kata" dest_dir="${default_dest_dir}" if [ -n "${INSTALLATION_PREFIX}" ]; then + if [[ "${INSTALLATION_PREFIX:0:1}" != "/" ]]; then + die 'INSTALLATION_PREFIX must begin with a "/"(ex. /hoge/fuga)' + fi # There's no `/` in between ${INSTALLATION_PREFIX} and ${default_dest_dir} # as, otherwise, we'd have it doubled there, as: `/foo/bar//opt/kata` dest_dir="${INSTALLATION_PREFIX}${default_dest_dir}"