summaryrefslogtreecommitdiff
path: root/src/share/mh/revoke_hostname
blob: 7e4d573beab3fd038330f6582a0f38182c5a904b (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. userID="ssh://${1}"
  25. # make sure the user ID to revoke
  26. uidIndex=$(find_host_userid) || \
  27. failure "No non-revoked user ID found matching '$userID'."
  28. if [ "$PROMPT" = "true" ] ; then
  29. 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
  30. read OK; OK=${OK:=Y}
  31. if [ "${OK/y/Y}" != 'Y' ] ; then
  32. failure "User ID not revoked."
  33. fi
  34. else
  35. log debug "revoking user ID without prompting."
  36. fi
  37. # actually revoke:
  38. if <"$GNUPGHOME_HOST/secring.gpg" "$SYSSHAREDIR/keytrans" revokeuserid \
  39. "$HOST_FINGERPRINT" "$userID" | gpg_host --import ; then
  40. gpg_host --check-trustdb
  41. update_gpg_pub_file
  42. show_key
  43. echo
  44. echo "NOTE: User ID revoked, but revocation not published."
  45. echo "Run '$PGRM publish-key' to publish the revocation."
  46. else
  47. failure "Problem revoking user ID."
  48. fi
  49. }