tor

The Tor anonymity network
git clone https://git.dasho.dev/tor.git
Log | Files | Refs | README | LICENSE

test_zero_length_keys.sh (1046B)


      1 #!/bin/sh
      2 # Check that tor regenerates keys when key files are zero-length
      3 
      4 umask 077
      5 set -e
      6 
      7 # emulate realpath(), in case coreutils or equivalent is not installed.
      8 abspath() {
      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
     22 if [ $# -ge 1 ]; then
     23  TOR_BINARY="${1}"
     24  shift
     25 else
     26  TOR_BINARY="${TESTING_TOR_BINARY:-./src/app/tor}"
     27 fi
     28 
     29 TOR_BINARY="$(abspath "$TOR_BINARY")"
     30 
     31 echo "TOR BINARY IS ${TOR_BINARY}"
     32 
     33 if "$TOR_BINARY" --list-modules | grep -q "relay: no"; then
     34  echo "This test requires the relay module. Skipping." >&2
     35  exit 77
     36 fi
     37 
     38 exitcode=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 
     44 exit ${exitcode}