summaryrefslogtreecommitdiff
path: root/src/share/mh/revoke_hostname
blob: 6b80802408ef0b2eb0a55f9cb422667d1bab813e (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. # the gpg secring might not contain the host key we are trying to
  38. # revoke (let alone any selfsig over that host key), but the plain
  39. # --export won't contain the secret key. "keytrans revokeuserid"
  40. # needs access to both pieces, so we feed it both of them.
  41. if (cat "$GNUPGHOME_HOST/secring.gpg" && gpg_host --export "$HOST_FINGERPRINT") | \
  42. "$SYSSHAREDIR/keytrans" revokeuserid \
  43. "$HOST_FINGERPRINT" "$userID" | gpg_host --import ; then
  44. gpg_host --check-trustdb
  45. update_gpg_pub_file
  46. show_key
  47. echo
  48. echo "NOTE: User ID revoked, but revocation not published."
  49. echo "Run '$PGRM publish-key' to publish the revocation."
  50. else
  51. failure "Problem revoking user ID."
  52. fi
  53. }