forked from OpenVPN/openvpn
-
Notifications
You must be signed in to change notification settings - Fork 1
/
t_server_null.sh
executable file
·72 lines (62 loc) · 2.04 KB
/
t_server_null.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/env sh
#
TSERVER_NULL_SKIP_RC="${TSERVER_NULL_SKIP_RC:-77}"
if ! [ -r "./t_server_null.rc" ] ; then
echo "${0}: cannot find './t_server_null.rc. SKIPPING TEST.'" >&2
exit "${TSERVER_NULL_SKIP_RC}"
fi
. ./t_server_null.rc
if KILL_EXEC=$(which kill); then
export KILL_EXEC
else
echo "${0}: kill not found in \$PATH" >&2
exit "${TSERVER_NULL_SKIP_RC}"
fi
# Ensure PREFER_KSU is in a known state
PREFER_KSU="${PREFER_KSU:-0}"
# make sure we have permissions to run ifconfig/route from OpenVPN
# can't use "id -u" here - doesn't work on Solaris
ID=$(id)
if expr "$ID" : "uid=0" >/dev/null
then :
else
if [ "${PREFER_KSU}" -eq 1 ];
then
# Check if we have a valid kerberos ticket
if klist -l 1>/dev/null 2>/dev/null; then
RUN_SUDO="ksu -q -e"
else
# No kerberos ticket found, skip ksu and fallback to RUN_SUDO
PREFER_KSU=0
echo "${0}: No Kerberos ticket available. Will not use ksu."
fi
fi
if [ -z "$RUN_SUDO" ]
then
echo "${0}: this test must run be as root, or RUN_SUDO=... " >&2
echo " must be set correctly in 't_server_null.rc'. SKIP." >&2
exit "${TSERVER_NULL_SKIP_RC}"
else
# Run a no-op command with privilege escalation (e.g. sudo) so that
# we (hopefully) do not have to ask the users password during the test.
if $RUN_SUDO "${KILL_EXEC}" -0 $$
then
echo "${0}: $RUN_SUDO $KILL_EXEC -0 succeeded, good."
else
echo "${0}: $RUN_SUDO $KILL_EXEC -0 failed, cannot go on. SKIP." >&2
exit "${TSERVER_NULL_SKIP_RC}"
fi
fi
fi
srcdir="${srcdir:-.}"
if [ -z "${RUN_SUDO}" ]; then
"${srcdir}/t_server_null_server.sh" &
else
$RUN_SUDO "${srcdir}/t_server_null_server.sh" &
fi
"${srcdir}/t_server_null_client.sh"
# When running make jobs in parallel ("make -j<x> check") we need to ensure
# that this script does not exit before all --dev null servers are dead and
# their network interfaces are gone. Otherwise t_client.sh will fail because
# pre and post ifconfig output does not match.
wait