summaryrefslogtreecommitdiff
path: root/src/test/zero_length_keys.sh
diff options
context:
space:
mode:
authorSebastian Hahn <sebastian@torproject.org>2015-02-06 21:53:22 +0100
committerSebastian Hahn <sebastian@torproject.org>2015-02-06 21:55:59 +0100
commitd695f7b4235bb1a54658e5a5ba2f7ce025ffda92 (patch)
treeaeceabf55e5cd88a59c9e756d8471f66cb045c72 /src/test/zero_length_keys.sh
parente36faeec1d40e1f4f7ae54c798ad4492f86f594c (diff)
downloadtor-d695f7b4235bb1a54658e5a5ba2f7ce025ffda92.tar.gz
tor-d695f7b4235bb1a54658e5a5ba2f7ce025ffda92.zip
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!
Diffstat (limited to 'src/test/zero_length_keys.sh')
-rwxr-xr-xsrc/test/zero_length_keys.sh24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/test/zero_length_keys.sh b/src/test/zero_length_keys.sh
index 3a99ca1f1d..6c82c3d3d3 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