From 66a3723ba943d7cfe01ed32ea5924d3a25dd1543 Mon Sep 17 00:00:00 2001 From: luis Date: Mon, 30 Jul 2007 05:06:49 +0000 Subject: - Try to guarantee that REPLAY_COUNT, DELIVERY_RANDOMIZATION, and RandomString's input contain just digits. - Fixed a few minor bugs in NewList (list creation routine). - Catch NewList exit code. --- firma | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'firma') diff --git a/firma b/firma index 1c8cace..5fcc382 100755 --- a/firma +++ b/firma @@ -224,7 +224,8 @@ WARNING: $LIST_NAME: Removing this address from LIST_ADMIN for this run." fi if [[ "$REPLAY_PROTECTION" == "1" ]]; then - if [[ -z "$REPLAY_COUNT" ]]; then + REPLAY_COUNT="$(( 10#$(echo "$REPLAY_COUNT" | tr -dc '[:digit:]') ))" + if [[ "$REPLAY_COUNT" == "0" ]]; then REPLAY_COUNT="150" fi if [[ -z "$REPLAY_FILE" ]]; then @@ -924,8 +925,8 @@ function NewList { break elif CheckValidEmail $LIST_ADDRESS; then break - else - echo " Invalid email address: $LIST_ADDRESS." + elif [[ -n "$LIST_ADDRESS" ]]; then + echo " Invalid email address: $LIST_ADDRESS" fi done @@ -939,14 +940,14 @@ function NewList { echo "List creation aborted." return_code=1 break - else + elif [[ -n "$LIST_ADMIN" ]]; then for admin in $LIST_ADMIN; do if ! CheckValidEmail $admin; then invalid="$(echo $invalid $admin | sed -e 's/ / /')" fi done if [[ -n "$invalid" ]]; then - echo " Invalid email address: $invalid." + echo " Invalid email address: $invalid" invalid="" else break @@ -973,6 +974,7 @@ function NewList { elif [[ "$answer" == "N" || "$answer" == "NO" ]]; then read -resp " Passphrase to protect the list's secret key (you'll type it once): " PASSPHRASE while ! CheckPassphrase; do + echo "" read -resp " Passphrase doesn't fit all the requirements, please choose another: " PASSPHRASE done break @@ -1021,8 +1023,8 @@ function NewList { while true; do read -rep " Please enter the key expiration time or 'quit' to exit: " KEY_EXPIRATION KEY_EXPIRATION="$(echo $KEY_EXPIRATION | tr '[:upper:]' '[:lower:]')" - last_char="$(echo "$KEY_EXPIRATION" | grep -o '[hdwmy]$')" - digits_only="$(echo "$SUBKEY_VALIDITY" | sed -e "s/$last_char.$//")" + last_char="$(echo "$KEY_EXPIRATION" | grep -o '[wmy]$')" + digits_only="$(echo "$KEY_EXPIRATION" | sed -e "s/${last_char}$//")" if [[ -z "$KEY_EXPIRATION" ]]; then KEY_EXPIRATION="0" break @@ -1032,7 +1034,7 @@ function NewList { echo "List creation aborted." return_code=1 break - elif [[ -z "$(echo $digits_only | sed -e 's/[0-9]//g')" || -n "$last_char" ]]; then + elif [[ -z "$(echo $digits_only | sed -e 's/[0-9]//g')" ]]; then break else echo " Invalid key expiration time." @@ -1780,10 +1782,9 @@ function RandomString { local n alpha="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,;:?!" - if [[ -z "$1" ]]; then + n="$(( 10#$(echo "$1" | tr -dc '[:digit:]') ))" + if [[ "$n" == "0" ]]; then n=6 - else - n=$(echo "$1" | sed 's/[^0-9]//g') fi if [[ $n -gt 62 ]]; then @@ -2198,7 +2199,7 @@ function SetDeliveryRandomization { if [[ "$DELIVERY_RANDOMIZATION" != "0" && -n "$DELIVERY_RANDOMIZATION" ]]; then # remove non-digits - DELIVERY_RANDOMIZATION="$(echo $DELIVERY_RANDOMIZATION | sed -e 's/[^0-9]//g')" + DELIVERY_RANDOMIZATION="$(( 10#$(echo $DELIVERY_RANDOMIZATION | tr -dc '[:digit:]') ))" else DELIVERY_RANDOMIZATION="0" fi @@ -2438,6 +2439,7 @@ case $# in case $1 in -c|--create-newlist) NewList + EXIT_CODE=$? ;; # options that depend on the list configuration file -a|--admin-task|-e|--email-admin-task|-p|--process-message) -- cgit v1.2.3