4 TESTDIR
=$(readlink -f $(dirname $0))
8 configarchitecture
"i386"
15 # extract net_update() and import it
16 func
=$( sed -n -e '/^add_keys_with_verify_against_master_keyring/,/^}/p' ${BUILDDIRECTORY}/apt-key )
20 TRUSTEDFILE
=.
/etc
/apt
/trusted.gpg
21 mkdir -p .
/var
/lib
/apt
/keyrings
22 TMP_KEYRING
=.
/var
/lib
/apt
/keyrings
/maybe
-import-keyring.gpg
23 GPG_CMD
="gpg --ignore-time-conflict --no-options --no-default-keyring"
25 # FIXME: instead of copying this use apt-key and the buildin apt webserver
28 # COPYIED from apt-key.in --------------
30 # gpg needs a trustdb to function, but it can't be invalid (not even empty)
31 # so we create a temporary directory to store our fresh readable trustdb in
32 TRUSTDBDIR
="$(mktemp -d)"
33 CURRENTTRAP
="${CURRENTTRAP} rm -rf '${TRUSTDBDIR}';"
34 trap "${CURRENTTRAP}" 0 HUP INT QUIT ILL ABRT FPE SEGV PIPE TERM
35 chmod 700 "$TRUSTDBDIR"
36 # We also don't use a secret keyring, of course, but gpg panics and
37 # implodes if there isn't one available - and writeable for imports
38 SECRETKEYRING
="${TRUSTDBDIR}/secring.gpg"
40 GPG_CMD
="$GPG_CMD --secret-keyring $SECRETKEYRING"
41 GPG_CMD
="$GPG_CMD --trustdb-name ${TRUSTDBDIR}/trustdb.gpg"
42 #----------------------------------------- END COPY
44 GPG
="$GPG_CMD --keyring $TRUSTEDFILE"
45 MASTER_KEYRING
=/usr
/share
/keyrings
/ubuntu
-master-keyring.gpg
47 msgtest
"add_keys_with_verify_against_master_keyring"
48 if [ ! -e $MASTER_KEYRING ]; then
49 echo -n "No $MASTER_KEYRING found"
54 # test bad keyring and ensure its not added (LP: #857472)
55 ADD_KEYRING
=.
/keys
/exploid
-keyring-with-dupe-keys.pub
56 if add_keys_with_verify_against_master_keyring
$ADD_KEYRING $MASTER_KEYRING; then
62 # ensure the keyring is still empty
63 gpg_out
=$($GPG --list-keys)
64 msgtest
"Test if keyring is empty"
72 # test another possible attack vector using subkeys (LP: #1013128)
73 msgtest
"add_keys_with_verify_against_master_keyring with subkey attack"
74 ADD_KEYRING
=.
/keys
/exploid
-keyring-with-dupe-subkeys.pub
75 if add_keys_with_verify_against_master_keyring
$ADD_KEYRING $MASTER_KEYRING; then
81 # ensure the keyring is still empty
82 gpg_out
=$($GPG --list-keys)
83 msgtest
"Test if keyring is empty"
91 # test good keyring and ensure we get no errors
92 ADD_KEYRING
=/usr
/share
/keyrings
/ubuntu
-archive-keyring.gpg
93 if add_keys_with_verify_against_master_keyring
$ADD_KEYRING $MASTER_KEYRING; then
99 testequal
'./etc/apt/trusted.gpg
100 ---------------------
101 pub 1024D/437D05B5 2004-09-12
102 uid Ubuntu Archive Automatic Signing Key <ftpmaster@ubuntu.com>
103 sub 2048g/79164387 2004-09-12
105 pub 1024D/FBB75451 2004-12-30
106 uid Ubuntu CD Image Automatic Signing Key <cdimage@ubuntu.com>
108 pub 4096R/C0B21F32 2012-05-11
109 uid Ubuntu Archive Automatic Signing Key (2012) <ftpmaster@ubuntu.com>
111 pub 4096R/EFE21092 2012-05-11
112 uid Ubuntu CD Image Automatic Signing Key (2012) <cdimage@ubuntu.com>