From: "cron2 (Code Review)" Date: Fri, 25 Oct 2024 11:22:26 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., samuli@...515..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="rbRu+GJSfls="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: t_server_null: forcibly kill misbehaving servers List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: mattock , plaisthos , flichtenheld Cc: openvpn-devel --rbRu+GJSfls= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable cron2 has uploaded a new patch set (#10) to the change originally created b= y mattock. ( http://gerrit.openvpn.net/c/openvpn/+/775?usp=3Demail ) The following approvals got outdated and were removed: Code-Review+2 by cron2 Change subject: t_server_null: forcibly kill misbehaving servers ...................................................................... t_server_null: forcibly kill misbehaving servers Change-Id: Ic0f98cd3b87a7b86e032e63167ac9036f7c08fcb Signed-off-by: Samuli Sepp=C3=A4nen Acked-by: Gert Doering Message-Id: <20241025103632.4413-1-gert@...1296...> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg29= 655.html Signed-off-by: Gert Doering --- M tests/t_server_null.sh M tests/t_server_null_client.sh M tests/t_server_null_default.rc M tests/t_server_null_server.sh 4 files changed, 30 insertions(+), 10 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/75/775/10 diff --git a/tests/t_server_null.sh b/tests/t_server_null.sh index d4311d4..3c0fc4b 100755 --- a/tests/t_server_null.sh +++ b/tests/t_server_null.sh @@ -71,4 +71,10 @@ # pre and post ifconfig output does not match. wait -exit $retval +. ./t_server_null_default.rc + +if [ -e $SERVER_KILL_FAIL_FILE ]; then + exit 1 +else + exit $retval +fi diff --git a/tests/t_server_null_client.sh b/tests/t_server_null_client.sh index 846f790..2210e63 100755 --- a/tests/t_server_null_client.sh +++ b/tests/t_server_null_client.sh @@ -53,11 +53,11 @@ echo "PASS ${test_name} (test failure)" elif [ $exit_code -eq 0 ] && [ "${should_pass}" =3D "no" ]; then echo "FAIL ${test_name} (test failure)" - cat "${log}" + cat "${t_server_null_logdir}/${log}" retval=3D1 elif [ $exit_code -eq 1 ] && [ "${should_pass}" =3D "yes" ]; then echo "FAIL ${test_name}" - cat "${log}" + cat "${t_server_null_logdir}/${log}" retval=3D1 fi } diff --git a/tests/t_server_null_default.rc b/tests/t_server_null_default.rc index 825bb52..cbf4877 100755 --- a/tests/t_server_null_default.rc +++ b/tests/t_server_null_default.rc @@ -20,6 +20,10 @@ SERVER_KEY=3D"${sample_keys}/server.key" TA=3D"${sample_keys}/ta.key" +# Used to detect if graceful kill of any server instance failed during the= test +# run +SERVER_KILL_FAIL_FILE=3D".t_server_null_server.kill_failed" + # Test server configurations MAX_CLIENTS=3D"10" CLIENT_MATCH=3D"Test-Client" diff --git a/tests/t_server_null_server.sh b/tests/t_server_null_server.sh index f8ba3a3..ab01dd2 100755 --- a/tests/t_server_null_server.sh +++ b/tests/t_server_null_server.sh @@ -8,6 +8,9 @@ status=3D"${server_name}.status" pid=3D"${server_name}.pid" + # Allow reading this file even umask values are strict + touch "$log" + if [ -z "${RUN_SUDO}" ]; then "${server_exec}" \ $server_conf \ @@ -34,6 +37,9 @@ # Load local configuration, if any test -r ./t_server_null.rc && . ./t_server_null.rc +# Remove server kill failure marker file, if any +rm -f $SERVER_KILL_FAIL_FILE + # Launch test servers for SUF in $TEST_SERVER_LIST do @@ -75,6 +81,7 @@ # Make sure that the server processes are truly dead before exiting. If a # server process does not exit in 15 seconds assume it never will, move on= and # hope for the best. + echo "Waiting for servers to exit" for PID_FILE in $server_pid_files do @@ -85,22 +92,25 @@ continue fi - if [ -z "${RUN_SUDO}" ]; then - $KILL_EXEC "${SERVER_PID}" - else - $RUN_SUDO $KILL_EXEC "${SERVER_PID}" - fi + # Attempt to kill the OpenVPN server gracefully with SIGTERM + $RUN_SUDO $KILL_EXEC "${SERVER_PID}" count=3D0 maxcount=3D75 while [ $count -le $maxcount ] do - ps -p "${SERVER_PID}" > /dev/null || break + $RUN_SUDO kill -0 "${SERVER_PID}" 2> /dev/null || break count=3D$(( count + 1)) sleep 0.2 done + # If server is still up send a SIGKILL if [ $count -ge $maxcount ]; then - echo "WARNING: could not kill server with pid ${SERVER_PID}!" + $RUN_SUDO $KILL_EXEC -9 "${SERVER_PID}" + SERVER_NAME=3D$(basename $PID_FILE|cut -d . -f 1) + echo "ERROR: had to send SIGKILL to server ${SERVER_NAME} with pid= ${SERVER_PID}!" + echo "Tail of server log:" + tail -n 20 "${t_server_null_logdir}/${SERVER_NAME}.log" + touch $SERVER_KILL_FAIL_FILE fi done -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/775?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: Ic0f98cd3b87a7b86e032e63167ac9036f7c08fcb Gerrit-Change-Number: 775 Gerrit-PatchSet: 10 Gerrit-Owner: mattock Gerrit-Reviewer: cron2 Gerrit-Reviewer: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-MessageType: newpatchset --rbRu+GJSfls= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

cron2 uploaded patch set #10 to the change originally c= reated by mattock.

View Change

The following approvals got outdated = and were removed: Code-Review+2 by cron2

t_server_null: forcibly kill misbehaving servers
=
Change-Id: Ic0f98cd3b87a7b86e032e63167ac9036f7c08fcb
Signed-off-by: = Samuli Sepp=C3=A4nen <samuli.seppanen@...277...>
Acked-by: Gert Do= ering <gert@...1296...>
Message-Id: <20241025103632.4413-1-gert= @...1296...>
URL: https://www.mail-archive.com/openvpn-devel@...1466...= urceforge.net/msg29655.html
Signed-off-by: Gert Doering <gert@...1726...= ...>
---
M tests/t_server_null.sh
M tests/t_server_null_client.= sh
M tests/t_server_null_default.rc
M tests/t_server_null_server.sh4 files changed, 30 insertions(+), 10 deletions(-)

git pull ssh=
://gerrit.openvpn.net:29418/openvpn refs/changes/75/775/10
diff --=
git a/tests/t_server_null.sh b/tests/t_server_null.sh
index= d4311d4..3c0fc4b 100755
--- a/tests/t_server_null.sh
+++ b/tests/t_server_null.sh
@@ -71,4 +71,10 @@<= /span>
# pre and post ifconfig output does not match.
<= span> wait


-exit $retval
+= . ./t_server_null_default.rc
+
+if [ -e $S= ERVER_KILL_FAIL_FILE ]; then
+ exit 1
+= else
+ exit $retva= l
+fi
diff --git a/tests/t_server_null_client.sh b/tests/t_server_null_client.sh=

index 846f790..2210e63 100755
--- a/tests/= t_server_null_client.sh
+++ b/tests/t_server_null_client.sh=
@@ -53,11 +53,11 @@
echo "PA= SS ${test_name} (test failure)"
elif [ $exit_code= -eq 0 ] && [ "${should_pass}" =3D "no" ]; then=
echo "FAIL ${test_name} (test failure)"=
- cat "${l= og}"
+ ca= t "${t_server_null_logdir}/${log}"
retva= l=3D1
elif [ $exit_code -eq 1 ] && [ "${s= hould_pass}" =3D "yes" ]; then
echo= "FAIL ${test_name}"
- cat "${log}"
+ cat "${t_server_null_logdir}/${log}"<= /span>
retval=3D1
fi
}

diff --git a/tests/t_server_null_default.rc b/tests/t_s= erver_null_default.rc
index 825bb52..cbf4877 100755<= br>--- a/tests/t_server_null_default.rc
+++ b/tests/t= _server_null_default.rc
@@ -20,6 +20,10 @@
= SERVER_KEY=3D"${sample_keys}/server.key"
TA=3D&= quot;${sample_keys}/ta.key"

+# Used to detect if graceful kill of any ser= ver instance failed during the test
+# run
+SERVER_KILL_FAIL_FILE=3D".t_server_null_server.kill_failed"
+
# Tes= t server configurations
MAX_CLIENTS=3D"10"
CLIENT_MATCH=3D"Test-Client"
diff --g= it a/tests/t_server_null_server.sh b/tests/t_server_null_server.shindex f8ba3a3..ab01dd2 100755
--- a/tests/t_server_= null_server.sh
+++ b/tests/t_server_null_server.sh@@ -8,6 +8,9 @@
status=3D"${server_name}.= status"
pid=3D"${server_name}.pid"

+ # = Allow reading this file even umask values are strict
+ touch "$log"
+

if [ -z &quo= t;${RUN_SUDO}" ]; then
"${server_exec}&q= uot; \
$server_conf \
@@ -34,6 +3= 7,9 @@
# Load local configuration, if any
= test -r ./t_server_null.rc && . ./t_server_null.rc

+# Remove server k= ill failure marker file, if any
+rm -f $SERVER_KILL_FAIL_FILE
+
# Launch test servers
for SUF in $TEST_SERVER_LIST

do
@@ -75,= 6 +81,7 @@
# Make sure that the server processes are truly= dead before exiting. If a
# server process does not exit= in 15 seconds assume it never will, move on and
# hope fo= r the best.
+<= br> echo "Waiting for servers to exit"
for= PID_FILE in $server_pid_files
do
@@ -85,2= 2 +92,25 @@
continue
fi

- if [ = -z "${RUN_SUDO}" ]; then
- $KILL_EXEC "${SERVER_PID}"
- else
- $RUN_SUDO $KILL_EXEC "${SERVER_PID}&quo= t;
- fi
+ # Attempt to kill the OpenVP= N server gracefully with SIGTERM

+ $RUN_SUDO $KILL_EXEC "${SERVER_PID}"
<= span>
count=3D0
maxcount=3D75
while [ $count -le $maxcount ]
do
- ps -p "${S= ERVER_PID}" > /dev/null || break
+ $RUN_SUDO kill -0 "${SERVER_PID}" 2&= gt; /dev/null || break
count=3D$(( count + 1))
sleep 0.2
done
=
+ # If server is = still up send a SIGKILL
if [ $count -ge $maxcount ]; t= hen
- echo "= ;WARNING: could not kill server with pid ${SERVER_PID}!"
+ $RUN_SUDO $KILL_EXEC -9 &= quot;${SERVER_PID}"

+ SERVER_NAME=3D$(basename $PID_FILE|cut -d . -f 1)
+ echo "ERROR: had to= send SIGKILL to server ${SERVER_NAME} with pid ${SERVER_PID}!"
=
+ echo "Tail of= server log:"
+ = tail -n 20 "${t_server_null_logdir}/${SERVER_NAME}.log"
+ touch $SERVER_= KILL_FAIL_FILE
fi
done

To view, visit change 775. To unsubscribe, or for help wri= ting mail filters, visit set= tings.

=
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic0f98cd3b87a7b86e032e63167a= c9036f7c08fcb
Gerrit-Change-Number: 775
Gerrit-PatchSet: 10
Gerrit-Owner: mattock <samuli@...515...>=
Gerrit-Reviewer: cron2 <gert@...1296...>=
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-MessageType: newpatchset
--rbRu+GJSfls=--