From f97dd58a298cf337a1fffa00d3733256d21d2d8f Mon Sep 17 00:00:00 2001 From: Daniel Kahn Gillmor Date: Thu, 6 May 2010 22:25:28 -0400 Subject: reporting new expiration date when key expiry is updated (closes MS #2291) --- Changelog | 2 ++ src/monkeysphere-host | 2 +- src/share/mh/set_expire | 27 +++++++++++++++++++++------ 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/Changelog b/Changelog index d6a7a56..35197d0 100644 --- a/Changelog +++ b/Changelog @@ -4,6 +4,8 @@ monkeysphere (0.31~pre) UNRELEASED; urgency=low between m-h and m-a (closes MS #2288) * do not bail or fail on m-h publish-key if the admin interactively declines to publish one of the keys key (closes MS #1945) + * report updated expiration date upon successful conclusion of m-h + set-expire (closes MS #2291) -- Daniel Kahn Gillmor Thu, 06 May 2010 11:23:38 -0400 diff --git a/src/monkeysphere-host b/src/monkeysphere-host index 13cc3ca..6216dce 100755 --- a/src/monkeysphere-host +++ b/src/monkeysphere-host @@ -74,7 +74,7 @@ EOF # function to interact with the gpg keyring gpg_host() { - GNUPGHOME="$GNUPGHOME_HOST" gpg --no-auto-check-trustdb --no-greeting --quiet --no-tty "$@" + GNUPGHOME="$GNUPGHOME_HOST" gpg --no-auto-check-trustdb --trust-model=always --no-greeting --quiet --no-tty "$@" } # list the info about the a key, in colon format, to stdout diff --git a/src/share/mh/set_expire b/src/share/mh/set_expire index 68a8dfd..f9a5507 100644 --- a/src/share/mh/set_expire +++ b/src/share/mh/set_expire @@ -19,20 +19,25 @@ set_expire() { local extendBy local keyID -if [ -z "$1" ] ; then - cat <&2 -Must specify expiration. The possibilities are: +local formatMsg=' +The possibilities are: 0 = key does not expire = key expires in n days w = key expires in n weeks m = key expires in n months - y = key expires in n years -EOF - failure + y = key expires in n years' + + +if [ -z "$1" ] ; then + failure "Must specify expiration.$formatMsg" fi extendBy="$1" shift +if ! <<<"$extendBy" egrep -q '^[[:digit:]]+[wmy]?$' ; then + failure "'$extendBy' is not a valid expiration date.$formatMsg" +fi + keyID=$(check_key_input "$@") if [ "$PROMPT" != "false" ] ; then @@ -55,6 +60,16 @@ EOF update_pgp_pub_file +if [ 0 == "$extendBy" ] ; then + log info "Key ${keyID} no longer expires." +else + if expiry=$(gpg_host_list_keys "${keyID}" | grep ^pub: | head -n1 | cut -f7 -d: ) ; then + log info "Key ${keyID} now expires at $(date '+%F %T' --date "1970-01-01 0:00 UTC + ${expiry} seconds")" + else + log error "Failed to retrieve new expiration date for key ${keyID}" + fi +fi + log info <