summaryrefslogtreecommitdiff
path: root/src/share/mh/revoke_hostname
blob: 5dc327f02c8a65a97e1fa4dd4dae1289bb15bc85 (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 hostname."
  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. if [ "$PROMPT" = "true" ] ; then
  37. read -p "The following host key user ID will be revoked:
  38. $userID
  39. Are you sure you would like to revoke this user ID? (Y/n) " OK; OK=${OK:=Y}
  40. if [ "${OK/y/Y}" != 'Y' ] ; then
  41. failure "User ID not revoked."
  42. fi
  43. else
  44. log debug "revoking user ID without prompting."
  45. fi
  46. # edit-key script command to revoke user ID
  47. revuidCommand="$uidIndex
  48. revuid
  49. y
  50. 4
  51. Hostname removed by monkeysphere-host: $DATE
  52. y
  53. save"
  54. # end script
  55. # execute edit-key script
  56. if echo "$revuidCommand" | gpg_host_edit ; then
  57. update_gpg_pub_file
  58. show_key
  59. echo
  60. echo "NOTE: User ID revoked, but revocation not published."
  61. echo "Run '$PGRM publish-key' to publish the revocation."
  62. else
  63. failure "Problem revoking user ID."
  64. fi
  65. }