diff options
author | Jameson Rollins <jrollins@finestructure.net> | 2010-07-04 00:16:26 -0400 |
---|---|---|
committer | Jameson Rollins <jrollins@finestructure.net> | 2010-07-04 00:16:26 -0400 |
commit | 1aa3096af58da671b674409010bbd7f3a73332ac (patch) | |
tree | bdd66e0c98c3e14bd79372606bd1d9bfe3452b15 /src/share | |
parent | 330d2eca0d43bcf54b535212d56d4a5b1b218ced (diff) | |
parent | f97dd58a298cf337a1fffa00d3733256d21d2d8f (diff) |
Merge remote branch 'dkg/master'
Diffstat (limited to 'src/share')
-rw-r--r-- | src/share/mh/set_expire | 27 |
1 files changed, 21 insertions, 6 deletions
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 <<EOF >&2 -Must specify expiration. The possibilities are: +local formatMsg=' +The possibilities are: 0 = key does not expire <n> = key expires in n days <n>w = key expires in n weeks <n>m = key expires in n months - <n>y = key expires in n years -EOF - failure + <n>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 <<EOF NOTE: Key expiration date adjusted, but not yet published. Run '$PGRM publish-key' to publish the new expiration date. |