Merge branch 'master' of git://lair.fifthhorseman.net/~dkg/monkeysphere
[monkeysphere.git] / src / share / ma / remove_certifier
1 # -*-shell-script-*-
2 # This should be sourced by bash (though we welcome changes to make it POSIX sh compliant)
3
4 # Monkeysphere authentication remove-certifier subcommand
5 #
6 # The monkeysphere scripts are written by:
7 # Jameson Rollins <jrollins@finestructure.net>
8 # Jamie McClelland <jm@mayfirst.org>
9 # Daniel Kahn Gillmor <dkg@fifthhorseman.net>
10 #
11 # They are Copyright 2008-2009, and are all released under the GPL,
12 # version 3 or later.
13
14 # delete a certifiers key from the host keyring
15
16 remove_certifier() {
17
18 local keyID
19 local fingerprint
20
21 keyID="$1"
22 if [ -z "$keyID" ] ; then
23     failure "You must specify the key ID of a key to remove."
24 fi
25
26 # FIXME: should we be doing a fancier list_certifier output here?
27 gpg_core --list-key --fingerprint "0x${keyID}!" || failure
28
29 if [ "$PROMPT" = "true" ] ; then
30     read -p "Really remove the above listed identity certifier? (Y/n) " OK; OK=${OK:-Y}
31     if [ "${OK/y/Y}" != 'Y' ] ; then
32         failure "Identity certifier not removed."
33     fi
34 else
35     log debug "certifier removed without prompting."
36 fi
37
38 # delete the requested key from the sphere keyring
39 if gpg_sphere "--delete-key --batch --yes 0x${keyID}!" ; then
40     # delete key from core keyring as well
41     gpg_core --delete-key --batch --yes "0x${keyID}!"
42
43     # update the trustdb for the authentication keyring
44     gpg_sphere "--check-trustdb"
45
46     log info "Identity certifier removed."
47 else
48     failure "Problem removing identity certifier."
49 fi
50
51 }