summaryrefslogtreecommitdiff
path: root/src/share/mh/revoke_name
blob: d080704b75b9f7e3410bc732a19566548ab492bd (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-2010, and are all released under the GPL,
  11. # version 3 or later.
  12. # revoke service name user ID from host key
  13. revoke_name() {
  14. local serviceName
  15. local keyID
  16. local fingerprint
  17. local tmpuidMatch
  18. local line
  19. local message
  20. local revuidCommand
  21. if [ -z "$1" ] ; then
  22. failure "You must specify a service name to revoke."
  23. fi
  24. serviceName="$1"
  25. shift
  26. keyID=$(check_key_input "$@")
  27. # make sure the user ID to revoke exists
  28. check_key_userid "$keyID" "$serviceName" || \
  29. failure "No non-revoked service name found matching '$serviceName'."
  30. if [ "$PROMPT" = "true" ] ; then
  31. printf "The following service name on key '$keyID' will be revoked:\n %s\nAre you sure you would like to revoke this service name? (Y/n) " "$serviceName" >&2
  32. read OK; OK=${OK:=Y}
  33. if [ "${OK/y/Y}" != 'Y' ] ; then
  34. failure "User ID not revoked."
  35. fi
  36. else
  37. log debug "revoking service name without prompting."
  38. fi
  39. # actually revoke:
  40. # the gpg secring might not contain the host key we are trying to
  41. # revoke (let alone any selfsig over that host key), but the plain
  42. # --export won't contain the secret key. "keytrans revokeuserid"
  43. # needs access to both pieces, so we feed it both of them.
  44. if (cat "$GNUPGHOME_HOST/secring.gpg" && gpg_host --export "$keyID") \
  45. | "$SYSSHAREDIR/keytrans" revokeuserid "$keyID" "$serviceName" \
  46. | gpg_host --import ; then
  47. gpg_host --check-trustdb
  48. update_gpg_pub_file
  49. show_key "$keyID"
  50. echo
  51. echo "NOTE: Service name revoked, but revocation not published."
  52. echo "Run '$PGRM publish-key' to publish the revocation."
  53. else
  54. failure "Problem revoking service name."
  55. fi
  56. }