1#!/bin/sh 2# Check that tor regenerates keys when key files are zero-length 3 4umask 077 5set -e 6 7# emulate realpath(), in case coreutils or equivalent is not installed. 8abspath() { 9 f="$*" 10 if [ -d "$f" ]; then 11 dir="$f" 12 base="" 13 else 14 dir="$(dirname "$f")" 15 base="/$(basename "$f")" 16 fi 17 dir="$(cd "$dir" && pwd)" 18 echo "$dir$base" 19} 20 21# find the tor binary 22if [ $# -ge 1 ]; then 23 TOR_BINARY="${1}" 24 shift 25else 26 TOR_BINARY="${TESTING_TOR_BINARY:-./src/app/tor}" 27fi 28 29TOR_BINARY="$(abspath "$TOR_BINARY")" 30 31echo "TOR BINARY IS ${TOR_BINARY}" 32 33if "$TOR_BINARY" --list-modules | grep -q "relay: no"; then 34 echo "This test requires the relay module. Skipping." >&2 35 exit 77 36fi 37 38exitcode=0 39 40"${SHELL:-sh}" "${abs_top_srcdir:-.}/src/test/zero_length_keys.sh" "$TOR_BINARY" -z || exitcode=1 41"${SHELL:-sh}" "${abs_top_srcdir:-.}/src/test/zero_length_keys.sh" "$TOR_BINARY" -d || exitcode=1 42"${SHELL:-sh}" "${abs_top_srcdir:-.}/src/test/zero_length_keys.sh" "$TOR_BINARY" -e || exitcode=1 43 44exit ${exitcode} 45