summaryrefslogtreecommitdiff
path: root/src/share/mh/revoke_hostname
blob: 99ba60350a569703290d3fdb49391d4cec32ef4b (plain)
  1. # -*-shell-script-*-
  2. # This should be sourced by bash (though we welcome changes to make it POSIX sh compliant)
  3. # Monkeysphere host revoke-hostname subcommand
  4. #
  5. # The monkeysphere scripts are written by:
  6. # Jameson Rollins <jrollins@finestructure.net>
  7. # Jamie McClelland <jm@mayfirst.org>
  8. # Daniel Kahn Gillmor <dkg@fifthhorseman.net>
  9. #
  10. # They are Copyright 2008-2009, and are all released under the GPL,
  11. # version 3 or later.
  12. # revoke hostname user ID from host key
  13. revoke_hostname() {
  14. local userID
  15. local fingerprint
  16. local tmpuidMatch
  17. local line
  18. local uidIndex
  19. local message
  20. local revuidCommand
  21. if [ -z "$1" ] ; then
  22. failure "You must specify a hostname to revoke."
  23. fi
  24. echo "WARNING: There is a known bug in this function."
  25. echo "This function has been known to occasionally revoke the wrong user ID."
  26. echo "Please see the following bug report for more information:"
  27. echo "https://labs.riseup.net/code/issues/show/422"
  28. read -p "Are you sure you would like to proceed? (y/N) " OK; OK=${OK:=N}
  29. if [ ${OK/y/Y} != 'Y' ] ; then
  30. failure "aborting."
  31. fi
  32. userID="ssh://${1}"
  33. # make sure the user ID to revoke
  34. uidIndex=$(find_host_userid) || \
  35. failure "No non-revoked user ID found matching '$userID'."
  36. echo "The following host key user ID will be revoked:"
  37. echo " $userID"
  38. read -p "Are you sure you would like to revoke this user ID? (y/N) " OK; OK=${OK:=N}
  39. if [ ${OK/y/Y} != 'Y' ] ; then
  40. failure "User ID not revoked."
  41. fi
  42. # edit-key script command to revoke user ID
  43. revuidCommand=$(cat <<EOF
  44. $uidIndex
  45. revuid
  46. y
  47. 4
  48. Hostname removed by monkeysphere-host: $DATE
  49. y
  50. save
  51. EOF
  52. )
  53. # execute edit-key script
  54. if echo "$revuidCommand" | gpg_host_edit ; then
  55. update_gpg_pub_file
  56. show_key
  57. echo
  58. echo "NOTE: User ID revoked, but revocation not published."
  59. echo "Run '$PGRM publish-key' to publish the revocation."
  60. else
  61. failure "Problem revoking user ID."
  62. fi
  63. }