summaryrefslogtreecommitdiff
path: root/src/share/mh/revoke_hostname
blob: 2142af7dbeb424757b94d58516b33b6e12a927cc (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=$(cat <<EOF
  48. $uidIndex
  49. revuid
  50. y
  51. 4
  52. Hostname removed by monkeysphere-host: $DATE
  53. y
  54. save
  55. EOF
  56. )
  57. # execute edit-key script
  58. if echo "$revuidCommand" | gpg_host_edit ; then
  59. update_gpg_pub_file
  60. show_key
  61. echo
  62. echo "NOTE: User ID revoked, but revocation not published."
  63. echo "Run '$PGRM publish-key' to publish the revocation."
  64. else
  65. failure "Problem revoking user ID."
  66. fi
  67. }