]> git.saurik.com Git - apt.git/blame_incremental - test/integration/test-apt-update-file
Don't download "optional" files not in Release :/.
[apt.git] / test / integration / test-apt-update-file
... / ...
CommitLineData
1#!/bin/sh
2#
3# Ensure that we do not modify file:/// uris (regression test for
4# CVE-2014-0487
5#
6set -e
7
8TESTDIR="$(readlink -f "$(dirname "$0")")"
9. "$TESTDIR/framework"
10
11setupenvironment
12configarchitecture "amd64"
13configcompression 'bz2' 'gz'
14confighashes 'SHA512'
15
16insertpackage 'unstable' 'foo' 'all' '1'
17insertpackage 'unstable' 'bar' 'amd64' '1'
18insertsource 'unstable' 'foo' 'all' '1'
19
20setupaptarchive --no-update
21logcurrentarchivedirectory
22
23# ensure the archive is not writable
24addtrap 'prefix' 'chmod 755 aptarchive/dists/unstable/main/binary-all;'
25if [ "$(id -u)" = '0' ]; then
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
28 testfailure aptget update
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/
37 testsuccesswithnotice aptget update
38 rm -rf rootdir/var/lib/apt/lists
39 chmod 500 aptarchive/dists/
40 testsuccesswithnotice aptget update
41 chmod 755 aptarchive/dists/
42else
43 testsuccess aptget update
44fi
45mv rootdir/var/lib/apt/lists/_* rootdir/var/lib/apt/lists/partial
46chmod 555 aptarchive/dists/unstable/main/binary-all
47testsuccess aptget update -o Debug::pkgAcquire::Worker=1
48cp -a rootdir/tmp/testsuccess.output rootdir/tmp/update.output
49testsuccess grep '%0aAlt-Filename:%20' rootdir/tmp/update.output
50
51# the release files aren't an IMS-hit, but the indexes are
52redatereleasefiles '+1 hour'
53
54# we don't download the index if it isn't updated
55testsuccess aptget update -o Debug::pkgAcquire::Auth=1
56# file:/ isn't shown in the log, so see if it was downloaded anyhow
57cp -a rootdir/tmp/testsuccess.output rootdir/tmp/update.output
58canary="SHA512:$(bzcat aptarchive/dists/unstable/main/binary-all/Packages.bz2 | sha512sum |cut -f1 -d' ')"
59testfailure grep -- "$canary" rootdir/tmp/update.output
60
61testfoo() {
62 # foo is still available
63 testsuccess aptget install -s foo
64 testsuccess aptcache showsrc foo
65 testsuccess aptget source foo --print-uris
66}
67testfoo
68
69# the release file is new again, the index still isn't, but it is somehow gone now from disk
70redatereleasefiles '+2 hour'
71find rootdir/var/lib/apt/lists -name '*_Packages*' -delete
72
73testsuccess aptget update -o Debug::pkgAcquire::Auth=1
74# file:/ isn't shown in the log, so see if it was downloaded anyhow
75cp -a rootdir/tmp/testsuccess.output rootdir/tmp/update.output
76canary="SHA512:$(bzcat aptarchive/dists/unstable/main/binary-all/Packages.bz2 | sha512sum |cut -f1 -d' ')"
77testsuccess grep -- "$canary" rootdir/tmp/update.output
78
79testfoo