Merge commit 'mjgoins/master'
[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 if gpg_sphere "--no-options --list-options show-uid-validity --keyring ${GNUPGHOME_AUTHENTICATION}/pubring.gpg --list-key 0x${keyID}!" ; then
27     read -p "Really remove above listed identity certifier? (y/N) " OK; OK=${OK:-N}
28     if [ "${OK/y/Y}" != 'Y' ] ; then
29         failure "Identity certifier not removed."
30     fi
31 else
32     failure
33 fi
34
35 # delete the requested key
36 if gpg_sphere "--delete-key --batch --yes 0x${keyID}!" ; then
37     # delete key from host keyring as well
38     gpg_core --delete-key --batch --yes "0x${keyID}!"
39
40     # update the trustdb for the authentication keyring
41     gpg_sphere "--check-trustdb"
42
43     echo
44     echo "Identity certifier removed."
45 else
46     failure "Problem removing identity certifier."
47 fi
48
49 }