summaryrefslogtreecommitdiff
path: root/src/share/mh/revoke_hostname
blob: 44ba3122ad6b4c5543ecd913ebe7cb4816e5256f (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. This function has been known to occasionally revoke the wrong hostname.
  26. Please see the following bug report for more information:
  27. https://labs.riseup.net/code/issues/show/422" >&2
  28. printf "Are you sure you would like to proceed? (y/N) " >&2
  29. read OK; OK=${OK:=N}
  30. if [ ${OK/y/Y} != 'Y' ] ; then
  31. failure "aborting."
  32. fi
  33. userID="ssh://${1}"
  34. # make sure the user ID to revoke
  35. uidIndex=$(find_host_userid) || \
  36. failure "No non-revoked user ID found matching '$userID'."
  37. if [ "$PROMPT" = "true" ] ; then
  38. printf "The following host key user ID will be revoked:\n %s\nAre you sure you would like to revoke this user ID? (Y/n) " "$userID" >&2
  39. read 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. }