2 # This should be sourced by bash (though we welcome changes to make it POSIX sh compliant)
4 # Monkeysphere host revoke-hostname subcommand
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>
11 # They are Copyright 2008-2009, and are all released under the GPL,
14 # revoke hostname user ID from host key
27 failure "You must specify a hostname to revoke."
30 echo "WARNING: There is a known bug in this function."
31 echo "This function has been known to occasionally revoke the wrong user ID."
32 echo "Please see the following bug report for more information:"
33 echo "http://web.monkeysphere.info/bugs/revoke-hostname-revoking-wrong-userid/"
34 read -p "Are you sure you would like to proceed? (y/N) " OK; OK=${OK:=N}
35 if [ ${OK/y/Y} != 'Y' ] ; then
41 fingerprint=$(fingerprint_server_key)
43 # match to only ultimately trusted user IDs
44 tmpuidMatch="u:$(echo $userID | gpg_escape)"
46 # find the index of the requsted user ID
47 # NOTE: this is based on circumstantial evidence that the order of
48 # this output is the appropriate index
49 if line=$(gpg_host --list-keys --with-colons --fixed-list-mode "0x${fingerprint}!" \
50 | egrep '^(uid|uat):' | cut -f2,10 -d: | grep -n -x -F "$tmpuidMatch") ; then
53 failure "No non-revoked user ID '$userID' is found."
56 echo "The following host key user ID will be revoked:"
58 read -p "Are you sure you would like to revoke this user ID? (y/N) " OK; OK=${OK:=N}
59 if [ ${OK/y/Y} != 'Y' ] ; then
60 failure "User ID not revoked."
63 message="Hostname removed by monkeysphere-server $DATE"
65 # edit-key script command to revoke user ID
66 revuidCommand=$(cat <<EOF
78 # execute edit-key script
79 if echo "$revuidCommand" | \
80 gpg_host --quiet --command-fd 0 --edit-key "0x${fingerprint}!" ; then
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."