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