3 # Monkeysphere host revoke-hostname subcommand
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>
10 # They are Copyright 2008, and are all released under the GPL, version 3
13 # revoke hostname user ID from host key
26 failure "You must specify a hostname to revoke."
29 echo "WARNING: There is a known bug in this function."
30 echo "This function has been known to occasionally revoke the wrong user ID."
31 echo "Please see the following bug report for more information:"
32 echo "http://web.monkeysphere.info/bugs/revoke-hostname-revoking-wrong-userid/"
33 read -p "Are you sure you would like to proceed? (y/N) " OK; OK=${OK:=N}
34 if [ ${OK/y/Y} != 'Y' ] ; then
40 fingerprint=$(fingerprint_server_key)
42 # match to only ultimately trusted user IDs
43 tmpuidMatch="u:$(echo $userID | gpg_escape)"
45 # find the index of the requsted user ID
46 # NOTE: this is based on circumstantial evidence that the order of
47 # this output is the appropriate index
48 if line=$(gpg_host --list-keys --with-colons --fixed-list-mode "0x${fingerprint}!" \
49 | egrep '^(uid|uat):' | cut -f2,10 -d: | grep -n -x -F "$tmpuidMatch") ; then
52 failure "No non-revoked user ID '$userID' is found."
55 echo "The following host key user ID will be revoked:"
57 read -p "Are you sure you would like to revoke this user ID? (y/N) " OK; OK=${OK:=N}
58 if [ ${OK/y/Y} != 'Y' ] ; then
59 failure "User ID not revoked."
62 message="Hostname removed by monkeysphere-server $DATE"
64 # edit-key script command to revoke user ID
65 revuidCommand=$(cat <<EOF
77 # execute edit-key script
78 if echo "$revuidCommand" | \
79 gpg_host --quiet --command-fd 0 --edit-key "0x${fingerprint}!" ; then
81 # update the trustdb for the authentication keyring
82 gpg_authentication "--check-trustdb"
87 echo "NOTE: User ID revoked, but revocation not published."
88 echo "Run '$PGRM publish-key' to publish the revocation."
90 failure "Problem revoking user ID."