~l3on/ubuntu/lucid/apt/fix-917845

« back to all changes in this revision

Viewing changes to cmdline/apt-key

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2011-11-22 13:56:02 UTC
  • mfrom: (104.1.9 lucid-proposed)
  • Revision ID: package-import@ubuntu.com-20111122135602-scxagfxmbpajhgvi
Tags: 0.7.25.3ubuntu9.9
* SECURITY UPDATE: sensitive information disclosure via incorrect
  hostname validation (LP: #868353)
  - methods/https.cc: properly set CURLOPT_SSL_VERIFYHOST.
  - CVE-2011-3634
* SECURITY UPDATE: Restore apt-ket net-update functionality (LP: #857472)
  - cmdline/apt-key: improve key validation.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
ARCHIVE_KEYRING=/usr/share/keyrings/ubuntu-archive-keyring.gpg
13
13
REMOVED_KEYS=/usr/share/keyrings/ubuntu-archive-removed-keys.gpg
14
14
ARCHIVE_KEYRING_URI=http://archive.ubuntu.com/ubuntu/project/ubuntu-archive-keyring.gpg
 
15
TMP_KEYRING=/var/lib/apt/keyrings/maybe-import-keyring.gpg
15
16
 
16
17
add_keys_with_verify_against_master_keyring() {
17
18
    ADD_KEYRING=$1
18
19
    MASTER=$2
19
 
    
 
20
 
20
21
    if [ ! -f "$ADD_KEYRING" ]; then
21
22
        echo "ERROR: '$ADD_KEYRING' not found"
22
23
        return
32
33
    #   from a key in the $distro-master-keyring
33
34
    add_keys=`$GPG_CMD --keyring $ADD_KEYRING --with-colons --list-keys | grep ^pub | cut -d: -f5`
34
35
    master_keys=`$GPG_CMD --keyring $MASTER --with-colons --list-keys | grep ^pub | cut -d: -f5`
 
36
    
35
37
    for add_key in $add_keys; do
36
 
        ADDED=0
37
 
        for master_key in $master_keys; do
38
 
            if $GPG_CMD --keyring $ADD_KEYRING --list-sigs --with-colons $add_key | grep ^sig | cut -d: -f5 | grep -q $master_key; then
39
 
                $GPG_CMD --quiet --batch --keyring $ADD_KEYRING --export $add_key | $GPG --import
 
38
 
 
39
        # ensure there are no colisions LP: #857472
 
40
        for master_key in $master_keys; do
 
41
            if [ "$add_key" = "$master_key" ]; then
 
42
                echo >&2 "Keyid collision for '$add_key' detected, operation aborted"
 
43
                return 1
 
44
            fi
 
45
        done
 
46
 
 
47
        # export the add keyring one-by-one
 
48
        rm -f $TMP_KEYRING
 
49
        $GPG_CMD --keyring $ADD_KEYRING --output $TMP_KEYRING --export $add_key 
 
50
        # check if signed with the master key and only add in this case
 
51
        ADDED=0
 
52
        for master_key in $master_keys; do
 
53
            if $GPG_CMD --keyring $MASTER --keyring $TMP_KEYRING --check-sigs --with-colons $add_key | grep '^sig:!:' | cut -d: -f5 | grep -q $master_key; then
 
54
                $GPG --import $TMP_KEYRING
40
55
                ADDED=1
41
56
            fi
42
57
        done
44
59
            echo >&2 "Key '$add_key' not added. It is not signed with a master key"
45
60
        fi
46
61
    done
 
62
    rm -f $TMP_KEYRING
47
63
}
48
64
 
49
65
# update the current archive signing keyring from a network URI
50
66
# the archive-keyring keys needs to be signed with the master key
51
67
# (otherwise it does not make sense from a security POV)
52
68
net_update() {
53
 
    # Disabled for now as code is insecure
54
 
    exit 1
55
69
 
56
70
    if [ -z "$ARCHIVE_KEYRING_URI" ]; then
57
71
        echo "ERROR: no location for the archive-keyring given"