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
24 failure "You must specify a hostname to revoke."
27 echo "WARNING: There is a known bug in this function."
28 echo "This function has been known to occasionally revoke the wrong user ID."
29 echo "Please see the following bug report for more information:"
30 echo "http://web.monkeysphere.info/bugs/revoke-hostname-revoking-wrong-userid/"
31 read -p "Are you sure you would like to proceed? (y/N) " OK; OK=${OK:=N}
32 if [ ${OK/y/Y} != 'Y' ] ; then
38 fingerprint=$(fingerprint_server_key)
40 # match to only ultimately trusted user IDs
41 tmpuidMatch="u:$(echo $userID | gpg_escape)"
43 # find the index of the requsted user ID
44 # NOTE: this is based on circumstantial evidence that the order of
45 # this output is the appropriate index
46 if line=$(gpg_host --list-keys --with-colons --fixed-list-mode "0x${fingerprint}!" \
47 | egrep '^(uid|uat):' | cut -f2,10 -d: | grep -n -x -F "$tmpuidMatch") ; then
50 failure "No non-revoked user ID '$userID' is found."
53 echo "The following host key user ID will be revoked:"
55 read -p "Are you sure you would like to revoke this user ID? (y/N) " OK; OK=${OK:=N}
56 if [ ${OK/y/Y} != 'Y' ] ; then
57 failure "User ID not revoked."
60 message="Hostname removed by monkeysphere-server $DATE"
62 # edit-key script command to revoke user ID
63 revuidCommand=$(cat <<EOF
75 # execute edit-key script
76 if echo "$revuidCommand" | \
77 gpg_host --quiet --command-fd 0 --edit-key "0x${fingerprint}!" ; then
79 # update the trustdb for the authentication keyring
80 gpg_authentication "--check-trustdb"
85 echo "NOTE: User ID revoked, but revocation not published."
86 echo "Run '$PGRM publish-key' to publish the revocation."
88 failure "Problem revoking user ID."