mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-11 05:33:47 +01:00
Change exit code of zero_length_keys script
Weasel notes that exit codes above 128 are for when a script dies from a signal.
This commit is contained in:
parent
6ecd6e27da
commit
c5f176b9b0
@ -15,8 +15,8 @@
|
|||||||
# Exit Statuses:
|
# Exit Statuses:
|
||||||
# 0: test succeeded - tor regenerated/kept the files
|
# 0: test succeeded - tor regenerated/kept the files
|
||||||
# 1: test failed - tor did not regenerate/keep 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
|
# 2: test failed - tor did not generate the key files on first run
|
||||||
# 255: a command failed - the test could not be completed
|
# 3: a command failed - the test could not be completed
|
||||||
#
|
#
|
||||||
|
|
||||||
if [ $# -lt 1 ]; then
|
if [ $# -lt 1 ]; then
|
||||||
@ -28,12 +28,12 @@ fi
|
|||||||
DATA_DIR=`mktemp -d -t tor_zero_length_keys.XXXXXX`
|
DATA_DIR=`mktemp -d -t tor_zero_length_keys.XXXXXX`
|
||||||
if [ -z "$DATA_DIR" ]; then
|
if [ -z "$DATA_DIR" ]; then
|
||||||
echo "Failure: mktemp invocation returned empty string"
|
echo "Failure: mktemp invocation returned empty string"
|
||||||
exit 255
|
exit 3
|
||||||
fi
|
fi
|
||||||
if [ ! -d "$DATA_DIR" ]; then
|
if [ ! -d "$DATA_DIR" ]; then
|
||||||
echo "$DATA_DIR"
|
echo "$DATA_DIR"
|
||||||
echo "Failure: mktemp invocation result doesn't point to directory"
|
echo "Failure: mktemp invocation result doesn't point to directory"
|
||||||
exit 255
|
exit 3
|
||||||
fi
|
fi
|
||||||
trap "rm -rf '$DATA_DIR'" 0
|
trap "rm -rf '$DATA_DIR'" 0
|
||||||
|
|
||||||
@ -44,7 +44,7 @@ TOR="./src/or/tor --hush --DisableNetwork 1 --ShutdownWaitLength 0 --ORPort 1234
|
|||||||
if [ -s "$DATA_DIR"/keys/secret_id_key ] && [ -s "$DATA_DIR"/keys/secret_onion_key ] &&
|
if [ -s "$DATA_DIR"/keys/secret_id_key ] && [ -s "$DATA_DIR"/keys/secret_onion_key ] &&
|
||||||
[ -s "$DATA_DIR"/keys/secret_onion_key_ntor ]; then
|
[ -s "$DATA_DIR"/keys/secret_onion_key_ntor ]; then
|
||||||
echo "Failure: Previous tor keys present in tor data directory"
|
echo "Failure: Previous tor keys present in tor data directory"
|
||||||
exit 255
|
exit 3
|
||||||
else
|
else
|
||||||
echo "Generating initial tor keys"
|
echo "Generating initial tor keys"
|
||||||
$TOR --DataDirectory "$DATA_DIR" --PidFile "$DATA_DIR"/pid &
|
$TOR --DataDirectory "$DATA_DIR" --PidFile "$DATA_DIR"/pid &
|
||||||
@ -60,11 +60,11 @@ else
|
|||||||
true #echo "tor generated the initial key files"
|
true #echo "tor generated the initial key files"
|
||||||
else
|
else
|
||||||
echo "Failure: tor failed to generate the initial key files"
|
echo "Failure: tor failed to generate the initial key files"
|
||||||
exit 254
|
exit 2
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#ls -lh "$DATA_DIR"/keys/ || exit 255
|
#ls -lh "$DATA_DIR"/keys/ || exit 3
|
||||||
|
|
||||||
# backup and keep/delete/create zero-length files for the keys
|
# backup and keep/delete/create zero-length files for the keys
|
||||||
|
|
||||||
@ -75,17 +75,17 @@ cp -r "$DATA_DIR"/keys "$DATA_DIR"/keys.old
|
|||||||
# delete keys for -d or -z
|
# delete keys for -d or -z
|
||||||
if [ "$1" != "-e" ]; then
|
if [ "$1" != "-e" ]; then
|
||||||
FILE_DESC="regenerates deleted"
|
FILE_DESC="regenerates deleted"
|
||||||
rm "$DATA_DIR"/keys/secret_id_key || exit 255
|
rm "$DATA_DIR"/keys/secret_id_key || exit 3
|
||||||
rm "$DATA_DIR"/keys/secret_onion_key || exit 255
|
rm "$DATA_DIR"/keys/secret_onion_key || exit 3
|
||||||
rm "$DATA_DIR"/keys/secret_onion_key_ntor || exit 255
|
rm "$DATA_DIR"/keys/secret_onion_key_ntor || exit 3
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# create empty files for -z
|
# create empty files for -z
|
||||||
if [ "$1" = "-z" ]; then
|
if [ "$1" = "-z" ]; then
|
||||||
FILE_DESC="regenerates zero-length"
|
FILE_DESC="regenerates zero-length"
|
||||||
touch "$DATA_DIR"/keys/secret_id_key || exit 255
|
touch "$DATA_DIR"/keys/secret_id_key || exit 3
|
||||||
touch "$DATA_DIR"/keys/secret_onion_key || exit 255
|
touch "$DATA_DIR"/keys/secret_onion_key || exit 3
|
||||||
touch "$DATA_DIR"/keys/secret_onion_key_ntor || exit 255
|
touch "$DATA_DIR"/keys/secret_onion_key_ntor || exit 3
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Running tor again to check if it $FILE_DESC keys"
|
echo "Running tor again to check if it $FILE_DESC keys"
|
||||||
@ -96,7 +96,7 @@ sleep 5
|
|||||||
kill $TOR_PID
|
kill $TOR_PID
|
||||||
wait $TOR_PID
|
wait $TOR_PID
|
||||||
|
|
||||||
#ls -lh "$DATA_DIR"/keys/ || exit 255
|
#ls -lh "$DATA_DIR"/keys/ || exit 3
|
||||||
|
|
||||||
# tor must always have non-zero-length key files
|
# tor must always have non-zero-length key files
|
||||||
if [ -s "$DATA_DIR"/keys/secret_id_key ] && [ -s "$DATA_DIR"/keys/secret_onion_key ] &&
|
if [ -s "$DATA_DIR"/keys/secret_id_key ] && [ -s "$DATA_DIR"/keys/secret_onion_key ] &&
|
||||||
|
Loading…
Reference in New Issue
Block a user