commit d695f7b4235bb1a54658e5a5ba2f7ce025ffda92 Author: Sebastian Hahn sebastian@torproject.org Date: Fri Feb 6 21:53:22 2015 +0100
Don't use invalid exit values in zero length key test
Shell exit values must fall into the range of [0-255], so let's honour this. In practice, the "exit -1" from the old code set an exit value of 255 on most systems, so let's pick that.
Fixes part of bug #14478, patch idea suggested by an anonymous contributor. Thanks! --- src/test/zero_length_keys.sh | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/src/test/zero_length_keys.sh b/src/test/zero_length_keys.sh index 3a99ca1..6c82c3d 100755 --- a/src/test/zero_length_keys.sh +++ b/src/test/zero_length_keys.sh @@ -13,10 +13,10 @@ # Check tor does not overwrite existing keys (existing behaviour) # # Exit Statuses: -# -2: test failed - tor did not generate the key files on first run -# -1: a command failed - the test could not be completed # 0: test succeeded - tor regenerated/kept the files # 1: test failed - tor did not regenerate/keep the files +# 254: test failed - tor did not generate the key files on first run +# 255: a command failed - the test could not be completed #
if [ $# -lt 1 ]; then @@ -32,7 +32,7 @@ TOR="./src/or/tor --hush --DisableNetwork 1 --ShutdownWaitLength 0 --ORPort 1234
if [ -s "$DATA_DIR"/keys/secret_id_key -a -s "$DATA_DIR"/keys/secret_onion_key -a -s "$DATA_DIR"/keys/secret_onion_key_ntor ]; then echo "Failure: Previous tor keys present in tor data directory" - exit -1 + exit 255 else echo "Generating initial tor keys" $TOR --DataDirectory "$DATA_DIR" --PidFile "$DATA_DIR"/pid & @@ -47,11 +47,11 @@ else true #echo "tor generated the initial key files" else echo "Failure: tor failed to generate the initial key files" - exit -2 + exit 254 fi fi
-#ls -lh "$DATA_DIR"/keys/ || exit -1 +#ls -lh "$DATA_DIR"/keys/ || exit 255
# backup and keep/delete/create zero-length files for the keys
@@ -62,17 +62,17 @@ cp -r "$DATA_DIR"/keys "$DATA_DIR"/keys.old # delete keys for -d or -z if [ "$1" != "-e" ]; then FILE_DESC="regenerates deleted" - rm "$DATA_DIR"/keys/secret_id_key || exit -1 - rm "$DATA_DIR"/keys/secret_onion_key || exit -1 - rm "$DATA_DIR"/keys/secret_onion_key_ntor || exit -1 + rm "$DATA_DIR"/keys/secret_id_key || exit 255 + rm "$DATA_DIR"/keys/secret_onion_key || exit 255 + rm "$DATA_DIR"/keys/secret_onion_key_ntor || exit 255 fi
# create empty files for -z if [ "$1" = "-z" ]; then FILE_DESC="regenerates zero-length" - touch "$DATA_DIR"/keys/secret_id_key || exit -1 - touch "$DATA_DIR"/keys/secret_onion_key || exit -1 - touch "$DATA_DIR"/keys/secret_onion_key_ntor || exit -1 + touch "$DATA_DIR"/keys/secret_id_key || exit 255 + touch "$DATA_DIR"/keys/secret_onion_key || exit 255 + touch "$DATA_DIR"/keys/secret_onion_key_ntor || exit 255 fi
echo "Running tor again to check if it $FILE_DESC keys" @@ -83,7 +83,7 @@ sleep 5 kill $TOR_PID wait $TOR_PID
-#ls -lh "$DATA_DIR"/keys/ || exit -1 +#ls -lh "$DATA_DIR"/keys/ || exit 255
# tor must always have non-zero-length key files if [ -s "$DATA_DIR"/keys/secret_id_key -a -s "$DATA_DIR"/keys/secret_onion_key -a -s "$DATA_DIR"/keys/secret_onion_key_ntor ]; then
tor-commits@lists.torproject.org