4 TESTDIR
=$(readlink -f $(dirname $0))
8 configarchitecture
"i386"
12 mkdir -p aptarchive
/ubuntu
/project var
/lib
/apt
/keyrings
13 echo 'APT::Key::ArchiveKeyringURI "http://localhost:8080/ubuntu/project/ubuntu-archive-keyring.gpg";' >> .
/aptconfig.conf
14 echo 'APT::Key::Net-Update-Enabled "1";' >> .
/aptconfig.conf
17 echo "meep" > aptarchive
/ubuntu
/project
/ubuntu
-archive-keyring.gpg
19 # test against the "real" webserver
20 aptkey
--fakeroot net
-update
29 # extract net_update() and import it
30 func
=$( sed -n -e '/^add_keys_with_verify_against_master_keyring/,/^}/p' ${BUILDDIRECTORY}/apt-key )
34 TRUSTEDFILE
=.
/etc
/apt
/trusted.gpg
35 mkdir -p .
/var
/lib
/apt
/keyrings
36 TMP_KEYRING
=.
/var
/lib
/apt
/keyrings
/maybe
-import-keyring.gpg
37 GPG_CMD
="gpg --ignore-time-conflict --no-options --no-default-keyring"
39 # FIXME: instead of copying this use apt-key and the buildin apt webserver
42 # COPYIED from apt-key.in --------------
44 # gpg needs a trustdb to function, but it can't be invalid (not even empty)
45 # so we create a temporary directory to store our fresh readable trustdb in
46 TRUSTDBDIR
="$(mktemp -d)"
47 CURRENTTRAP
="${CURRENTTRAP} rm -rf '${TRUSTDBDIR}';"
48 trap "${CURRENTTRAP}" 0 HUP INT QUIT ILL ABRT FPE SEGV PIPE TERM
49 chmod 700 "$TRUSTDBDIR"
50 # We also don't use a secret keyring, of course, but gpg panics and
51 # implodes if there isn't one available - and writeable for imports
52 SECRETKEYRING
="${TRUSTDBDIR}/secring.gpg"
54 GPG_CMD
="$GPG_CMD --secret-keyring $SECRETKEYRING"
55 GPG_CMD
="$GPG_CMD --trustdb-name ${TRUSTDBDIR}/trustdb.gpg"
56 #----------------------------------------- END COPY
58 GPG
="$GPG_CMD --keyring $TRUSTEDFILE"
59 MASTER_KEYRING
=/usr
/share
/keyrings
/ubuntu
-master-keyring.gpg
61 msgtest
"add_keys_with_verify_against_master_keyring"
62 if [ ! -e $MASTER_KEYRING ]; then
63 echo -n "No $MASTER_KEYRING found"
68 # test bad keyring and ensure its not added (LP: #857472)
69 ADD_KEYRING
=.
/keys
/exploid
-keyring-with-dupe-keys.pub
70 if add_keys_with_verify_against_master_keyring
$ADD_KEYRING $MASTER_KEYRING; then
76 # ensure the keyring is still empty
77 gpg_out
=$($GPG --list-keys)
78 msgtest
"Test if keyring is empty"
86 # test another possible attack vector using subkeys (LP: #1013128)
87 msgtest
"add_keys_with_verify_against_master_keyring with subkey attack"
88 ADD_KEYRING
=.
/keys
/exploid
-keyring-with-dupe-subkeys.pub
89 if add_keys_with_verify_against_master_keyring
$ADD_KEYRING $MASTER_KEYRING; then
95 # ensure the keyring is still empty
96 gpg_out
=$($GPG --list-keys)
97 msgtest
"Test if keyring is empty"
105 # test good keyring and ensure we get no errors
106 ADD_KEYRING
=/usr
/share
/keyrings
/ubuntu
-archive-keyring.gpg
107 if add_keys_with_verify_against_master_keyring
$ADD_KEYRING $MASTER_KEYRING; then
113 testequal
'./etc/apt/trusted.gpg
114 ---------------------
115 pub 1024D/437D05B5 2004-09-12
116 uid Ubuntu Archive Automatic Signing Key <ftpmaster@ubuntu.com>
117 sub 2048g/79164387 2004-09-12
119 pub 1024D/FBB75451 2004-12-30
120 uid Ubuntu CD Image Automatic Signing Key <cdimage@ubuntu.com>
122 pub 4096R/C0B21F32 2012-05-11
123 uid Ubuntu Archive Automatic Signing Key (2012) <ftpmaster@ubuntu.com>
125 pub 4096R/EFE21092 2012-05-11
126 uid Ubuntu CD Image Automatic Signing Key (2012) <cdimage@ubuntu.com>