X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/f19d6a77f60b876e5453614d24886aabdd242ef6..5a23c56d6852a27d45c2ae227b43060f7beac051:/test/integration/test-apt-update-nofallback diff --git a/test/integration/test-apt-update-nofallback b/test/integration/test-apt-update-nofallback index dae537c32..c8a008214 100755 --- a/test/integration/test-apt-update-nofallback +++ b/test/integration/test-apt-update-nofallback @@ -9,14 +9,13 @@ set -e simulate_mitm_and_inject_evil_package() { redatereleasefiles '+1 hour' - rm -f $APTARCHIVE/dists/unstable/InRelease - rm -f $APTARCHIVE/dists/unstable/Release.gpg + rm -f "$APTARCHIVE/dists/unstable/InRelease" "$APTARCHIVE/dists/unstable/Release.gpg" inject_evil_package } inject_evil_package() { - cat > $APTARCHIVE/dists/unstable/main/binary-i386/Packages < "$APTARCHIVE/dists/unstable/main/binary-i386/Packages" < @@ -33,24 +32,22 @@ EOF assert_update_is_refused_and_last_good_state_used() { - testfailuremsg "E: The repository 'file:${APTARCHIVE} unstable Release' is no longer signed." aptget update + testfailuremsg "E: The repository 'file:${APTARCHIVE} unstable Release' is no longer signed. +N: Updating from such a repository can't be done securely, and is therefore disabled by default. +N: See apt-secure(8) manpage for repository creation and user configuration details." aptget update assert_repo_is_intact } assert_repo_is_intact() { - testsuccessequal "foo/unstable 2.0 all" apt list -q + testsuccessequal "foo/unstable 2.0 all" apt list -qq testsuccess aptget install -y -s foo testfailure aptget install -y evil testsuccess aptget source foo --print-uris LISTDIR=rootdir/var/lib/apt/lists - if ! ( ls $LISTDIR/*InRelease >/dev/null 2>&1 || - ls $LISTDIR/*Release.gpg >/dev/null 2>&1 ); then - echo "Can not find InRelease/Release.gpg in $(ls $LISTDIR)" - msgfail - fi + testempty find "$LISTDIR" -name 'InRelease' -o -name 'Release.gpg' } setupaptarchive_with_lists_clean() @@ -61,7 +58,7 @@ setupaptarchive_with_lists_clean() test_from_inrelease_to_unsigned() { - # setup archive with InRelease file + export APT_DONT_SIGN='Release.gpg' setupaptarchive_with_lists_clean testsuccess aptget update listcurrentlistsdirectory > lists.before @@ -73,9 +70,8 @@ test_from_inrelease_to_unsigned() test_from_release_gpg_to_unsigned() { - # setup archive with Release/Release.gpg (but no InRelease) + export APT_DONT_SIGN='InRelease' setupaptarchive_with_lists_clean - rm $APTARCHIVE/dists/unstable/InRelease testsuccess aptget update listcurrentlistsdirectory > lists.before @@ -86,6 +82,7 @@ test_from_release_gpg_to_unsigned() test_from_inrelease_to_unsigned_with_override() { + export APT_DONT_SIGN='Release.gpg' # setup archive with InRelease file setupaptarchive_with_lists_clean testsuccess aptget update @@ -93,7 +90,7 @@ test_from_inrelease_to_unsigned_with_override() # simulate moving to a unsigned but otherwise valid repo simulate_mitm_and_inject_evil_package generatereleasefiles '+2 hours' - find $APTARCHIVE -name '*Packages*' -exec touch -d '+2 hours' {} \; + find "$APTARCHIVE" -name '*Packages*' -exec touch -d '+2 hours' {} \; # and ensure we can update to it (with enough force) testwarning aptget update --allow-insecure-repositories \ @@ -122,17 +119,16 @@ test_cve_2012_0214() # # Still worth having a regression test the simulates the condition - # setup archive with InRelease + export APT_DONT_SIGN='Release.gpg' setupaptarchive_with_lists_clean testsuccess aptget update listcurrentlistsdirectory > lists.before # do what CVE-2012-0214 did - rm $APTARCHIVE/dists/unstable/InRelease - rm $APTARCHIVE/dists/unstable/Release.gpg + rm -f "$APTARCHIVE/dists/unstable/InRelease" "$APTARCHIVE/dists/unstable/Release.gpg" inject_evil_package # build valid Release file - aptftparchive -qq release ./aptarchive > aptarchive/dists/unstable/Release + aptftparchive -qq release ./aptarchive > aptarchive/dists/unstable/Release assert_update_is_refused_and_last_good_state_used testfileequal lists.before "$(listcurrentlistsdirectory)" @@ -143,15 +139,15 @@ test_cve_2012_0214() test_subvert_inrelease() { - # setup archive with InRelease + export APT_DONT_SIGN='Release.gpg' setupaptarchive_with_lists_clean testsuccess aptget update listcurrentlistsdirectory > lists.before # replace InRelease with something else - mv $APTARCHIVE/dists/unstable/Release $APTARCHIVE/dists/unstable/InRelease + mv "$APTARCHIVE/dists/unstable/Release" "$APTARCHIVE/dists/unstable/InRelease" - testfailuremsg "W: Failed to fetch file:${APTARCHIVE}/dists/unstable/InRelease Clearsigned file isn't valid, got 'NOSPLIT' (does the network require authentication?) + testfailuremsg "E: Failed to fetch file:${APTARCHIVE}/dists/unstable/InRelease Clearsigned file isn't valid, got 'NOSPLIT' (does the network require authentication?) E: Some index files failed to download. They have been ignored, or old ones used instead." aptget update # ensure we keep the repo @@ -161,13 +157,13 @@ E: Some index files failed to download. They have been ignored, or old ones used test_inrelease_to_invalid_inrelease() { - # setup archive with InRelease + export APT_DONT_SIGN='Release.gpg' setupaptarchive_with_lists_clean testsuccess aptget update listcurrentlistsdirectory > lists.before # now remove InRelease and subvert Release do no longer verify - sed -i 's/^Codename:.*/Codename: evil!/' $APTARCHIVE/dists/unstable/InRelease + sed -i 's/^Codename:.*/Codename: evil!/' "$APTARCHIVE/dists/unstable/InRelease" inject_evil_package testwarningequal "W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: file:${APTARCHIVE} unstable InRelease: The following signatures were invalid: BADSIG 5A90D141DBAC8DAE Joe Sixpack (APT Testcases Dummy) @@ -182,14 +178,13 @@ W: Some index files failed to download. They have been ignored, or old ones used test_release_gpg_to_invalid_release_release_gpg() { - # setup archive with InRelease + export APT_DONT_SIGN='InRelease' setupaptarchive_with_lists_clean - rm $APTARCHIVE/dists/unstable/InRelease testsuccess aptget update listcurrentlistsdirectory > lists.before # now subvert Release do no longer verify - echo "Some evil data" >> $APTARCHIVE/dists/unstable/Release + echo "Some evil data" >> "$APTARCHIVE/dists/unstable/Release" inject_evil_package testwarningequal "W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: file:${APTARCHIVE} unstable Release: The following signatures were invalid: BADSIG 5A90D141DBAC8DAE Joe Sixpack (APT Testcases Dummy) @@ -202,8 +197,8 @@ W: Some index files failed to download. They have been ignored, or old ones used } -TESTDIR=$(readlink -f $(dirname $0)) -. $TESTDIR/framework +TESTDIR="$(readlink -f "$(dirname "$0")")" +. "$TESTDIR/framework" setupenvironment configarchitecture "i386" @@ -213,7 +208,7 @@ buildsimplenativepackage 'foo' 'all' '2.0' # setup the archive and ensure we have a single package that installs fine setupaptarchive -APTARCHIVE=$(readlink -f ./aptarchive) +APTARCHIVE="$(readlink -f ./aptarchive)" assert_repo_is_intact # test the various cases where a repo may go from signed->unsigned @@ -227,7 +222,7 @@ test_from_release_gpg_to_unsigned msgmsg "test_cve_2012_0214" test_cve_2012_0214 -# ensure InRelase can not be subverted +# ensure InRelease can not be subverted msgmsg "test_subvert_inrelease" test_subvert_inrelease