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" 'now + 1 month'
36 rm -rf rootdir/var/cache/apt/archives
37 testsuccessequal "Reading package lists...
38 Building dependency tree...
40 aptitude
| synaptic
| wajig dpkg
-dev apt
-doc bzip2 lzma python
-apt
41 The following NEW packages will be installed
:
43 0 upgraded
, 1 newly installed
, 0 to remove and
0 not upgraded.
44 After this operation
, 5370 kB of additional disk space will be used.
45 Get
:1 http
://localhost
:${APTHTTPPORT} apt
0.7.25.3
46 Download complete and
in download only mode
" aptget install apt -dy
50 rm -rf rootdir/var/cache/apt/archives
51 testsuccessequal "Reading package lists...
52 Building dependency tree...
54 aptitude
| synaptic
| wajig dpkg
-dev apt
-doc bzip2 lzma python
-apt
55 The following NEW packages will be installed
:
57 0 upgraded
, 1 newly installed
, 0 to remove and
0 not upgraded.
58 After this operation
, 5808 kB of additional disk space will be used.
59 Get
:1 http
://localhost
:${APTHTTPPORT} apt
0.8.0~pre1
60 Download complete and
in download only mode
" aptget install apt -dy
64 testfailureequal 'Reading package lists...
65 Building dependency tree...
67 aptitude | synaptic | wajig dpkg-dev apt-doc bzip2 lzma python-apt
68 The following NEW packages will be installed:
70 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
71 After this operation, 5370 kB of additional disk space will be used.
72 WARNING: The following packages cannot be authenticated!
74 E: There were unauthenticated packages and -y was used without --allow-unauthenticated' aptget install apt -dy
78 testfailureequal 'Reading package lists...
79 Building dependency tree...
81 aptitude | synaptic | wajig dpkg-dev apt-doc bzip2 lzma python-apt
82 The following NEW packages will be installed:
84 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
85 After this operation, 5808 kB of additional disk space will be used.
86 WARNING: The following packages cannot be authenticated!
88 E: There were unauthenticated packages and -y was used without --allow-unauthenticated' aptget install apt -dy
91 # fake our downloadable file
92 touch aptarchive/apt.deb
94 PKGFILE="${TESTDIR}/$(echo "$(basename "$0")" | sed 's#^test-#Packages-#')"
96 updatewithwarnings
() {
97 testwarning aptget update
-o Debug
::pkgAcquire
::Worker
=1 -o Debug
::Acquire
::gpgv
=1
98 testsuccess
grep -E "$1" rootdir
/tmp
/testwarning.output
102 msgmsg
'Cold archive signed by' 'Joe Sixpack'
104 rm -rf rootdir
/var
/lib
/apt
/lists
105 signreleasefiles
'Joe Sixpack'
106 successfulaptgetupdate
107 testsuccessequal
"$(cat "${PKGFILE}")
111 msgmsg
'Good warm archive signed by' 'Joe Sixpack'
112 prepare
"${PKGFILE}-new"
113 signreleasefiles
'Joe Sixpack'
114 successfulaptgetupdate
115 testsuccessequal
"$(cat "${PKGFILE}-new")
119 msgmsg
'Cold archive signed by' 'Rex Expired'
121 rm -rf rootdir
/var
/lib
/apt
/lists
122 cp keys
/rexexpired.pub rootdir
/etc
/apt
/trusted.gpg.d
/rexexpired.gpg
123 signreleasefiles
'Rex Expired'
124 updatewithwarnings
'^W: .* EXPKEYSIG'
125 testsuccessequal
"$(cat "${PKGFILE}")
128 rm -f rootdir
/etc
/apt
/trusted.gpg.d
/rexexpired.gpg
130 msgmsg
'Cold archive expired signed by' 'Joe Sixpack'
131 if dpkg
--compare-versions "$(aptkey adv --version | head -n 2 | tail -n 1 | cut -d' ' -f 3)" '>=' '2.1' >/dev
/null
2>&1; then
132 touch rootdir
/etc
/apt
/apt.conf.d
/99gnupg2
133 elif gpg2
--version >/dev
/null
2>&1; then
134 echo 'Apt::Key::gpgcommand "gpg2";' > rootdir
/etc
/apt
/apt.conf.d
/99gnupg2
135 if ! dpkg
--compare-versions "$(aptkey adv --version | head -n 2 | tail -n 1 | cut -d' ' -f 3)" '>=' '2.1' >/dev
/null
2>&1; then
136 rm rootdir
/etc
/apt
/apt.conf.d
/99gnupg2
139 if [ -e rootdir
/etc
/apt
/apt.conf.d
/99gnupg2
]; then
141 rm -rf rootdir
/var
/lib
/apt
/lists
142 signreleasefiles
'Joe Sixpack' 'aptarchive' --faked-system-time "20070924T154812" --default-sig-expire 2016-04-01
143 updatewithwarnings
'^W: .* EXPSIG'
144 testsuccessequal
"$(cat "${PKGFILE}")
147 rm -f rootdir
/etc
/apt
/apt.conf.d
/99gnupg2
149 msgskip
'Not a new enough gpg available providing --fake-system-time'
152 msgmsg
'Cold archive signed by' 'Joe Sixpack,Marvin Paranoid'
154 rm -rf rootdir
/var
/lib
/apt
/lists
155 signreleasefiles
'Joe Sixpack,Marvin Paranoid'
156 successfulaptgetupdate
'NO_PUBKEY'
157 testsuccessequal
"$(cat "${PKGFILE}")
161 msgmsg
'Cold archive signed by' 'Joe Sixpack,Rex Expired'
163 rm -rf rootdir
/var
/lib
/apt
/lists
164 signreleasefiles
'Joe Sixpack,Rex Expired'
165 cp keys
/rexexpired.pub rootdir
/etc
/apt
/trusted.gpg.d
/rexexpired.gpg
166 successfulaptgetupdate
'EXPKEYSIG'
167 rm -f rootdir
/etc
/apt
/trusted.gpg.d
/rexexpired.gpg
168 testsuccessequal
"$(cat "${PKGFILE}")
172 msgmsg
'Cold archive signed by' 'Marvin Paranoid'
174 rm -rf rootdir
/var
/lib
/apt
/lists
175 signreleasefiles
'Marvin Paranoid'
176 updatewithwarnings
'^W: .* NO_PUBKEY'
177 testsuccessequal
"$(cat "${PKGFILE}")
181 msgmsg
'Bad warm archive signed by' 'Joe Sixpack'
182 prepare
"${PKGFILE}-new"
183 signreleasefiles
'Joe Sixpack'
184 successfulaptgetupdate
185 testsuccessequal
"$(cat "${PKGFILE}-new")
189 msgmsg
'Cold archive signed by' 'Joe Sixpack'
191 rm -rf rootdir
/var
/lib
/apt
/lists
192 signreleasefiles
'Joe Sixpack'
193 successfulaptgetupdate
194 testsuccessequal
"$(cat "${PKGFILE}")
198 msgmsg
'Good warm archive signed by' 'Marvin Paranoid'
199 prepare
"${PKGFILE}-new"
200 signreleasefiles
'Marvin Paranoid'
201 updatewithwarnings
'^W: .* NO_PUBKEY'
202 testsuccessequal
"$(cat "${PKGFILE}")
206 msgmsg
'Good warm archive signed by' 'Rex Expired'
207 prepare
"${PKGFILE}-new"
208 cp keys
/rexexpired.pub rootdir
/etc
/apt
/trusted.gpg.d
/rexexpired.gpg
209 signreleasefiles
'Rex Expired'
210 updatewithwarnings
'^W: .* EXPKEYSIG'
211 testsuccessequal
"$(cat "${PKGFILE}")
214 rm rootdir
/etc
/apt
/trusted.gpg.d
/rexexpired.gpg
216 msgmsg
'Good warm archive signed by' 'Joe Sixpack'
217 prepare
"${PKGFILE}-new"
219 successfulaptgetupdate
220 testsuccessequal
"$(cat "${PKGFILE}-new")
224 msgmsg
'Cold archive signed by good keyring' 'Marvin Paranoid'
226 rm -rf rootdir
/var
/lib
/apt
/lists
227 signreleasefiles
'Marvin Paranoid'
228 local MARVIN
="$(readlink -f keys/marvinparanoid.pub)"
229 sed -i "s#^\(deb\(-src\)\?\) #\1 [signed-by=$MARVIN] #" rootdir
/etc
/apt
/sources.list.d
/*
230 successfulaptgetupdate
231 testsuccessequal
"$(cat "${PKGFILE}")
235 msgmsg
'Cold archive signed by bad keyring' 'Joe Sixpack'
236 rm -rf rootdir
/var
/lib
/apt
/lists
237 signreleasefiles
'Joe Sixpack'
238 updatewithwarnings
'^W: .* NO_PUBKEY'
239 sed -i "s#^\(deb\(-src\)\?\) \[signed-by=$MARVIN\] #\1 #" rootdir
/etc
/apt
/sources.list.d
/*
241 local MARVIN
="$(aptkey --keyring $MARVIN finger | grep 'Key fingerprint' | cut -d'=' -f 2 | tr -d ' ')"
242 msgmsg
'Cold archive signed by bad keyid' 'Joe Sixpack'
243 rm -rf rootdir
/var
/lib
/apt
/lists
244 signreleasefiles
'Joe Sixpack'
245 sed -i "s#^\(deb\(-src\)\?\) #\1 [signed-by=$MARVIN] #" rootdir
/etc
/apt
/sources.list.d
/*
246 updatewithwarnings
'^W: .* be verified because the public key is not available: .*'
248 msgmsg
'Cold archive signed by good keyid' 'Marvin Paranoid'
249 rm -rf rootdir
/var
/lib
/apt
/lists
250 signreleasefiles
'Marvin Paranoid'
251 cp keys
/marvinparanoid.pub rootdir
/etc
/apt
/trusted.gpg.d
/marvinparanoid.gpg
252 successfulaptgetupdate
253 testsuccessequal
"$(cat "${PKGFILE}")
257 msgmsg
'Cold archive signed by good keyid' 'Marvin Paranoid,Joe Sixpack'
258 rm -rf rootdir
/var
/lib
/apt
/lists
259 signreleasefiles
'Marvin Paranoid,Joe Sixpack'
260 successfulaptgetupdate
'NoPubKey: GOODSIG'
261 testsuccessequal
"$(cat "${PKGFILE}")
265 local SIXPACK
="$(aptkey --keyring keys/joesixpack.pub finger | grep 'Key fingerprint' | cut -d'=' -f 2 | tr -d ' ')"
266 msgmsg
'Cold archive signed by good keyids' 'Joe Sixpack'
267 rm -rf rootdir
/var
/lib
/apt
/lists
268 signreleasefiles
'Joe Sixpack'
269 sed -i "s#^\(deb\(-src\)\?\) \[signed-by=$MARVIN\] #\1 [signed-by=${SIXPACK},${MARVIN}] #" rootdir
/etc
/apt
/sources.list.d
/*
270 successfulaptgetupdate
271 testsuccessequal
"$(cat "${PKGFILE}")
275 local SIXPACK
="$(aptkey --keyring keys/joesixpack.pub finger | grep 'Key fingerprint' | cut -d'=' -f 2 | tr -d ' ')"
276 msgmsg
'Cold archive signed by good keyids' 'Joe Sixpack'
277 rm -rf rootdir
/var
/lib
/apt
/lists
278 sed -i "s#^\(deb\(-src\)\?\) \[signed-by=${SIXPACK},${MARVIN}\] #\1 [signed-by=${MARVIN},${SIXPACK}] #" rootdir
/etc
/apt
/sources.list.d
/*
279 successfulaptgetupdate
280 testsuccessequal
"$(cat "${PKGFILE}")
283 rm -f rootdir
/etc
/apt
/trusted.gpg.d
/marvinparanoid.gpg
284 sed -i "s#^\(deb\(-src\)\?\) \[signed-by=${MARVIN},${SIXPACK}\] #\1 #" rootdir
/etc
/apt
/sources.list.d
/*
286 rm -rf rootdir
/var
/lib
/apt
/lists
-bak
287 cp -a rootdir
/var
/lib
/apt
/lists rootdir
/var
/lib
/apt
/lists
-bak
288 prepare
"${PKGFILE}-new"
289 signreleasefiles
'Joe Sixpack'
291 msgmsg
'Warm archive with signed-by' 'Joe Sixpack'
292 sed -i "/^Valid-Until: / a\
293 Signed-By: ${SIXPACK}" rootdir
/var
/lib
/apt
/lists
/*Release
294 touch -d 'now - 1 year' rootdir
/var
/lib
/apt
/lists
/*Release
295 successfulaptgetupdate
296 testsuccessequal
"$(cat "${PKGFILE}-new")
300 msgmsg
'Warm archive with signed-by' 'Marvin Paranoid'
301 rm -rf rootdir
/var
/lib
/apt
/lists
302 cp -a rootdir
/var
/lib
/apt
/lists
-bak rootdir
/var
/lib
/apt
/lists
303 sed -i "/^Valid-Until: / a\
304 Signed-By: ${MARVIN}" rootdir
/var
/lib
/apt
/lists
/*Release
305 touch -d 'now - 1 year' rootdir
/var
/lib
/apt
/lists
/*Release
306 updatewithwarnings
'W: .* public key is not available: GOODSIG'
307 testsuccessequal
"$(cat "${PKGFILE}")
311 msgmsg
'Warm archive with outdated signed-by' 'Marvin Paranoid'
312 rm -rf rootdir
/var
/lib
/apt
/lists
313 cp -a rootdir
/var
/lib
/apt
/lists
-bak rootdir
/var
/lib
/apt
/lists
314 sed -i "/^Valid-Until: / a\
315 Valid-Until: $(date -u -d "now - 2min" '+%a, %d %b %Y %H:%M:%S %Z') \\
316 Signed-By: ${MARVIN}" rootdir
/var
/lib
/apt
/lists
/*Release
317 touch -d 'now - 1 year' rootdir
/var
/lib
/apt
/lists
/*Release
318 successfulaptgetupdate
319 testsuccessequal
"$(cat "${PKGFILE}-new")
323 msgmsg
'Warm archive with two signed-bys' 'Joe Sixpack'
324 rm -rf rootdir
/var
/lib
/apt
/lists
325 cp -a rootdir
/var
/lib
/apt
/lists
-bak rootdir
/var
/lib
/apt
/lists
326 sed -i "/^Valid-Until: / a\
327 Signed-By: ${MARVIN} ${MARVIN}, \\
328 ${SIXPACK}" rootdir
/var
/lib
/apt
/lists
/*Release
329 touch -d 'now - 1 year' rootdir
/var
/lib
/apt
/lists
/*Release
330 successfulaptgetupdate
331 testsuccessequal
"$(cat "${PKGFILE}-new")
337 msgmsg
'Cold archive signed by' 'Joe Sixpack'
339 rm -rf rootdir
/var
/lib
/apt
/lists
340 signreleasefiles
'Joe Sixpack'
341 successfulaptgetupdate
343 # New .deb but now an unsigned archive. For example MITM to circumvent
344 # package verification.
345 msgmsg
'Warm archive signed by' 'nobody'
346 prepare
"${PKGFILE}-new"
347 find aptarchive
/ \
( -name InRelease
-o -name Release.gpg \
) -delete
348 updatewithwarnings
'W: .* no longer signed.'
349 testsuccessequal
"$(cat "${PKGFILE}-new")
353 # Unsigned archive from the beginning must also be detected.
354 msgmsg
'Cold archive signed by' 'nobody'
355 rm -rf rootdir
/var
/lib
/apt
/lists
356 updatewithwarnings
'W: .* is not signed.'
357 testsuccessequal
"$(cat "${PKGFILE}-new")
363 echo "APT::Hashes::$APT_TESTS_DIGEST_ALGO::$1 \"yes\";" > rootdir
/etc
/apt
/apt.conf.d
/truststate
364 msgmsg
"Running base test with $1 digest"
367 for DELETEFILE
in 'InRelease' 'Release.gpg'; do
368 export APT_DONT_SIGN
="$DELETEFILE"
369 msgmsg
"Running test with deletion of $DELETEFILE and $1 digest"
375 # diable some protection by default and ensure we still do the verification
377 cat > rootdir
/etc
/apt
/apt.conf.d
/weaken
-security <<EOF
378 Acquire::AllowInsecureRepositories "1";
379 Acquire::AllowDowngradeToInsecureRepositories "1";
381 # the hash marked as configureable in our gpgv method
382 export APT_TESTS_DIGEST_ALGO
='SHA224'
384 successfulaptgetupdate
() {
385 testsuccess aptget update
-o Debug
::pkgAcquire
::Worker
=1 -o Debug
::Acquire
::gpgv
=1
387 cp rootdir
/tmp
/testsuccess.output aptupdate.output
388 testsuccess
grep "$1" aptupdate.output
393 successfulaptgetupdate
() {
394 testwarning aptget update
-o Debug
::pkgAcquire
::Worker
=1 -o Debug
::Acquire
::gpgv
=1
396 testsuccess
grep "$1" rootdir
/tmp
/testwarning.output
398 testsuccess
grep 'uses weak digest algorithm' rootdir
/tmp
/testwarning.output
402 msgmsg
"Running test with apt-untrusted digest"
403 echo "APT::Hashes::$APT_TESTS_DIGEST_ALGO::Untrusted \"yes\";" > rootdir
/etc
/apt
/apt.conf.d
/truststate
405 for DELETEFILE
in 'InRelease' 'Release.gpg'; do
406 export APT_DONT_SIGN
="$DELETEFILE"
407 msgmsg
'Cold archive signed by' 'Joe Sixpack'
409 rm -rf rootdir
/var
/lib
/apt
/lists
410 signreleasefiles
'Joe Sixpack'
411 testfailure aptget update
--no-allow-insecure-repositories -o Debug
::pkgAcquire
::Worker
=1 -o Debug
::Acquire
::gpgv
=1
412 testsuccess
grep 'The following signatures were invalid' rootdir
/tmp
/testfailure.output
414 testwarning aptget update
--allow-insecure-repositories -o Debug
::pkgAcquire
::Worker
=1 -o Debug
::Acquire
::gpgv
=1
417 msgmsg
'Cold archive signed by' 'Marvin Paranoid'
419 rm -rf rootdir
/var
/lib
/apt
/lists
420 signreleasefiles
'Marvin Paranoid'
421 testfailure aptget update
--no-allow-insecure-repositories -o Debug
::pkgAcquire
::Worker
=1 -o Debug
::Acquire
::gpgv
=1
423 updatewithwarnings
'^W: .* NO_PUBKEY'
424 testsuccessequal
"$(cat "${PKGFILE}")
432 msgmsg
"Running test with gpgv-untrusted digest"
433 export APT_TESTS_DIGEST_ALGO
='MD5'