]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
t_server_null: print error when server startup fails
authorSamuli Seppänen <samuli.seppanen@gmail.com>
Wed, 18 Jun 2025 14:13:21 +0000 (16:13 +0200)
committerGert Doering <gert@greenie.muc.de>
Wed, 18 Jun 2025 16:07:13 +0000 (18:07 +0200)
Use "&" to background so that the exit code and all output can be
obtained in all failure cases.

Change-Id: I39dc6b08952a06dae7901e468f9487c8541d83c3
Signed-off-by: Samuli Seppänen <samuli.seppanen@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20250618141328.4600-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31932.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
tests/t_server_null_default.rc
tests/t_server_null_server.sh

index 365b5a8b4dd68b4d8c995c25d87570712ad33ed9..41ec591caf738c26e745f1525d1c280579da3abd 100755 (executable)
@@ -38,7 +38,7 @@ SERVER_KILL_FAIL_FILE=".t_server_null_server.kill_failed"
 MAX_CLIENTS="10"
 CLIENT_MATCH="Test-Client"
 SERVER_EXEC="${top_builddir}/src/openvpn/openvpn"
-SERVER_BASE_OPTS="--daemon --local 127.0.0.1 --dev tun --topology subnet --max-clients $MAX_CLIENTS --persist-tun --verb 3 --duplicate-cn"
+SERVER_BASE_OPTS="--local 127.0.0.1 --dev tun --topology subnet --max-clients $MAX_CLIENTS --persist-tun --verb 3 --duplicate-cn"
 SERVER_CIPHER_OPTS=""
 SERVER_CERT_OPTS="--ca ${CA} --cert ${SERVER_CERT} --key ${SERVER_KEY} --tls-auth ${TA} 0"
 SERVER_CONF_BASE="${SERVER_BASE_OPTS} ${SERVER_CIPHER_OPTS} ${SERVER_CERT_OPTS}"
index acf8479e26df41814e0977d2854a6f464f308b46..65b7d56a468e387c9cb2454340aafb9d26032ca7 100755 (executable)
@@ -11,20 +11,18 @@ launch_server() {
     # Allow reading this file even umask values are strict
     touch "$log"
 
-    if [ -z "${RUN_SUDO}" ]; then
-        "${server_exec}" \
-         $server_conf \
-         --status "${status}" 1 \
-         --log "${log}" \
-         --writepid "${pid}" \
-         --explicit-exit-notify 3
-    else
-        $RUN_SUDO "${server_exec}" \
-                   $server_conf \
-                   --status "${status}" 1 \
-                   --log "${log}" \
-                   --writepid "${pid}" \
-                   --explicit-exit-notify 3
+    # Try to launch the server
+    $RUN_SUDO "${server_exec}" \
+               $server_conf \
+               --status "${status}" 1 \
+               --writepid "${pid}" \
+               --explicit-exit-notify 3 > "$log" 2>&1 &
+
+    sleep 1
+
+    if ! [ -r "$pid" ] || [ -z "$pid" ]; then
+        echo "ERROR: failed to start server $server_name"
+        tail -n 20 "$log"
     fi
 }