summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJameson Graef Rollins <jrollins@phys.columbia.edu>2008-08-24 23:57:09 -0700
committerJameson Graef Rollins <jrollins@phys.columbia.edu>2008-08-24 23:57:09 -0700
commit050302344aba552900a199d76fab57fd49c05795 (patch)
tree2d9165f527c1eca667cd74ca16f74d270d239d6f /src
parent140fd9b87865c53ead7b16c28a8bc040c2650026 (diff)
tweaked the key expiration checking function, and replied to SJJ's bug
comment.
Diffstat (limited to 'src')
-rw-r--r--src/common25
-rwxr-xr-xsrc/monkeysphere20
-rwxr-xr-xsrc/monkeysphere-server15
3 files changed, 20 insertions, 40 deletions
diff --git a/src/common b/src/common
index 44bdb67..d90730f 100644
--- a/src/common
+++ b/src/common
@@ -85,9 +85,12 @@ gpg_escape() {
# prompt for GPG-formatted expiration, and emit result on stdout
get_gpg_expiration() {
- local keyExpire=
+ local keyExpire
- cat >&2 <<EOF
+ keyExpire="$1"
+
+ if [ -z "$keyExpire" ]; then
+ cat >&2 <<EOF
Please specify how long the key should be valid.
0 = key does not expire
<n> = key expires in n days
@@ -95,13 +98,17 @@ Please specify how long the key should be valid.
<n>m = key expires in n months
<n>y = key expires in n years
EOF
- while [ -z "$keyExpire" ] ; do
- read -p "Key is valid for? (0) " keyExpire
- if ! test_gpg_expire ${keyExpire:=0} ; then
- echo "invalid value" >&2
- unset keyExpire
- fi
- done
+ while [ -z "$keyExpire" ] ; do
+ read -p "Key is valid for? (0) " keyExpire
+ if ! test_gpg_expire ${keyExpire:=0} ; then
+ echo "invalid value" >&2
+ unset keyExpire
+ fi
+ done
+ elif ! test_gpg_expire "$keyExpire" ; then
+ failure "invalid key expiration value '$keyExpire'."
+ fi
+
echo "$keyExpire"
}
diff --git a/src/monkeysphere b/src/monkeysphere
index 8936668..2690db8 100755
--- a/src/monkeysphere
+++ b/src/monkeysphere
@@ -128,25 +128,7 @@ key before joining the monkeysphere. You can do this with:
# set subkey defaults
# prompt about key expiration if not specified
- if [ -z "$keyExpire" ] ; then
- cat <<EOF
-Please specify how long the key should be valid.
- 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
- while [ -z "$keyExpire" ] ; do
- read -p "Key is valid for? (0) " keyExpire
- if ! test_gpg_expire ${keyExpire:=0} ; then
- echo "invalid value"
- unset keyExpire
- fi
- done
- elif ! test_gpg_expire "$keyExpire" ; then
- failure "invalid key expiration value '$keyExpire'."
- fi
+ keyExpire=$(get_gpg_expiration "$keyExpire")
# generate the list of commands that will be passed to edit-key
editCommands=$(cat <<EOF
diff --git a/src/monkeysphere-server b/src/monkeysphere-server
index 3c4eed4..4c8ecdc 100755
--- a/src/monkeysphere-server
+++ b/src/monkeysphere-server
@@ -308,12 +308,7 @@ gen_key() {
fi
# prompt about key expiration if not specified
- if [ -z "$keyExpire" ] ; then
- keyExpire=$(get_gpg_expiration)
- fi
- if ! test_gpg_expire "$keyExpire" ; then
- failure "invalid key expiration value '$keyExpire'."
- fi
+ keyExpire=$(get_gpg_expiration "$keyExpire")
# set key parameters
keyParameters=$(cat <<EOF
@@ -382,12 +377,8 @@ extend_key() {
failure "You don't appear to have a MonkeySphere host key on this server. Try 'monkeysphere-server gen-key' first."
fi
- if [ -z "$extendTo" ]; then
- extendTo=$(get_gpg_expiration)
- fi
- if ! test_gpg_expire "$extendTo" ; then
- failure "invalid expiration value '$extendTo'."
- fi
+ # get the new expiration date
+ extendTo=$(get_gpg_expiration "$extendTo")
gpg_host --quiet --command-fd 0 --edit-key "$fpr" <<EOF
expire