]> git.saurik.com Git - apt.git/blame - test/integration/test-apt-update-stale
save and restore selection states before/after calling dpkg
[apt.git] / test / integration / test-apt-update-stale
CommitLineData
ca7fd76c
MV
1#!/bin/sh
2#
3# Ensure that a MITM can not stale the Packages/Sources without
4# raising a error message. Note that the Release file is protected
5# via the "Valid-Until" header
6#
7set -e
8
3abb6a6a
DK
9TESTDIR="$(readlink -f "$(dirname "$0")")"
10. "$TESTDIR/framework"
ca7fd76c
MV
11
12setupenvironment
13configarchitecture "i386"
14
1dd20368 15insertpackage 'unstable' 'foo' 'i386' '1.0'
ca7fd76c 16
081c9d44 17setupaptarchive --no-update
ca7fd76c 18changetowebserver
081c9d44
DK
19
20echo "Acquire::Languages \"none\";" > rootdir/etc/apt/apt.conf.d/00nolanguages
448c38bd 21testsuccess aptget update -o Debug::pkgAcquire::Worker=1 -o Debug::Acquire::http=1
846bc058 22listcurrentlistsdirectory > lists.before
ca7fd76c
MV
23
24# insert new version
25mkdir aptarchive/dists/unstable/main/binary-i386/saved
26cp -p aptarchive/dists/unstable/main/binary-i386/Packages* \
27 aptarchive/dists/unstable/main/binary-i386/saved
1dd20368 28insertpackage 'unstable' 'foo' 'i386' '2.0'
448c38bd 29touch -d '+1 hour' aptarchive/dists/unstable/main/binary-i386/Packages
846bc058 30compressfile aptarchive/dists/unstable/main/binary-i386/Packages
ca7fd76c 31# ensure that we do not get a I-M-S hit for the Release file
846bc058
DK
32
33generatereleasefiles '+1hour'
34signreleasefiles
ca7fd76c
MV
35
36# but now only deliver the previous Packages file instead of the new one
37# (simulating a stale attack)
38cp -p aptarchive/dists/unstable/main/binary-i386/saved/Packages* \
39 aptarchive/dists/unstable/main/binary-i386/
40
846bc058 41# ensure this raises an error
f695e761 42testfailuremsg "E: Failed to fetch http://localhost:${APTHTTPPORT}/dists/unstable/main/binary-i386/Packages.gz Hash Sum mismatch
448c38bd 43E: Some index files failed to download. They have been ignored, or old ones used instead." aptget update -o Debug::pkgAcquire::Worker=1 -o Debug::Acquire::http=1
846bc058 44testfileequal lists.before "$(listcurrentlistsdirectory)"