more big cleanup of host/authentication commands to reflect new
[monkeysphere.git] / src / subcommands / ma / remove-certifier
1 #!/usr/bin/env bash
2
3 # Monkeysphere authentication remove-certifier subcommand
4 #
5 # The monkeysphere scripts are written by:
6 # Jameson Rollins <jrollins@fifthhorseman.net>
7 # Jamie McClelland <jm@mayfirst.org>
8 # Daniel Kahn Gillmor <dkg@fifthhorseman.net>
9 #
10 # They are Copyright 2008, and are all released under the GPL, version 3
11 # or later.
12
13 # delete a certifiers key from the host keyring
14
15 remove_certifier() {
16
17 local keyID
18 local fingerprint
19
20 keyID="$1"
21 if [ -z "$keyID" ] ; then
22     failure "You must specify the key ID of a key to remove."
23 fi
24
25 if gpg_sphere "--no-options --list-options show-uid-validity --keyring ${GNUPGHOME_AUTHENTICATION}/pubring.gpg --list-key 0x${keyID}!" ; then
26     read -p "Really remove above listed identity certifier? (y/N) " OK; OK=${OK:-N}
27     if [ "${OK/y/Y}" != 'Y' ] ; then
28         failure "Identity certifier not removed."
29     fi
30 else
31     failure
32 fi
33
34 # delete the requested key
35 if gpg_sphere "--delete-key --batch --yes 0x${keyID}!" ; then
36     # delete key from host keyring as well
37     gpg_core --delete-key --batch --yes "0x${keyID}!"
38
39     # update the trustdb for the authentication keyring
40     gpg_sphere "--check-trustdb"
41
42     echo
43     echo "Identity certifier removed."
44 else
45     failure "Problem removing identity certifier."
46 fi
47
48 }