X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/dbf8fc0419831c83e83165de8c434782165aa400..e8fb1cdfdd13e45f2b3abbd57a28b57ae6137f14:/test/integration/test-releasefile-verification?ds=inline diff --git a/test/integration/test-releasefile-verification b/test/integration/test-releasefile-verification index a9f4b9775..363b7fe5b 100755 --- a/test/integration/test-releasefile-verification +++ b/test/integration/test-releasefile-verification @@ -11,23 +11,29 @@ buildaptarchive setupflataptarchive changetowebserver +webserverconfig 'aptwebserver::support::range' 'false' + prepare() { local DATE="${2:-now}" - if [ "$DATE" = 'now' -a "$1" = "${PKGFILE}-new" ]; then - DATE='now + 6 days' + if [ "$DATE" = 'now' ]; then + if [ "$1" = "${PKGFILE}-new" ]; then + DATE='now - 1 day' + else + DATE='now - 7 day' + fi fi for release in $(find rootdir/var/lib/apt/lists 2> /dev/null); do - touch -d 'now - 6 hours' $release + touch -d 'now - 1 year' $release done aptget clean cp $1 aptarchive/Packages find aptarchive -name 'Release' -delete - compressfile 'aptarchive/Packages' + compressfile 'aptarchive/Packages' "$DATE" generatereleasefiles "$DATE" } installaptold() { - testequal 'Reading package lists... + testsuccessequal 'Reading package lists... Building dependency tree... Suggested packages: aptitude synaptic wajig dpkg-dev apt-doc bzip2 lzma python-apt @@ -40,7 +46,7 @@ Download complete and in download only mode' aptget install apt -dy } installaptnew() { - testequal 'Reading package lists... + testsuccessequal 'Reading package lists... Building dependency tree... Suggested packages: aptitude synaptic wajig dpkg-dev apt-doc bzip2 lzma python-apt @@ -53,7 +59,7 @@ Download complete and in download only mode' aptget install apt -dy } failaptold() { - testequal 'Reading package lists... + testfailureequal 'Reading package lists... Building dependency tree... Suggested packages: aptitude synaptic wajig dpkg-dev apt-doc bzip2 lzma python-apt @@ -67,7 +73,7 @@ E: There are problems and -y was used without --force-yes' aptget install apt -d } failaptnew() { - testequal 'Reading package lists... + testfailureequal 'Reading package lists... Building dependency tree... Suggested packages: aptitude synaptic wajig dpkg-dev apt-doc bzip2 lzma python-apt @@ -85,14 +91,35 @@ touch aptarchive/apt.deb PKGFILE="${TESTDIR}/$(echo "$(basename $0)" | sed 's#^test-#Packages-#')" +updatesuccess() { + local LOG='update.log' + if aptget update >$LOG 2>&1 || grep -q -E '^(W|E): ' $LOG; then + msgpass + else + cat $LOG + msgfail + fi +} + +updatefailure() { + local LOG='update.log' + aptget update >$LOG 2>&1 || true + if grep -q -E "$1" $LOG; then + msgpass + else + cat $LOG + msgfail + fi +} + runtest() { prepare ${PKGFILE} rm -rf rootdir/var/lib/apt/lists signreleasefiles 'Joe Sixpack' find aptarchive/ -name "$DELETEFILE" -delete msgtest 'Cold archive signed by' 'Joe Sixpack' - aptget update 2>&1 | grep -E '^(W|E): ' > /dev/null && msgfail || msgpass - testequal "$(cat ${PKGFILE}) + updatesuccess + testsuccessequal "$(cat ${PKGFILE}) " aptcache show apt installaptold @@ -100,8 +127,8 @@ runtest() { signreleasefiles 'Joe Sixpack' find aptarchive/ -name "$DELETEFILE" -delete msgtest 'Good warm archive signed by' 'Joe Sixpack' - aptget update 2>&1 | grep -E '^(W|E): ' > /dev/null && msgfail || msgpass - testequal "$(cat ${PKGFILE}-new) + updatesuccess + testsuccessequal "$(cat ${PKGFILE}-new) " aptcache show apt installaptnew @@ -111,8 +138,8 @@ runtest() { signreleasefiles 'Rex Expired' find aptarchive/ -name "$DELETEFILE" -delete msgtest 'Cold archive signed by' 'Rex Expired' - aptget update 2>&1 | grep -E '^W: .* KEYEXPIRED' > /dev/null && msgpass || msgfail - testequal "$(cat ${PKGFILE}) + updatefailure '^W: .* KEYEXPIRED' + testsuccessequal "$(cat ${PKGFILE}) " aptcache show apt failaptold rm rootdir/etc/apt/trusted.gpg.d/rexexpired.gpg @@ -122,8 +149,8 @@ runtest() { signreleasefiles 'Marvin Paranoid' find aptarchive/ -name "$DELETEFILE" -delete msgtest 'Cold archive signed by' 'Marvin Paranoid' - aptget update 2>&1 | grep -E '^W: .* NO_PUBKEY' > /dev/null && msgpass || msgfail - testequal "$(cat ${PKGFILE}) + updatefailure '^W: .* NO_PUBKEY' + testsuccessequal "$(cat ${PKGFILE}) " aptcache show apt failaptold @@ -136,8 +163,8 @@ runtest() { signreleasefiles 'Joe Sixpack' find aptarchive/ -name "$DELETEFILE" -delete msgtest 'Bad warm archive signed by' 'Joe Sixpack' - aptget update 2>&1 | grep -E '^(W|E): ' > /dev/null && msgfail || msgpass - testequal "$(cat ${PKGFILE}-new) + updatesuccess + testsuccessequal "$(cat ${PKGFILE}-new) " aptcache show apt installaptnew @@ -147,8 +174,8 @@ runtest() { signreleasefiles 'Joe Sixpack' find aptarchive/ -name "$DELETEFILE" -delete msgtest 'Cold archive signed by' 'Joe Sixpack' - aptget update 2>&1 | grep -E '^(W|E): ' > /dev/null && msgfail || msgpass - testequal "$(cat ${PKGFILE}) + updatesuccess + testsuccessequal "$(cat ${PKGFILE}) " aptcache show apt installaptold @@ -156,8 +183,8 @@ runtest() { signreleasefiles 'Marvin Paranoid' find aptarchive/ -name "$DELETEFILE" -delete msgtest 'Good warm archive signed by' 'Marvin Paranoid' - aptget update 2>&1 | grep -E '^W: .* NO_PUBKEY' > /dev/null && msgpass || msgfail - testequal "$(cat ${PKGFILE}) + updatefailure '^W: .* NO_PUBKEY' + testsuccessequal "$(cat ${PKGFILE}) " aptcache show apt installaptold @@ -166,8 +193,8 @@ runtest() { signreleasefiles 'Rex Expired' find aptarchive/ -name "$DELETEFILE" -delete msgtest 'Good warm archive signed by' 'Rex Expired' - aptget update 2>&1 | grep -E '^W: .* KEYEXPIRED' > /dev/null && msgpass || msgfail - testequal "$(cat ${PKGFILE}) + updatefailure '^W: .* KEYEXPIRED' + testsuccessequal "$(cat ${PKGFILE}) " aptcache show apt installaptold rm rootdir/etc/apt/trusted.gpg.d/rexexpired.gpg @@ -176,8 +203,8 @@ runtest() { signreleasefiles find aptarchive/ -name "$DELETEFILE" -delete msgtest 'Good warm archive signed by' 'Joe Sixpack' - aptget update 2>&1 | grep -E '^(W|E): ' > /dev/null && msgfail || msgpass - testequal "$(cat ${PKGFILE}-new) + updatesuccess + testsuccessequal "$(cat ${PKGFILE}-new) " aptcache show apt installaptnew } @@ -187,7 +214,7 @@ runtest2() { rm -rf rootdir/var/lib/apt/lists signreleasefiles 'Joe Sixpack' msgtest 'Cold archive signed by' 'Joe Sixpack' - aptget update 2>&1 | grep -E '^(W|E): ' > /dev/null && msgfail || msgpass + updatesuccess # New .deb but now an unsigned archive. For example MITM to circumvent # package verification. @@ -195,23 +222,34 @@ runtest2() { find aptarchive/ -name InRelease -delete find aptarchive/ -name Release.gpg -delete msgtest 'Warm archive signed by' 'nobody' - aptget update 2>&1 | grep -E '^(W|E): ' > /dev/null && msgfail || msgpass - testequal "$(cat ${PKGFILE}-new) + updatesuccess + testsuccessequal "$(cat ${PKGFILE}-new) " aptcache show apt failaptnew # Unsigned archive from the beginning must also be detected. rm -rf rootdir/var/lib/apt/lists msgtest 'Cold archive signed by' 'nobody' - aptget update 2>&1 | grep -E '^(W|E): ' > /dev/null && msgfail || msgpass - testequal "$(cat ${PKGFILE}-new) + updatesuccess + testsuccessequal "$(cat ${PKGFILE}-new) " aptcache show apt failaptnew } -runtest2 +# diable some protection by default and ensure we still do the verification +# correctly +cat > rootdir/etc/apt/apt.conf.d/weaken-security <