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: .* EXPKEYSIG'
127 testsuccessequal
"$(cat "${PKGFILE}")
130 rm -f rootdir
/etc
/apt
/trusted.gpg.d
/rexexpired.gpg
132 msgmsg
'Cold archive expired signed by' 'Joe Sixpack'
133 if dpkg
--compare-versions "$(aptkey adv --version | head -n 2 | tail -n 1 | cut -d' ' -f 3)" '>=' '2.1' >/dev
/null
2>&1; then
134 touch rootdir
/etc
/apt
/apt.conf.d
/99gnupg2
135 elif gpg2
--version >/dev
/null
2>&1; then
136 echo 'Apt::Key::gpgcommand "gpg2";' > rootdir
/etc
/apt
/apt.conf.d
/99gnupg2
137 if ! dpkg
--compare-versions "$(aptkey adv --version | head -n 2 | tail -n 1 | cut -d' ' -f 3)" '>=' '2.1' >/dev
/null
2>&1; then
138 rm rootdir
/etc
/apt
/apt.conf.d
/99gnupg2
141 if [ -e rootdir
/etc
/apt
/apt.conf.d
/99gnupg2
]; then
143 rm -rf rootdir
/var
/lib
/apt
/lists
144 signreleasefiles
'Joe Sixpack' 'aptarchive' --faked-system-time "20070924T154812" --default-sig-expire 2016-04-01
145 find aptarchive
/ -name "$DELETEFILE" -delete
146 updatewithwarnings
'^W: .* EXPSIG'
147 testsuccessequal
"$(cat "${PKGFILE}")
150 rm -f rootdir
/etc
/apt
/apt.conf.d
/99gnupg2
152 msgskip
'Not a new enough gpg available providing --fake-system-time'
155 msgmsg
'Cold archive signed by' 'Joe Sixpack,Marvin Paranoid'
157 rm -rf rootdir
/var
/lib
/apt
/lists
158 signreleasefiles
'Joe Sixpack,Marvin Paranoid'
159 find aptarchive
/ -name "$DELETEFILE" -delete
160 successfulaptgetupdate
'NO_PUBKEY'
161 testsuccessequal
"$(cat "${PKGFILE}")
165 msgmsg
'Cold archive signed by' 'Joe Sixpack,Rex Expired'
167 rm -rf rootdir
/var
/lib
/apt
/lists
168 signreleasefiles
'Joe Sixpack,Rex Expired'
169 find aptarchive
/ -name "$DELETEFILE" -delete
170 cp keys
/rexexpired.pub rootdir
/etc
/apt
/trusted.gpg.d
/rexexpired.gpg
171 successfulaptgetupdate
'EXPKEYSIG'
172 rm -f rootdir
/etc
/apt
/trusted.gpg.d
/rexexpired.gpg
173 testsuccessequal
"$(cat "${PKGFILE}")
177 msgmsg
'Cold archive signed by' 'Marvin Paranoid'
179 rm -rf rootdir
/var
/lib
/apt
/lists
180 signreleasefiles
'Marvin Paranoid'
181 find aptarchive
/ -name "$DELETEFILE" -delete
182 updatewithwarnings
'^W: .* NO_PUBKEY'
183 testsuccessequal
"$(cat "${PKGFILE}")
187 msgmsg
'Bad warm archive signed by' 'Joe Sixpack'
188 prepare
"${PKGFILE}-new"
189 signreleasefiles
'Joe Sixpack'
190 find aptarchive
/ -name "$DELETEFILE" -delete
191 successfulaptgetupdate
192 testsuccessequal
"$(cat "${PKGFILE}-new")
196 msgmsg
'Cold archive signed by' 'Joe Sixpack'
198 rm -rf rootdir
/var
/lib
/apt
/lists
199 signreleasefiles
'Joe Sixpack'
200 find aptarchive
/ -name "$DELETEFILE" -delete
201 successfulaptgetupdate
202 testsuccessequal
"$(cat "${PKGFILE}")
206 msgmsg
'Good warm archive signed by' 'Marvin Paranoid'
207 prepare
"${PKGFILE}-new"
208 signreleasefiles
'Marvin Paranoid'
209 find aptarchive
/ -name "$DELETEFILE" -delete
210 updatewithwarnings
'^W: .* NO_PUBKEY'
211 testsuccessequal
"$(cat "${PKGFILE}")
215 msgmsg
'Good warm archive signed by' 'Rex Expired'
216 prepare
"${PKGFILE}-new"
217 cp keys
/rexexpired.pub rootdir
/etc
/apt
/trusted.gpg.d
/rexexpired.gpg
218 signreleasefiles
'Rex Expired'
219 find aptarchive
/ -name "$DELETEFILE" -delete
220 updatewithwarnings
'^W: .* EXPKEYSIG'
221 testsuccessequal
"$(cat "${PKGFILE}")
224 rm rootdir
/etc
/apt
/trusted.gpg.d
/rexexpired.gpg
226 msgmsg
'Good warm archive signed by' 'Joe Sixpack'
227 prepare
"${PKGFILE}-new"
229 find aptarchive
/ -name "$DELETEFILE" -delete
230 successfulaptgetupdate
231 testsuccessequal
"$(cat "${PKGFILE}-new")
235 msgmsg
'Cold archive signed by good keyring' 'Marvin Paranoid'
237 rm -rf rootdir
/var
/lib
/apt
/lists
238 signreleasefiles
'Marvin Paranoid'
239 find aptarchive
/ -name "$DELETEFILE" -delete
240 local MARVIN
="$(readlink -f keys/marvinparanoid.pub)"
241 sed -i "s#^\(deb\(-src\)\?\) #\1 [signed-by=$MARVIN] #" rootdir
/etc
/apt
/sources.list.d
/*
242 successfulaptgetupdate
243 testsuccessequal
"$(cat "${PKGFILE}")
247 msgmsg
'Cold archive signed by bad keyring' 'Joe Sixpack'
248 rm -rf rootdir
/var
/lib
/apt
/lists
249 signreleasefiles
'Joe Sixpack'
250 find aptarchive
/ -name "$DELETEFILE" -delete
251 updatewithwarnings
'^W: .* NO_PUBKEY'
253 sed -i "s#^\(deb\(-src\)\?\) \[signed-by=$MARVIN\] #\1 #" rootdir
/etc
/apt
/sources.list.d
/*
254 local MARVIN
="$(aptkey --keyring $MARVIN finger | grep 'Key fingerprint' | cut -d'=' -f 2 | tr -d ' ')"
256 msgmsg
'Cold archive signed by good keyid' 'Marvin Paranoid'
258 rm -rf rootdir
/var
/lib
/apt
/lists
259 signreleasefiles
'Marvin Paranoid'
260 find aptarchive
/ -name "$DELETEFILE" -delete
261 sed -i "s#^\(deb\(-src\)\?\) #\1 [signed-by=$MARVIN] #" rootdir
/etc
/apt
/sources.list.d
/*
262 cp keys
/marvinparanoid.pub rootdir
/etc
/apt
/trusted.gpg.d
/marvinparanoid.gpg
263 successfulaptgetupdate
264 testsuccessequal
"$(cat "${PKGFILE}")
267 rm -f rootdir
/etc
/apt
/trusted.gpg.d
/marvinparanoid.gpg
269 msgmsg
'Cold archive signed by bad keyid' 'Joe Sixpack'
270 rm -rf rootdir
/var
/lib
/apt
/lists
271 signreleasefiles
'Joe Sixpack'
272 find aptarchive
/ -name "$DELETEFILE" -delete
273 updatewithwarnings
'^W: .* be verified because the public key is not available: .*'
275 sed -i "s#^\(deb\(-src\)\?\) \[signed-by=$MARVIN\] #\1 #" rootdir
/etc
/apt
/sources.list.d
/*
279 msgmsg
'Cold archive signed by' 'Joe Sixpack'
281 rm -rf rootdir
/var
/lib
/apt
/lists
282 signreleasefiles
'Joe Sixpack'
283 successfulaptgetupdate
285 # New .deb but now an unsigned archive. For example MITM to circumvent
286 # package verification.
287 msgmsg
'Warm archive signed by' 'nobody'
288 prepare
"${PKGFILE}-new"
289 find aptarchive
/ -name InRelease
-delete
290 find aptarchive
/ -name Release.gpg
-delete
291 updatewithwarnings
'W: .* no longer signed.'
292 testsuccessequal
"$(cat "${PKGFILE}-new")
296 # Unsigned archive from the beginning must also be detected.
297 msgmsg
'Cold archive signed by' 'nobody'
298 rm -rf rootdir
/var
/lib
/apt
/lists
299 updatewithwarnings
'W: .* is not signed.'
300 testsuccessequal
"$(cat "${PKGFILE}-new")
306 echo "APT::Hashes::$APT_TESTS_DIGEST_ALGO::$1 \"yes\";" > rootdir
/etc
/apt
/apt.conf.d
/truststate
307 msgmsg
"Running base test with $1 digest"
310 for DELETEFILE
in 'InRelease' 'Release.gpg'; do
311 msgmsg
"Running test with deletion of $DELETEFILE and $1 digest"
312 runtest
"$DELETEFILE"
316 # diable some protection by default and ensure we still do the verification
318 cat > rootdir
/etc
/apt
/apt.conf.d
/weaken
-security <<EOF
319 Acquire::AllowInsecureRepositories "1";
320 Acquire::AllowDowngradeToInsecureRepositories "1";
322 # the hash marked as configureable in our gpgv method
323 export APT_TESTS_DIGEST_ALGO
='SHA224'
325 successfulaptgetupdate
() {
326 testsuccess aptget update
-o Debug
::pkgAcquire
::Worker
=1 -o Debug
::Acquire
::gpgv
=1
328 cp rootdir
/tmp
/testsuccess.output aptupdate.output
329 testsuccess
grep "$1" aptupdate.output
334 successfulaptgetupdate
() {
335 testwarning aptget update
-o Debug
::pkgAcquire
::Worker
=1 -o Debug
::Acquire
::gpgv
=1
337 testsuccess
grep "$1" rootdir
/tmp
/testwarning.output
339 testsuccess
grep 'uses weak digest algorithm' rootdir
/tmp
/testwarning.output
343 msgmsg
"Running test with apt-untrusted digest"
344 echo "APT::Hashes::$APT_TESTS_DIGEST_ALGO::Untrusted \"yes\";" > rootdir
/etc
/apt
/apt.conf.d
/truststate
346 for DELETEFILE
in 'InRelease' 'Release.gpg'; do
347 msgmsg
'Cold archive signed by' 'Joe Sixpack'
349 rm -rf rootdir
/var
/lib
/apt
/lists
350 signreleasefiles
'Joe Sixpack'
351 find aptarchive
/ -name "$DELETEFILE" -delete
352 testfailure aptget update
--no-allow-insecure-repositories -o Debug
::pkgAcquire
::Worker
=1 -o Debug
::Acquire
::gpgv
=1
353 testsuccess
grep 'The following signatures were invalid' rootdir
/tmp
/testfailure.output
355 testwarning aptget update
--allow-insecure-repositories -o Debug
::pkgAcquire
::Worker
=1 -o Debug
::Acquire
::gpgv
=1
358 msgmsg
'Cold archive signed by' 'Marvin Paranoid'
360 rm -rf rootdir
/var
/lib
/apt
/lists
361 signreleasefiles
'Marvin Paranoid'
362 find aptarchive
/ -name "$DELETEFILE" -delete
363 testfailure aptget update
--no-allow-insecure-repositories -o Debug
::pkgAcquire
::Worker
=1 -o Debug
::Acquire
::gpgv
=1
365 updatewithwarnings
'^W: .* NO_PUBKEY'
366 testsuccessequal
"$(cat "${PKGFILE}")
373 msgmsg
"Running test with gpgv-untrusted digest"
374 export APT_TESTS_DIGEST_ALGO
='MD5'