renaming m-h update_gpg_pub_file to update_pgp_pub_file
[monkeysphere.git] / src / share / mh / set_expire
index 0b581d99fa5aadf456b8c5169ae5598d5e23f6f3..be3f6bb4b8cdc61ff8b28b046464b64ad3db640e 100644 (file)
 # Jamie McClelland <jm@mayfirst.org>
 # Daniel Kahn Gillmor <dkg@fifthhorseman.net>
 #
-# They are Copyright 2008-2009, and are all released under the GPL,
+# They are Copyright 2008-2010, and are all released under the GPL,
 # version 3 or later.
 
 set_expire() {
 
-local extendTo
-
-# get the new expiration date
-extendTo=$(get_gpg_expiration "$1")
-
-log info "setting host key expiration to ${extendTo}:"
-
-log debug "executing host expire script..."
-gpg_host_edit expire <<EOF
-$extendTo
+local extendBy
+local keyID
+
+if [ -z "$1" ] ; then
+    cat <<EOF >&2
+Must specify expiration.  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
+fi
+extendBy="$1"
+shift
+
+keyID=$(check_key_input "$@")
+
+if [ "$PROMPT" = "true" ] ; then
+    printf "Are you sure you want to change the expiration on key '$keyID' by '%s'? (Y/n) " "$extendBy" >&2
+    read OK; OK=${OK:-Y}
+    if [ "${OK/y/Y}" != 'Y' ] ; then
+       failure "expiration not set."
+    fi
+else
+    log debug "extending without prompting."
+fi
+
+log info "setting key expiration to ${extendBy}."
+
+log debug "executing key expire script..."
+gpg_host_edit "0x${keyID}!" expire <<EOF
+$extendBy
 save
 EOF
 
-update_gpg_pub_file
+update_pgp_pub_file
 
-cat <<EOF | log info
-NOTE: Host key expiration date adjusted, but not yet published.
+log info <<EOF
+NOTE: Key expiration date adjusted, but not yet published.
 Run '$PGRM publish-key' to publish the new expiration date.
 EOF