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. --- CHANGELOG | 9 ++++++++- firma | 26 ++++++++++++++------------ 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 953ba52..aa9f4e1 100755 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,7 +1,14 @@ Firma CHANGELOG --------------- -29/07/2007 - 0.3-cvs (rev 1.169) - luis +30/07/2007 - 0.3-cvs (rev 1.170) - luis + + - Try to guarantee that REPLAY_COUNT and DELIVERY_RANDOMIZATION + contain just digits. + + - Fixed a few more bugs in the list creation routine. + +29/07/2007 - 0.3-cvs (rev 1.168) - luis - firma would always exit successfully (exit code = 0). Fixed. 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