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 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 testsuccessequal "Reading package lists...
51 Building dependency tree...
53 aptitude
| synaptic
| wajig dpkg
-dev apt
-doc bzip2 lzma python
-apt
54 The following NEW packages will be installed
:
56 0 upgraded
, 1 newly installed
, 0 to remove and
0 not upgraded.
57 After this operation
, 5808 kB of additional disk space will be used.
58 Get
:1 http
://localhost
:${APTHTTPPORT} apt
0.8.0~pre1
59 Download complete and
in download only mode
" aptget install apt -dy
63 testfailureequal 'Reading package lists...
64 Building dependency tree...
66 aptitude | synaptic | wajig dpkg-dev apt-doc bzip2 lzma python-apt
67 The following NEW packages will be installed:
69 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
70 After this operation, 5370 kB of additional disk space will be used.
71 WARNING: The following packages cannot be authenticated!
73 E: There were unauthenticated packages and -y was used without --allow-unauthenticated' aptget install apt -dy
77 testfailureequal 'Reading package lists...
78 Building dependency tree...
80 aptitude | synaptic | wajig dpkg-dev apt-doc bzip2 lzma python-apt
81 The following NEW packages will be installed:
83 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
84 After this operation, 5808 kB of additional disk space will be used.
85 WARNING: The following packages cannot be authenticated!
87 E: There were unauthenticated packages and -y was used without --allow-unauthenticated' aptget install apt -dy
90 # fake our downloadable file
91 touch aptarchive/apt.deb
93 PKGFILE="${TESTDIR}/$(echo "$(basename "$0")" | sed 's#^test-#Packages-#')"
95 updatewithwarnings
() {
96 testwarning aptget update
-o Debug
::pkgAcquire
::Worker
=1 -o Debug
::Acquire
::gpgv
=1
97 testsuccess
grep -E "$1" rootdir
/tmp
/testwarning.output
101 local DELETEFILE
="$1"
102 msgmsg
'Cold archive signed by' 'Joe Sixpack'
104 rm -rf rootdir
/var
/lib
/apt
/lists
105 signreleasefiles
'Joe Sixpack'
106 find aptarchive
/ -name "$DELETEFILE" -delete
107 successfulaptgetupdate
108 testsuccessequal
"$(cat "${PKGFILE}")
112 msgmsg
'Good warm archive signed by' 'Joe Sixpack'
113 prepare
"${PKGFILE}-new"
114 signreleasefiles
'Joe Sixpack'
115 find aptarchive
/ -name "$DELETEFILE" -delete
116 successfulaptgetupdate
117 testsuccessequal
"$(cat "${PKGFILE}-new")
121 msgmsg
'Cold archive signed by' 'Rex Expired'
123 rm -rf rootdir
/var
/lib
/apt
/lists
124 cp keys
/rexexpired.pub rootdir
/etc
/apt
/trusted.gpg.d
/rexexpired.gpg
125 signreleasefiles
'Rex Expired'
126 find aptarchive
/ -name "$DELETEFILE" -delete
127 updatewithwarnings
'^W: .* EXPKEYSIG'
128 testsuccessequal
"$(cat "${PKGFILE}")
131 rm -f rootdir
/etc
/apt
/trusted.gpg.d
/rexexpired.gpg
133 msgmsg
'Cold archive expired signed by' 'Joe Sixpack'
134 if dpkg
--compare-versions "$(aptkey adv --version | head -n 2 | tail -n 1 | cut -d' ' -f 3)" '>=' '2.1' >/dev
/null
2>&1; then
135 touch rootdir
/etc
/apt
/apt.conf.d
/99gnupg2
136 elif gpg2
--version >/dev
/null
2>&1; then
137 echo 'Apt::Key::gpgcommand "gpg2";' > rootdir
/etc
/apt
/apt.conf.d
/99gnupg2
138 if ! dpkg
--compare-versions "$(aptkey adv --version | head -n 2 | tail -n 1 | cut -d' ' -f 3)" '>=' '2.1' >/dev
/null
2>&1; then
139 rm rootdir
/etc
/apt
/apt.conf.d
/99gnupg2
142 if [ -e rootdir
/etc
/apt
/apt.conf.d
/99gnupg2
]; then
144 rm -rf rootdir
/var
/lib
/apt
/lists
145 signreleasefiles
'Joe Sixpack' 'aptarchive' --faked-system-time "20070924T154812" --default-sig-expire 2016-04-01
146 find aptarchive
/ -name "$DELETEFILE" -delete
147 updatewithwarnings
'^W: .* EXPSIG'
148 testsuccessequal
"$(cat "${PKGFILE}")
151 rm -f rootdir
/etc
/apt
/apt.conf.d
/99gnupg2
153 msgskip
'Not a new enough gpg available providing --fake-system-time'
156 msgmsg
'Cold archive signed by' 'Joe Sixpack,Marvin Paranoid'
158 rm -rf rootdir
/var
/lib
/apt
/lists
159 signreleasefiles
'Joe Sixpack,Marvin Paranoid'
160 find aptarchive
/ -name "$DELETEFILE" -delete
161 successfulaptgetupdate
'NO_PUBKEY'
162 testsuccessequal
"$(cat "${PKGFILE}")
166 msgmsg
'Cold archive signed by' 'Joe Sixpack,Rex Expired'
168 rm -rf rootdir
/var
/lib
/apt
/lists
169 signreleasefiles
'Joe Sixpack,Rex Expired'
170 find aptarchive
/ -name "$DELETEFILE" -delete
171 cp keys
/rexexpired.pub rootdir
/etc
/apt
/trusted.gpg.d
/rexexpired.gpg
172 successfulaptgetupdate
'EXPKEYSIG'
173 rm -f rootdir
/etc
/apt
/trusted.gpg.d
/rexexpired.gpg
174 testsuccessequal
"$(cat "${PKGFILE}")
178 msgmsg
'Cold archive signed by' 'Marvin Paranoid'
180 rm -rf rootdir
/var
/lib
/apt
/lists
181 signreleasefiles
'Marvin Paranoid'
182 find aptarchive
/ -name "$DELETEFILE" -delete
183 updatewithwarnings
'^W: .* NO_PUBKEY'
184 testsuccessequal
"$(cat "${PKGFILE}")
188 msgmsg
'Bad warm archive signed by' 'Joe Sixpack'
189 prepare
"${PKGFILE}-new"
190 signreleasefiles
'Joe Sixpack'
191 find aptarchive
/ -name "$DELETEFILE" -delete
192 successfulaptgetupdate
193 testsuccessequal
"$(cat "${PKGFILE}-new")
197 msgmsg
'Cold archive signed by' 'Joe Sixpack'
199 rm -rf rootdir
/var
/lib
/apt
/lists
200 signreleasefiles
'Joe Sixpack'
201 find aptarchive
/ -name "$DELETEFILE" -delete
202 successfulaptgetupdate
203 testsuccessequal
"$(cat "${PKGFILE}")
207 msgmsg
'Good warm archive signed by' 'Marvin Paranoid'
208 prepare
"${PKGFILE}-new"
209 signreleasefiles
'Marvin Paranoid'
210 find aptarchive
/ -name "$DELETEFILE" -delete
211 updatewithwarnings
'^W: .* NO_PUBKEY'
212 testsuccessequal
"$(cat "${PKGFILE}")
216 msgmsg
'Good warm archive signed by' 'Rex Expired'
217 prepare
"${PKGFILE}-new"
218 cp keys
/rexexpired.pub rootdir
/etc
/apt
/trusted.gpg.d
/rexexpired.gpg
219 signreleasefiles
'Rex Expired'
220 find aptarchive
/ -name "$DELETEFILE" -delete
221 updatewithwarnings
'^W: .* EXPKEYSIG'
222 testsuccessequal
"$(cat "${PKGFILE}")
225 rm rootdir
/etc
/apt
/trusted.gpg.d
/rexexpired.gpg
227 msgmsg
'Good warm archive signed by' 'Joe Sixpack'
228 prepare
"${PKGFILE}-new"
230 find aptarchive
/ -name "$DELETEFILE" -delete
231 successfulaptgetupdate
232 testsuccessequal
"$(cat "${PKGFILE}-new")
236 msgmsg
'Cold archive signed by good keyring' 'Marvin Paranoid'
238 rm -rf rootdir
/var
/lib
/apt
/lists
239 signreleasefiles
'Marvin Paranoid'
240 find aptarchive
/ -name "$DELETEFILE" -delete
241 local MARVIN
="$(readlink -f keys/marvinparanoid.pub)"
242 sed -i "s#^\(deb\(-src\)\?\) #\1 [signed-by=$MARVIN] #" rootdir
/etc
/apt
/sources.list.d
/*
243 successfulaptgetupdate
244 testsuccessequal
"$(cat "${PKGFILE}")
248 msgmsg
'Cold archive signed by bad keyring' 'Joe Sixpack'
249 rm -rf rootdir
/var
/lib
/apt
/lists
250 signreleasefiles
'Joe Sixpack'
251 find aptarchive
/ -name "$DELETEFILE" -delete
252 updatewithwarnings
'^W: .* NO_PUBKEY'
253 sed -i "s#^\(deb\(-src\)\?\) \[signed-by=$MARVIN\] #\1 #" rootdir
/etc
/apt
/sources.list.d
/*
255 local MARVIN
="$(aptkey --keyring $MARVIN finger | grep 'Key fingerprint' | cut -d'=' -f 2 | tr -d ' ')"
256 msgmsg
'Cold archive signed by bad keyid' 'Joe Sixpack'
257 rm -rf rootdir
/var
/lib
/apt
/lists
258 signreleasefiles
'Joe Sixpack'
259 find aptarchive
/ -name "$DELETEFILE" -delete
260 sed -i "s#^\(deb\(-src\)\?\) #\1 [signed-by=$MARVIN] #" rootdir
/etc
/apt
/sources.list.d
/*
261 updatewithwarnings
'^W: .* be verified because the public key is not available: .*'
263 msgmsg
'Cold archive signed by good keyid' 'Marvin Paranoid'
264 rm -rf rootdir
/var
/lib
/apt
/lists
265 signreleasefiles
'Marvin Paranoid'
266 find aptarchive
/ -name "$DELETEFILE" -delete
267 cp keys
/marvinparanoid.pub rootdir
/etc
/apt
/trusted.gpg.d
/marvinparanoid.gpg
268 successfulaptgetupdate
269 testsuccessequal
"$(cat "${PKGFILE}")
273 msgmsg
'Cold archive signed by good keyid' 'Marvin Paranoid,Joe Sixpack'
274 rm -rf rootdir
/var
/lib
/apt
/lists
275 signreleasefiles
'Marvin Paranoid,Joe Sixpack'
276 find aptarchive
/ -name "$DELETEFILE" -delete
277 successfulaptgetupdate
'NoPubKey: GOODSIG'
278 testsuccessequal
"$(cat "${PKGFILE}")
282 local SIXPACK
="$(aptkey --keyring keys/joesixpack.pub finger | grep 'Key fingerprint' | cut -d'=' -f 2 | tr -d ' ')"
283 msgmsg
'Cold archive signed by good keyids' 'Joe Sixpack'
284 rm -rf rootdir
/var
/lib
/apt
/lists
285 signreleasefiles
'Joe Sixpack'
286 find aptarchive
/ -name "$DELETEFILE" -delete
287 sed -i "s#^\(deb\(-src\)\?\) \[signed-by=$MARVIN\] #\1 [signed-by=${SIXPACK},${MARVIN}] #" rootdir
/etc
/apt
/sources.list.d
/*
288 successfulaptgetupdate
289 testsuccessequal
"$(cat "${PKGFILE}")
293 local SIXPACK
="$(aptkey --keyring keys/joesixpack.pub finger | grep 'Key fingerprint' | cut -d'=' -f 2 | tr -d ' ')"
294 msgmsg
'Cold archive signed by good keyids' 'Joe Sixpack'
295 rm -rf rootdir
/var
/lib
/apt
/lists
296 sed -i "s#^\(deb\(-src\)\?\) \[signed-by=${SIXPACK},${MARVIN}\] #\1 [signed-by=${MARVIN},${SIXPACK}] #" rootdir
/etc
/apt
/sources.list.d
/*
297 successfulaptgetupdate
298 testsuccessequal
"$(cat "${PKGFILE}")
301 rm -f rootdir
/etc
/apt
/trusted.gpg.d
/marvinparanoid.gpg
302 sed -i "s#^\(deb\(-src\)\?\) \[signed-by=${MARVIN},${SIXPACK}\] #\1 #" rootdir
/etc
/apt
/sources.list.d
/*
307 msgmsg
'Cold archive signed by' 'Joe Sixpack'
309 rm -rf rootdir
/var
/lib
/apt
/lists
310 signreleasefiles
'Joe Sixpack'
311 successfulaptgetupdate
313 # New .deb but now an unsigned archive. For example MITM to circumvent
314 # package verification.
315 msgmsg
'Warm archive signed by' 'nobody'
316 prepare
"${PKGFILE}-new"
317 find aptarchive
/ -name InRelease
-delete
318 find aptarchive
/ -name Release.gpg
-delete
319 updatewithwarnings
'W: .* no longer signed.'
320 testsuccessequal
"$(cat "${PKGFILE}-new")
324 # Unsigned archive from the beginning must also be detected.
325 msgmsg
'Cold archive signed by' 'nobody'
326 rm -rf rootdir
/var
/lib
/apt
/lists
327 updatewithwarnings
'W: .* is not signed.'
328 testsuccessequal
"$(cat "${PKGFILE}-new")
334 echo "APT::Hashes::$APT_TESTS_DIGEST_ALGO::$1 \"yes\";" > rootdir
/etc
/apt
/apt.conf.d
/truststate
335 msgmsg
"Running base test with $1 digest"
338 for DELETEFILE
in 'InRelease' 'Release.gpg'; do
339 msgmsg
"Running test with deletion of $DELETEFILE and $1 digest"
340 runtest
"$DELETEFILE"
344 # diable some protection by default and ensure we still do the verification
346 cat > rootdir
/etc
/apt
/apt.conf.d
/weaken
-security <<EOF
347 Acquire::AllowInsecureRepositories "1";
348 Acquire::AllowDowngradeToInsecureRepositories "1";
350 # the hash marked as configureable in our gpgv method
351 export APT_TESTS_DIGEST_ALGO
='SHA224'
353 successfulaptgetupdate
() {
354 testsuccess aptget update
-o Debug
::pkgAcquire
::Worker
=1 -o Debug
::Acquire
::gpgv
=1
356 cp rootdir
/tmp
/testsuccess.output aptupdate.output
357 testsuccess
grep "$1" aptupdate.output
362 successfulaptgetupdate
() {
363 testwarning aptget update
-o Debug
::pkgAcquire
::Worker
=1 -o Debug
::Acquire
::gpgv
=1
365 testsuccess
grep "$1" rootdir
/tmp
/testwarning.output
367 testsuccess
grep 'uses weak digest algorithm' rootdir
/tmp
/testwarning.output
371 msgmsg
"Running test with apt-untrusted digest"
372 echo "APT::Hashes::$APT_TESTS_DIGEST_ALGO::Untrusted \"yes\";" > rootdir
/etc
/apt
/apt.conf.d
/truststate
374 for DELETEFILE
in 'InRelease' 'Release.gpg'; do
375 msgmsg
'Cold archive signed by' 'Joe Sixpack'
377 rm -rf rootdir
/var
/lib
/apt
/lists
378 signreleasefiles
'Joe Sixpack'
379 find aptarchive
/ -name "$DELETEFILE" -delete
380 testfailure aptget update
--no-allow-insecure-repositories -o Debug
::pkgAcquire
::Worker
=1 -o Debug
::Acquire
::gpgv
=1
381 testsuccess
grep 'The following signatures were invalid' rootdir
/tmp
/testfailure.output
383 testwarning aptget update
--allow-insecure-repositories -o Debug
::pkgAcquire
::Worker
=1 -o Debug
::Acquire
::gpgv
=1
386 msgmsg
'Cold archive signed by' 'Marvin Paranoid'
388 rm -rf rootdir
/var
/lib
/apt
/lists
389 signreleasefiles
'Marvin Paranoid'
390 find aptarchive
/ -name "$DELETEFILE" -delete
391 testfailure aptget update
--no-allow-insecure-repositories -o Debug
::pkgAcquire
::Worker
=1 -o Debug
::Acquire
::gpgv
=1
393 updatewithwarnings
'^W: .* NO_PUBKEY'
394 testsuccessequal
"$(cat "${PKGFILE}")
401 msgmsg
"Running test with gpgv-untrusted digest"
402 export APT_TESTS_DIGEST_ALGO
='MD5'