]> git.saurik.com Git - apt.git/blob - test/integration/test-apt-update-file
94b604f0e7dc9b88cf991e2984f05e85054061a6
[apt.git] / test / integration / test-apt-update-file
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
8 TESTDIR=$(readlink -f $(dirname $0))
9 . $TESTDIR/framework
10
11 setupenvironment
12 configarchitecture "amd64"
13 configcompression 'bz2' 'gz'
14
15 insertpackage 'unstable' 'foo' 'all' '1'
16 insertsource 'unstable' 'foo' 'all' '1'
17
18 setupaptarchive --no-update
19
20 # ensure the archive is not writable
21 addtrap 'prefix' 'chmod 750 aptarchive/dists/unstable/main/binary-amd64;'
22 chmod 550 aptarchive/dists/unstable/main/binary-amd64
23
24 testsuccess aptget update
25
26 # the release files aren't an IMS-hit, but the indexes are
27 redatereleasefiles '+1 hour'
28
29 # we don't download the index if it isn't updated
30 testsuccess aptget update -o Debug::pkgAcquire::Auth=1
31 # file:/ isn't shown in the log, so see if it was downloaded anyhow
32 cp -a rootdir/tmp/testsuccess.output rootdir/tmp/update.output
33 canary="SHA512:$(bzcat aptarchive/dists/unstable/main/binary-amd64/Packages.bz2 | sha512sum |cut -f1 -d' ')"
34 testfailure grep -- "$canary" rootdir/tmp/update.output
35
36 testfoo() {
37 # foo is still available
38 testsuccess aptget install -s foo
39 testsuccess aptcache showsrc foo
40 testsuccess aptget source foo --print-uris
41 }
42 testfoo
43
44 # the release file is new again, the index still isn't, but it is somehow gone now from disk
45 redatereleasefiles '+2 hour'
46 find rootdir/var/lib/apt/lists -name '*_Packages*' -delete
47
48 testsuccess aptget update -o Debug::pkgAcquire::Auth=1
49 # file:/ isn't shown in the log, so see if it was downloaded anyhow
50 cp -a rootdir/tmp/testsuccess.output rootdir/tmp/update.output
51 canary="SHA512:$(bzcat aptarchive/dists/unstable/main/binary-amd64/Packages.bz2 | sha512sum |cut -f1 -d' ')"
52 testsuccess grep -- "$canary" rootdir/tmp/update.output
53
54 testfoo