4 TESTDIR
="$(readlink -f "$(dirname "$0")")"
8 configarchitecture "i386
"
14 webserverconfig 'aptwebserver::support::range' 'false'
17 local DATE="${2:-now}"
18 if [ "$DATE" = 'now' ]; then
19 if [ "$1" = "${PKGFILE}-new" ]; then
25 for release in $(find rootdir/var/lib/apt/lists 2> /dev/null); do
26 touch -d 'now - 1 year' "$release"
29 cp "$1" aptarchive/Packages
30 find aptarchive -name 'Release' -delete
31 compressfile 'aptarchive/Packages' "$DATE"
32 generatereleasefiles "$DATE"
36 testsuccessequal "Reading package lists...
37 Building dependency tree...
39 aptitude
| synaptic
| wajig dpkg
-dev apt
-doc bzip2 lzma python
-apt
40 The following NEW packages will be installed
:
42 0 upgraded
, 1 newly installed
, 0 to remove and
0 not upgraded.
43 After this operation
, 5370 kB of additional disk space will be used.
44 Get
:1 http
://localhost
:${APTHTTPPORT} apt
0.7.25.3
45 Download complete and
in download only mode
" aptget install apt -dy
49 testsuccessequal "Reading package lists...
50 Building dependency tree...
52 aptitude
| synaptic
| wajig dpkg
-dev apt
-doc bzip2 lzma python
-apt
53 The following NEW packages will be installed
:
55 0 upgraded
, 1 newly installed
, 0 to remove and
0 not upgraded.
56 After this operation
, 5808 kB of additional disk space will be used.
57 Get
:1 http
://localhost
:${APTHTTPPORT} apt
0.8.0~pre1
58 Download complete and
in download only mode
" aptget install apt -dy
62 testfailureequal 'Reading package lists...
63 Building dependency tree...
65 aptitude | synaptic | wajig dpkg-dev apt-doc bzip2 lzma python-apt
66 The following NEW packages will be installed:
68 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
69 After this operation, 5370 kB of additional disk space will be used.
70 WARNING: The following packages cannot be authenticated!
72 E: There were unauthenticated packages and -y was used without --allow-unauthenticated' aptget install apt -dy
76 testfailureequal 'Reading package lists...
77 Building dependency tree...
79 aptitude | synaptic | wajig dpkg-dev apt-doc bzip2 lzma python-apt
80 The following NEW packages will be installed:
82 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
83 After this operation, 5808 kB of additional disk space will be used.
84 WARNING: The following packages cannot be authenticated!
86 E: There were unauthenticated packages and -y was used without --allow-unauthenticated' aptget install apt -dy
89 # fake our downloadable file
90 touch aptarchive/apt.deb
92 PKGFILE="${TESTDIR}/$(echo "$(basename "$0")" | sed 's#^test-#Packages-#')"
94 updatewithwarnings
() {
95 testwarning aptget update
-o Debug
::pkgAcquire
::Worker
=1 -o Debug
::Acquire
::gpgv
=1
96 testsuccess
grep -E "$1" rootdir
/tmp
/testwarning.output
100 local DELETEFILE
="$1"
101 msgmsg
'Cold archive signed by' 'Joe Sixpack'
103 rm -rf rootdir
/var
/lib
/apt
/lists
104 signreleasefiles
'Joe Sixpack'
105 find aptarchive
/ -name "$DELETEFILE" -delete
106 successfulaptgetupdate
107 testsuccessequal
"$(cat "${PKGFILE}")
111 msgmsg
'Good warm archive signed by' 'Joe Sixpack'
112 prepare
"${PKGFILE}-new"
113 signreleasefiles
'Joe Sixpack'
114 find aptarchive
/ -name "$DELETEFILE" -delete
115 successfulaptgetupdate
116 testsuccessequal
"$(cat "${PKGFILE}-new")
120 msgmsg
'Cold archive signed by' 'Rex Expired'
122 rm -rf rootdir
/var
/lib
/apt
/lists
123 cp keys
/rexexpired.pub rootdir
/etc
/apt
/trusted.gpg.d
/rexexpired.gpg
124 signreleasefiles
'Rex Expired'
125 find aptarchive
/ -name "$DELETEFILE" -delete
126 updatewithwarnings
'^W: .* KEYEXPIRED'
127 testsuccessequal
"$(cat "${PKGFILE}")
130 rm rootdir
/etc
/apt
/trusted.gpg.d
/rexexpired.gpg
132 msgmsg
'Cold archive signed by' 'Marvin Paranoid'
134 rm -rf rootdir
/var
/lib
/apt
/lists
135 signreleasefiles
'Marvin Paranoid'
136 find aptarchive
/ -name "$DELETEFILE" -delete
137 updatewithwarnings
'^W: .* NO_PUBKEY'
138 testsuccessequal
"$(cat "${PKGFILE}")
142 msgmsg
'Bad warm archive signed by' 'Joe Sixpack'
143 prepare
"${PKGFILE}-new"
144 signreleasefiles
'Joe Sixpack'
145 find aptarchive
/ -name "$DELETEFILE" -delete
146 successfulaptgetupdate
147 testsuccessequal
"$(cat "${PKGFILE}-new")
151 msgmsg
'Cold archive signed by' 'Joe Sixpack'
153 rm -rf rootdir
/var
/lib
/apt
/lists
154 signreleasefiles
'Joe Sixpack'
155 find aptarchive
/ -name "$DELETEFILE" -delete
156 successfulaptgetupdate
157 testsuccessequal
"$(cat "${PKGFILE}")
161 msgmsg
'Good warm archive signed by' 'Marvin Paranoid'
162 prepare
"${PKGFILE}-new"
163 signreleasefiles
'Marvin Paranoid'
164 find aptarchive
/ -name "$DELETEFILE" -delete
165 updatewithwarnings
'^W: .* NO_PUBKEY'
166 testsuccessequal
"$(cat "${PKGFILE}")
170 msgmsg
'Good warm archive signed by' 'Rex Expired'
171 prepare
"${PKGFILE}-new"
172 cp keys
/rexexpired.pub rootdir
/etc
/apt
/trusted.gpg.d
/rexexpired.gpg
173 signreleasefiles
'Rex Expired'
174 find aptarchive
/ -name "$DELETEFILE" -delete
175 updatewithwarnings
'^W: .* KEYEXPIRED'
176 testsuccessequal
"$(cat "${PKGFILE}")
179 rm rootdir
/etc
/apt
/trusted.gpg.d
/rexexpired.gpg
181 msgmsg
'Good warm archive signed by' 'Joe Sixpack'
182 prepare
"${PKGFILE}-new"
184 find aptarchive
/ -name "$DELETEFILE" -delete
185 successfulaptgetupdate
186 testsuccessequal
"$(cat "${PKGFILE}-new")
190 msgmsg
'Cold archive signed by good keyring' 'Marvin Paranoid'
192 rm -rf rootdir
/var
/lib
/apt
/lists
193 signreleasefiles
'Marvin Paranoid'
194 find aptarchive
/ -name "$DELETEFILE" -delete
195 local MARVIN
="$(readlink -f keys/marvinparanoid.pub)"
196 sed -i "s#^\(deb\(-src\)\?\) #\1 [signed-by=$MARVIN] #" rootdir
/etc
/apt
/sources.list.d
/*
197 successfulaptgetupdate
198 testsuccessequal
"$(cat "${PKGFILE}")
202 msgmsg
'Cold archive signed by bad keyring' 'Joe Sixpack'
203 rm -rf rootdir
/var
/lib
/apt
/lists
204 signreleasefiles
'Joe Sixpack'
205 find aptarchive
/ -name "$DELETEFILE" -delete
206 updatewithwarnings
'^W: .* NO_PUBKEY'
208 sed -i "s#^\(deb\(-src\)\?\) \[signed-by=$MARVIN\] #\1 #" rootdir
/etc
/apt
/sources.list.d
/*
209 local MARVIN
="$(aptkey --keyring $MARVIN finger | grep 'Key fingerprint' | cut -d'=' -f 2 | tr -d ' ')"
211 msgmsg
'Cold archive signed by good keyid' 'Marvin Paranoid'
213 rm -rf rootdir
/var
/lib
/apt
/lists
214 signreleasefiles
'Marvin Paranoid'
215 find aptarchive
/ -name "$DELETEFILE" -delete
216 sed -i "s#^\(deb\(-src\)\?\) #\1 [signed-by=$MARVIN] #" rootdir
/etc
/apt
/sources.list.d
/*
217 cp keys
/marvinparanoid.pub rootdir
/etc
/apt
/trusted.gpg.d
/marvinparanoid.gpg
218 successfulaptgetupdate
219 testsuccessequal
"$(cat "${PKGFILE}")
222 rm -f rootdir
/etc
/apt
/trusted.gpg.d
/marvinparanoid.gpg
224 msgmsg
'Cold archive signed by bad keyid' 'Joe Sixpack'
225 rm -rf rootdir
/var
/lib
/apt
/lists
226 signreleasefiles
'Joe Sixpack'
227 find aptarchive
/ -name "$DELETEFILE" -delete
228 updatewithwarnings
'^W: .* be verified because the public key is not available: .*'
230 sed -i "s#^\(deb\(-src\)\?\) \[signed-by=$MARVIN\] #\1 #" rootdir
/etc
/apt
/sources.list.d
/*
234 msgmsg
'Cold archive signed by' 'Joe Sixpack'
236 rm -rf rootdir
/var
/lib
/apt
/lists
237 signreleasefiles
'Joe Sixpack'
238 successfulaptgetupdate
240 # New .deb but now an unsigned archive. For example MITM to circumvent
241 # package verification.
242 msgmsg
'Warm archive signed by' 'nobody'
243 prepare
"${PKGFILE}-new"
244 find aptarchive
/ -name InRelease
-delete
245 find aptarchive
/ -name Release.gpg
-delete
246 updatewithwarnings
'W: .* no longer signed.'
247 testsuccessequal
"$(cat "${PKGFILE}-new")
251 # Unsigned archive from the beginning must also be detected.
252 msgmsg
'Cold archive signed by' 'nobody'
253 rm -rf rootdir
/var
/lib
/apt
/lists
254 updatewithwarnings
'W: .* is not signed.'
255 testsuccessequal
"$(cat "${PKGFILE}-new")
261 echo "Debug::Acquire::gpgv::configdigest::truststate \"$1\";" > rootdir
/etc
/apt
/apt.conf.d
/truststate
262 msgmsg
"Running base test with $1 digest"
265 for DELETEFILE
in 'InRelease' 'Release.gpg'; do
266 msgmsg
"Running test with deletion of $DELETEFILE and $1 digest"
267 runtest
"$DELETEFILE"
271 # diable some protection by default and ensure we still do the verification
273 cat > rootdir
/etc
/apt
/apt.conf.d
/weaken
-security <<EOF
274 Acquire::AllowInsecureRepositories "1";
275 Acquire::AllowDowngradeToInsecureRepositories "1";
277 # the hash marked as configureable in our gpgv method
278 export APT_TESTS_DIGEST_ALGO
='SHA224'
280 successfulaptgetupdate
() {
281 testsuccess aptget update
-o Debug
::pkgAcquire
::Worker
=1 -o Debug
::Acquire
::gpgv
=1
285 successfulaptgetupdate
() {
286 testwarning aptget update
-o Debug
::pkgAcquire
::Worker
=1 -o Debug
::Acquire
::gpgv
=1
287 testsuccess
grep 'uses weak digest algorithm' rootdir
/tmp
/testwarning.output
291 msgmsg
"Running test with apt-untrusted digest"
292 echo "Debug::Acquire::gpgv::configdigest::truststate \"untrusted\";" > rootdir
/etc
/apt
/apt.conf.d
/truststate
294 for DELETEFILE
in 'InRelease' 'Release.gpg'; do
295 msgmsg
'Cold archive signed by' 'Joe Sixpack'
297 rm -rf rootdir
/var
/lib
/apt
/lists
298 signreleasefiles
'Joe Sixpack'
299 find aptarchive
/ -name "$DELETEFILE" -delete
300 testfailure aptget update
--no-allow-insecure-repositories -o Debug
::pkgAcquire
::Worker
=1 -o Debug
::Acquire
::gpgv
=1
301 testsuccess
grep 'The following signatures were invalid' rootdir
/tmp
/testfailure.output
303 testwarning aptget update
--allow-insecure-repositories -o Debug
::pkgAcquire
::Worker
=1 -o Debug
::Acquire
::gpgv
=1
306 msgmsg
'Cold archive signed by' 'Marvin Paranoid'
308 rm -rf rootdir
/var
/lib
/apt
/lists
309 signreleasefiles
'Marvin Paranoid'
310 find aptarchive
/ -name "$DELETEFILE" -delete
311 testfailure aptget update
--no-allow-insecure-repositories -o Debug
::pkgAcquire
::Worker
=1 -o Debug
::Acquire
::gpgv
=1
313 updatewithwarnings
'^W: .* NO_PUBKEY'
314 testsuccessequal
"$(cat "${PKGFILE}")
321 msgmsg
"Running test with gpgv-untrusted digest"
322 export APT_TESTS_DIGEST_ALGO
='MD5'