3
3
# t_cltsrv.sh - script to test OpenVPN's crypto loopback
4
# Copyright (C) 2005,2006 Matthias Andree
4
# Copyright (C) 2005, 2006, 2008 Matthias Andree
6
6
# This program is free software; you can redistribute it and/or
7
7
# modify it under the terms of the GNU General Public License
41
echo "the following test will take about two minutes..." >&2
44
./openvpn --cd "${srcdir}" ${addopts} --down 'echo "srv:${signal}" >&3 ; : #' --tls-exit --ping-exit 180 --config sample-config-files/loopback-server &
45
./openvpn --cd "${srcdir}" ${addopts} --down 'echo "clt:${signal}" >&3 ; : #' --tls-exit --ping-exit 180 --config sample-config-files/loopback-client
46
) 3>log.$$.signal >log.$$ 2>&1
50
grep -v ":inactive$" log.$$.signal >/dev/null && { cat log.$$.signal ; echo ; cat log.$$ ; exit 1 ; }
42
# make sure that the --down script is executable -- fail (rather than
43
# skip) test if it isn't.
44
downscript="t_cltsrv-down.sh"
45
test -x "${srcdir}"/$downscript || chmod +x "${srcdir}"/$downscript || { echo >&2 "$downscript is not executable, failing." ; exit 1 ; }
46
echo "The following test will take about two minutes." >&2
47
echo "If the addresses are in use, this test will retry up to two times." >&2
54
./openvpn --script-security 2 --cd "${srcdir}" ${addopts} --setenv role srv --down "$downscript" --tls-exit --ping-exit 180 --config sample-config-files/loopback-server &
55
./openvpn --script-security 2 --cd "${srcdir}" ${addopts} --setenv role clt --down "$downscript" --tls-exit --ping-exit 180 --config sample-config-files/loopback-client
56
) 3>log.$$.signal >log.$$ 2>&1
60
grep 'TCP/UDP: Socket bind failed on local address.*in use' log.$$ >/dev/null && {
61
echo 'address in use, retrying in 150 s'
65
grep -v ':inactive$' log.$$.signal >/dev/null && { cat log.$$.signal ; echo ; cat log.$$ ; exit 1 ; }
54
if [ $e1 != 0 ] || [ $e2 != 0 ] ; then
72
# exit code - defaults to 0, PASS
75
if [ $success != 1 ] ; then
76
# couldn't run test -- addresses in use, skip test
79
elif [ $e1 != 0 ] || [ $e2 != 0 ] ; then
80
# failure -- fail test
58
85
rm log.$$ log.$$.signal