]>
Commit | Line | Data |
---|---|---|
daff4aa3 MV |
1 | #!/bin/sh |
2 | # | |
3 | # Ensure that we do not modify file:/// uris (regression test for | |
4 | # CVE-2014-0487 | |
5 | # | |
6 | set -e | |
7 | ||
3abb6a6a DK |
8 | TESTDIR="$(readlink -f "$(dirname "$0")")" |
9 | . "$TESTDIR/framework" | |
daff4aa3 MV |
10 | |
11 | setupenvironment | |
12 | configarchitecture "amd64" | |
846bc058 | 13 | configcompression 'bz2' 'gz' |
c5ede4ca | 14 | confighashes 'SHA512' |
daff4aa3 | 15 | |
846bc058 | 16 | insertpackage 'unstable' 'foo' 'all' '1' |
514a25cb | 17 | insertpackage 'unstable' 'bar' 'amd64' '1' |
846bc058 | 18 | insertsource 'unstable' 'foo' 'all' '1' |
daff4aa3 | 19 | |
daff4aa3 | 20 | setupaptarchive --no-update |
34651385 | 21 | logcurrentarchivedirectory |
daff4aa3 MV |
22 | |
23 | # ensure the archive is not writable | |
30c8107e DK |
24 | addtrap 'prefix' 'chmod 755 aptarchive/dists/unstable/main/binary-all;' |
25 | if [ "$(id -u)" = '0' ]; then | |
514a25cb DK |
26 | # too deep to notice it, but it also unlikely that files in the same repo have different permissions |
27 | chmod 500 aptarchive/dists/unstable/main/binary-all | |
30c8107e | 28 | testfailure aptget update |
514a25cb DK |
29 | rm -rf rootdir/var/lib/apt/lists |
30 | chmod 755 aptarchive/dists/unstable/main/binary-all | |
31 | testsuccess aptget update | |
32 | rm -rf rootdir/var/lib/apt/lists | |
33 | chmod 511 aptarchive/dists/ | |
34 | testsuccess aptget update | |
35 | rm -rf rootdir/var/lib/apt/lists | |
36 | chmod 510 aptarchive/dists/ | |
87d6947d | 37 | testsuccesswithnotice aptget update |
514a25cb DK |
38 | rm -rf rootdir/var/lib/apt/lists |
39 | chmod 500 aptarchive/dists/ | |
87d6947d | 40 | testsuccesswithnotice aptget update |
34651385 DK |
41 | chmod 755 aptarchive/dists/ |
42 | else | |
43 | testsuccess aptget update | |
30c8107e | 44 | fi |
34651385 | 45 | mv rootdir/var/lib/apt/lists/_* rootdir/var/lib/apt/lists/partial |
30c8107e | 46 | chmod 555 aptarchive/dists/unstable/main/binary-all |
e169fa4a DK |
47 | testsuccess aptget update -o Debug::pkgAcquire::Worker=1 |
48 | cp -a rootdir/tmp/testsuccess.output rootdir/tmp/update.output | |
49 | testsuccess grep '%0aAlt-Filename:%20' rootdir/tmp/update.output | |
448c38bd DK |
50 | |
51 | # the release files aren't an IMS-hit, but the indexes are | |
52 | redatereleasefiles '+1 hour' | |
53 | ||
8d041b4f | 54 | # we don't download the index if it isn't updated |
846bc058 | 55 | testsuccess aptget update -o Debug::pkgAcquire::Auth=1 |
8d041b4f | 56 | # file:/ isn't shown in the log, so see if it was downloaded anyhow |
846bc058 | 57 | cp -a rootdir/tmp/testsuccess.output rootdir/tmp/update.output |
1dd20368 | 58 | canary="SHA512:$(bzcat aptarchive/dists/unstable/main/binary-all/Packages.bz2 | sha512sum |cut -f1 -d' ')" |
8d041b4f DK |
59 | testfailure grep -- "$canary" rootdir/tmp/update.output |
60 | ||
61 | testfoo() { | |
62 | # foo is still available | |
63 | testsuccess aptget install -s foo | |
64 | testsuccess aptcache showsrc foo | |
65 | testsuccess aptget source foo --print-uris | |
66 | } | |
67 | testfoo | |
68 | ||
69 | # the release file is new again, the index still isn't, but it is somehow gone now from disk | |
70 | redatereleasefiles '+2 hour' | |
71 | find rootdir/var/lib/apt/lists -name '*_Packages*' -delete | |
23d0a6fb | 72 | |
8d041b4f DK |
73 | testsuccess aptget update -o Debug::pkgAcquire::Auth=1 |
74 | # file:/ isn't shown in the log, so see if it was downloaded anyhow | |
75 | cp -a rootdir/tmp/testsuccess.output rootdir/tmp/update.output | |
1dd20368 | 76 | canary="SHA512:$(bzcat aptarchive/dists/unstable/main/binary-all/Packages.bz2 | sha512sum |cut -f1 -d' ')" |
846bc058 | 77 | testsuccess grep -- "$canary" rootdir/tmp/update.output |
23d0a6fb | 78 | |
8d041b4f | 79 | testfoo |