~ubuntu-branches/ubuntu/trusty/debian-keyring/trusty

« back to all changes in this revision

Viewing changes to scripts/move-key

  • Committer: Package Import Robot
  • Author(s): Gunnar Wolf
  • Date: 2013-07-29 17:51:00 UTC
  • Revision ID: package-import@ubuntu.com-20130729175100-jvgvt2uqlfj1y6o0
Tags: 2013.07.31
* Add new DD key 0xBFECAECBA0E7D8C3 (James Downing Page) (RT #4576)
* Add new DD key 0xF6947DAB68E7B931 (Hannes von Haugwitz) (RT #4577)
* Add new DD key 0xBE3219AF3ED41341 (Alberto Garcia) (RT #4578)
* Add new DD key 0x02285210789038F2 (Agustin Henze) (RT #4579)
* Add new DD key 0xB8E5087766475AAF (Nicolas Dandrimont) (RT #4580)
* Add new nonuploading key 0xC0F8864CDA3D0358 (Brian Gupta) (RT #4581)
* Add new DD key 0x69064B0195206DD3 (Richard Michael Hartmann) (RT
  #4582)
* Add new DD key 0xCF9A6F914193A197 (Jacob Appelbaum) (RT #4584)
* Added "move-key" script to speed up moving keys between keyrings
* Import changes sent to keyring.debian.org HKP interface:
  * 0x0907409606AAAAAA Jon Dowland <jmtd> sig:3
  * 0x16281F2E007C98D1 Francois Marier <francois> sig:10
  * 0x35FECD3FEB380BE6 Alexander List <alex> uid:1 sig:1
  * 0x416F061063FEE659 Erinn Clark <erinn> sig:6
  * 0x62AF4031C82E0039 Peter Palfrader <weasel> sig:30
  * 0x7174A18FAAA7A078 Asias He <asias> sig:5
  * 0x762B57BB784206AD David Bremner <bremner> sub:1 sig:3
  * 0x7F7606A445DCA80E Manuel A. Fernandez Montecelo <mafm> sig:4
  * 0x7FD9FCCB000BEEEE Jim Meyering <meyering> sig:3
  * 0x8CBF9A322861A790 Micah Anderson <micah> sig:2
  * 0x8F7BF8FC4A11C97A Ryan Kavanagh <rak> sig:13
  * 0x987689619ED101BF Michael Banck <mbanck> sig:26
  * 0x9BD2D6409A0C52FA Laszlo Kajan <lkajan> sig:3
  * 0x9C31503C6D866396 Stefano Zacchiroli <zack> sig:1
  * 0xB01FEA84617B586D Andreas B. Mundt <andi> sig:1
  * 0xB0E198D79057B5D3 Remi Vanicat <vanicat> sig:6
  * 0xB82A217AFDFE09F2 David Prévot <taffit> sig:4
  * 0xCAFB3BAD0A75C877 Nathan Harrison Handler <nhandler> sig:3
  * 0xD200EB30A0FB5DA6 Gustavo Noronha <kov> sig:4
  * 0x962680C5305A9418 Kåre Thor Olsen <kaare> uid:1 sig:2
  * 0x0A6268CF287D2531 UNKNOWN (DM?) sig:6
  * 0x1CF792111B5228B0 UNKNOWN (DM?) sig:3
  * 0x5556A34E04A3610B UNKNOWN (DM?) uid:1 sig:1
  * 0x6E608B637D8967E9 UNKNOWN (DM?) sig:4
  * 0x936A835B678B9796 UNKNOWN (DM?) sig:2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
 
 
3
# Copyright (c) 2013 Gunnar Wolf <gwolf@debian.org>,
 
4
#      Based on 2008 Jonathan McDowell <noodles@earth.li>
 
5
# GNU GPL; v2 or later
 
6
# Moves an existing key to another keyring directory
 
7
 
 
8
set -e
 
9
 
 
10
if [ -z "$1" ] || [ -z "$2" ]; then
 
11
        echo "Usage: move-key keyid dir" >&2
 
12
        exit 1
 
13
fi
 
14
 
 
15
key=$1
 
16
destdir=$(readlink -f $2)
 
17
 
 
18
# avoid gnupg touching ~/.gnupg
 
19
GNUPGHOME=$(mktemp -d -t jetring.XXXXXXXX)
 
20
export GNUPGHOME
 
21
trap cleanup exit
 
22
cleanup () {
 
23
        rm -rf "$GNUPGHOME"
 
24
}
 
25
 
 
26
if [ $(echo -n $key|wc -c) -eq 16 ]; then
 
27
    key='0x'$(echo $key|tr a-z A-Z)
 
28
elif [ $(echo -n $key|wc -c) -eq 40 ] ; then
 
29
    key='0x'$(echo -n $key | cut -b 25-)
 
30
fi
 
31
 
 
32
if [ ! -d "$destdir" ] || echo "$destdir"|grep -q -- '-gpg/?$'; then
 
33
    echo "Error: $destdir is not a valid keyring directory" >& 2
 
34
    exit 1
 
35
fi
 
36
 
 
37
for dir in *-gpg/; do
 
38
    if [ -f $dir/$key ]; then
 
39
        keyfile=$(readlink -f "$dir/$key")
 
40
        srcdir=$(readlink -f $dir)
 
41
        break
 
42
    fi
 
43
done
 
44
 
 
45
if [ "$srcdir" = "$destdir" ]; then
 
46
    echo "Source and destination directories are the same: $srcdir" >& 2
 
47
    exit 1
 
48
fi
 
49
 
 
50
if [ -z "$keyfile" ]; then
 
51
    echo "Requested key '$key' not found"
 
52
    exit 1
 
53
fi
 
54
 
 
55
keyuser=$(gpg --with-colons --keyid long --options /dev/null --no-auto-check-trustdb < $keyfile| grep '^pub' | cut -d : -f 10)
 
56
 
 
57
echo ""
 
58
echo "About to move key $key ($keyuser)"
 
59
echo "   FROM $srcdir"
 
60
echo "     TO $destdir"
 
61
echo "Are you sure you want to update this key? (y/n)"
 
62
read n
 
63
 
 
64
if [ "x$n" = "xy" -o "x$n" = "xY" ]; then
 
65
    add_to_keyid=""
 
66
    echo -n "Enter full name of new key's owner: "
 
67
    read name
 
68
    echo -n 'RT issue ID this change closes, if any: '
 
69
    read rtid
 
70
    rtid="(RT #$rtid)"
 
71
 
 
72
    if ( echo $destdir | egrep -q 'debian-keyring-gpg/?$' ); then
 
73
        log="Add new DD key $key ($name) $rtid"
 
74
        add_to_keyid=yes
 
75
    elif ( echo $destdir | egrep -q 'debian-nonupload-gpg/?$' ); then
 
76
        log="Add new nonuploading key $key ($name) $rtid"
 
77
        add_to_keyid=yes
 
78
    elif ( echo $destdir | egrep -q 'debian-maintainer-gpg/?$' ); then
 
79
        log="Add new DM key $key ($name) $rtid"
 
80
    elif ( echo $destdir | egrep -q 'debian-emeritus-gpg/?$' ); then
 
81
        log="Move $key to emeritus ($name) $rtid"
 
82
    elif ( echo $destdir | egrep -q 'debian-removed-gpg/?$' ); then
 
83
        log="Move $key ($name) to removed keyring $rtid"
 
84
    fi
 
85
 
 
86
    bzr mv $keyfile $destdir
 
87
    dch -D UNRELEASED -a "$log"
 
88
 
 
89
    if [ ! -z "$add_to_keyid" ]; then
 
90
        if oldkey=$(grep $key keyids); then
 
91
            echo "Key already present in the keyids file:"
 
92
            echo $oldkey
 
93
        else
 
94
            echo -n "Enter Debian login of new key: "
 
95
            read login
 
96
            echo "$key $name <$login>" >> keyids
 
97
            sort keyids > keyids.$$ && mv keyids.$$ keyids
 
98
        fi
 
99
    fi
 
100
else
 
101
    echo "Not moving key."
 
102
fi