mirror of
https://github.com/OpenVPN/openvpn.git
synced 2025-05-09 13:41:06 +08:00

By using wait in a more inventive way we can avoid using a marker file to detect the "server could not be killed gracefully" situation. Change-Id: Ib385080e1dd1c3046c54e6267db8aa7d5c09e2fb Signed-off-by: Samuli Seppänen <samuli.seppanen@gmail.com> Acked-by: Gert Doering <gert@greenie.muc.de> Message-Id: <20241026092515.30559-1-gert@greenie.muc.de> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg29664.html Signed-off-by: Gert Doering <gert@greenie.muc.de>
81 lines
2.2 KiB
Bash
Executable File
81 lines
2.2 KiB
Bash
Executable File
#!/bin/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:-.}"
|
|
export t_server_null_logdir=t_server_null-`hostname`-`date +%Y%m%d-%H%M%S`
|
|
|
|
# Create directory for server and client logs
|
|
mkdir $t_server_null_logdir
|
|
|
|
"${srcdir}/t_server_null_server.sh" &
|
|
T_SERVER_NULL_SERVER_PID=$!
|
|
|
|
"${srcdir}/t_server_null_client.sh"
|
|
retval=$?
|
|
|
|
# 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 $T_SERVER_NULL_SERVER_PID
|
|
|
|
if [ $? -ne 0 ]; then
|
|
exit 1
|
|
else
|
|
exit $retval
|
|
fi
|