summaryrefslogtreecommitdiff
path: root/src/share/mh/set_expire
blob: 68a8dfd010754a76f251220eeb4da45729b55992 (plain)
  1. # -*-shell-script-*-
  2. # This should be sourced by bash (though we welcome changes to make it POSIX sh compliant)
  3. # Monkeysphere host set-expire subcommand
  4. #
  5. # This is a function to set the expiration date of the monkeysphere
  6. # host key.
  7. #
  8. # The monkeysphere scripts are written by:
  9. # Jameson Rollins <jrollins@finestructure.net>
  10. # Jamie McClelland <jm@mayfirst.org>
  11. # Daniel Kahn Gillmor <dkg@fifthhorseman.net>
  12. #
  13. # They are Copyright 2008-2010, and are all released under the GPL,
  14. # version 3 or later.
  15. set_expire() {
  16. local extendBy
  17. local keyID
  18. if [ -z "$1" ] ; then
  19. cat <<EOF >&2
  20. Must specify expiration. The possibilities are:
  21. 0 = key does not expire
  22. <n> = key expires in n days
  23. <n>w = key expires in n weeks
  24. <n>m = key expires in n months
  25. <n>y = key expires in n years
  26. EOF
  27. failure
  28. fi
  29. extendBy="$1"
  30. shift
  31. keyID=$(check_key_input "$@")
  32. if [ "$PROMPT" != "false" ] ; then
  33. printf "Are you sure you want to change the expiration on key '$keyID' by '%s'? (Y/n) " "$extendBy" >&2
  34. read OK; OK=${OK:-Y}
  35. if [ "${OK/y/Y}" != 'Y' ] ; then
  36. failure "expiration not set."
  37. fi
  38. else
  39. log debug "extending without prompting."
  40. fi
  41. log info "setting key expiration to ${extendBy}."
  42. log debug "executing key expire script..."
  43. gpg_host_edit "0x${keyID}!" expire <<EOF
  44. $extendBy
  45. save
  46. EOF
  47. update_pgp_pub_file
  48. log info <<EOF
  49. NOTE: Key expiration date adjusted, but not yet published.
  50. Run '$PGRM publish-key' to publish the new expiration date.
  51. EOF
  52. }