X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=src%2Fmonkeysphere;h=a25fd6a64257a780fc6628842f119218a1f198ee;hb=5fadec09dcd44c4dcad657a0f3d96878b592b77b;hp=d8d4667c9201a6b286527d39aef6ce07916981dc;hpb=7d02db7106da26f7705563297544a4ba1edfc71b;p=monkeysphere.git diff --git a/src/monkeysphere b/src/monkeysphere index d8d4667..a25fd6a 100755 --- a/src/monkeysphere +++ b/src/monkeysphere @@ -11,21 +11,18 @@ ######################################################################## PGRM=$(basename $0) -SHAREDIR=${SHAREDIR:-"/usr/share/monkeysphere"} -export SHAREDIR -. "${SHAREDIR}/common" - -GLOBAL_CONFIG=${GLOBAL_CONFIG:-"${ETC}/monkeysphere.conf"} -[ -r "$GLOBAL_CONFIG" ] && . "$GLOBAL_CONFIG" +SHARE=${MONKEYSPHERE_SHARE:-"/usr/share/monkeysphere"} +export SHARE +. "${SHARE}/common" || exit 1 # date in UTF format if needed DATE=$(date -u '+%FT%T') # unset some environment variables that could screw things up -GREP_OPTIONS= +unset GREP_OPTIONS # default return code -ERR=0 +RETURN=0 ######################################################################## # FUNCTIONS @@ -33,13 +30,15 @@ ERR=0 usage() { cat < [args] +usage: $PGRM [options] [args] MonkeySphere client tool. subcommands: update-known_hosts (k) [HOST]... update known_hosts file update-authorized_keys (a) update authorized_keys file gen-subkey (g) KEYID generate an 'a' capable subkey + -l|--length BITS key length in bits (2048) + -e|--expire EXPIRE date to expire help (h,?) this help EOF @@ -72,18 +71,19 @@ gen_subkey(){ # prompt if an authentication subkey already exists if echo "$gpgOut" | egrep "^(pub|sub):" | cut -d: -f 12 | grep -q a ; then echo "An authentication subkey already exists for key '$keyID'." - read -p "Are you sure you would like to generate another one? [y|N]: " OK; OK=${OK:N} + read -p "Are you sure you would like to generate another one? (y/N) " OK; OK=${OK:N} if [ "${OK/y/Y}" != 'Y' ] ; then failure "aborting." fi fi # set subkey defaults - SUBKEY_TYPE=${SUBKEY_TYPE:-"RSA"} - SUBKEY_LENGTH=${SUBKEY_LENGTH:-} - SUBKEY_USAGE=${SUBKEY_USAGE:-"auth"} - SUBKEY_EXPIRE=${SUBKEY_EXPIRE:-"0"} - cat < = key expires in n days @@ -91,7 +91,16 @@ Please specify how long the key should be valid. m = key expires in n months y = key expires in n years EOF - read -p "Key is valid for? ($SUBKEY_EXPIRE) " SUBKEY_EXPIRE; SUBKEY_EXPIRE=${SUBKEY_EXPIRE:-"0"} + while [ -z "$KEY_EXPIRE" ] ; do + read -p "Key is valid for? (0) " KEY_EXPIRE + if ! test_gpg_expire ${KEY_EXPIRE:=0} ; then + echo "invalid value" + unset KEY_EXPIRE + fi + done + elif ! test_gpg_expire "$KEY_EXPIRE" ; then + failure "invalid key expiration value '$KEY_EXPIRE'." + fi # generate the list of commands that will be passed to edit-key editCommands=$(cat <