]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
make t_server_null 'server alive?' check more robust
authorGert Doering <gert@greenie.muc.de>
Wed, 18 Sep 2024 16:29:17 +0000 (18:29 +0200)
committerGert Doering <gert@greenie.muc.de>
Thu, 19 Sep 2024 10:01:46 +0000 (12:01 +0200)
- use "$RUN_SUDO kill -0 $pid" to test if a given process is running, not
  "ps -p $pid" - the latter will not work if security.bsd.see_other_uids=0
  is set

- produce proper error messages if pid files can not be found or are
  empty at server shutdown time

Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20240918162917.6809-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg29314.html

Signed-off-by: Gert Doering <gert@greenie.muc.de>
tests/t_server_null_client.sh
tests/t_server_null_server.sh

index e7dd332423c750a2fe14dce270fdb6b670879823..c1a25dfc544fc2a357bf84f84ca2fbaedcef6722 100755 (executable)
@@ -87,7 +87,10 @@ while [ $count -lt $server_max_wait ]; do
     # the active server count as the processes won't be running.
     for i in `set|grep 'SERVER_NAME_'|cut -d "=" -f 2|tr -d "[\']"`; do
         server_pid=$(cat $i.pid 2> /dev/null)
-        if ps -p $server_pid > /dev/null 2>&1; then
+        if [ -z "$server_pid" ] ; then
+            continue
+        fi
+        if $RUN_SUDO kill -0 $server_pid > /dev/null 2>&1; then
             servers_up=$(( $servers_up + 1 ))
         fi
     done
index e5906eec3b6eb67f530cec81c3026d5a29640c09..10bb44bfdd18a53e26ba6a8faea29cf2b743fb0f 100755 (executable)
@@ -82,6 +82,11 @@ for PID_FILE in $server_pid_files
 do
     SERVER_PID=$(cat "${PID_FILE}")
 
+    if [ -z "$SERVER_PID" ] ; then
+        echo "WARNING: could not kill server ${PID_FILE}!"
+        continue
+    fi
+
     if [ -z "${RUN_SUDO}" ]; then
         $KILL_EXEC "${SERVER_PID}"
     else