From 6f0017161f76ffecd1ee489bcb33462729ad96e6 Mon Sep 17 00:00:00 2001 From: Euan Harris Date: Wed, 10 Jul 2013 16:30:31 +0100 Subject: [PATCH] xenapi: Exit immediately if zipball download fails If install_os_domU.sh fails to download the Xapi plugins zipball correctly it ignores the error and continues the installation. This could damage the hypervisor's filesystem, as it may delete files or overwrite them with garbage. Change-Id: I9f6dc31b977592e2818e37b2d310c2a5dc477364 Fixes: bug #1195640 --- tools/xen/functions | 4 ++-- tools/xen/mocks | 3 +++ tools/xen/test_functions.sh | 9 +++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/tools/xen/functions b/tools/xen/functions index 4e37554f4d..e5a7531a41 100644 --- a/tools/xen/functions +++ b/tools/xen/functions @@ -40,11 +40,11 @@ function extract_remote_zipball { local LOCAL_ZIPBALL=$(mktemp) local EXTRACTED_FILES=$(mktemp -d) - ( + { wget -nv $ZIPBALL_URL -O $LOCAL_ZIPBALL --no-check-certificate unzip -q -o $LOCAL_ZIPBALL -d $EXTRACTED_FILES rm -f $LOCAL_ZIPBALL - ) >&2 + } >&2 echo "$EXTRACTED_FILES" } diff --git a/tools/xen/mocks b/tools/xen/mocks index 6da6acbba7..94b0ca4d02 100644 --- a/tools/xen/mocks +++ b/tools/xen/mocks @@ -34,6 +34,9 @@ function mktemp { } function wget { + if [[ $@ =~ "failurl" ]]; then + exit 1 + fi echo "wget $@" >> $LIST_OF_ACTIONS } diff --git a/tools/xen/test_functions.sh b/tools/xen/test_functions.sh index 410df5f8b7..534723833d 100755 --- a/tools/xen/test_functions.sh +++ b/tools/xen/test_functions.sh @@ -173,6 +173,15 @@ EOF [ "$RESULT" = "tempdir" ] } +function test_extract_remote_zipball_wget_fail { + set +e + + local IGNORE + IGNORE=$(. mocks && extract_remote_zipball "failurl") + + assert_previous_command_failed +} + function test_find_nova_plugins { local tmpdir=$(mktemp -d)