From: "mattock (Code Review)" Date: Fri, 16 May 2025 07:20:28 +0000 References: Reply-To: sasepp@...2783..., arne-openvpn@...1227..., 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="LGMguMEVWLU="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: t_server_null: print error when server startup fails List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos , flichtenheld Cc: openvpn-devel --LGMguMEVWLU= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: flichtenheld, plaisthos. Hello plaisthos, flichtenheld, I'd like you to do a code review. Please visit http://gerrit.openvpn.net/c/openvpn/+/1024?usp=3Demail to review the following change. Change subject: t_server_null: print error when server startup fails ...................................................................... t_server_null: print error when server startup fails The --daemon option has to be at the end of the command-line. Moreover, if a pid-file is not found or is empty, launch a new server instance without --log or --daemon so that the error message is printed properly. Change-Id: I39dc6b08952a06dae7901e468f9487c8541d83c3 Signed-off-by: Samuli Sepp=C3=A4nen --- M tests/t_server_null_default.rc M tests/t_server_null_server.sh 2 files changed, 22 insertions(+), 11 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/24/1024/1 diff --git a/tests/t_server_null_default.rc b/tests/t_server_null_default.rc index 5b74761..1f2fa2c 100755 --- a/tests/t_server_null_default.rc +++ b/tests/t_server_null_default.rc @@ -38,7 +38,7 @@ MAX_CLIENTS=3D"10" CLIENT_MATCH=3D"Test-Client" SERVER_EXEC=3D"${top_builddir}/src/openvpn/openvpn" -SERVER_BASE_OPTS=3D"--daemon --dev tun --topology subnet --max-clients $MA= X_CLIENTS --persist-tun --verb 3 --duplicate-cn" +SERVER_BASE_OPTS=3D"--dev tun --topology subnet --max-clients $MAX_CLIENTS= --persist-tun --verb 3 --duplicate-cn" SERVER_BIND_OPTS=3D"--local 127.0.0.1" SERVER_CIPHER_OPTS=3D"" SERVER_CERT_OPTS=3D"--ca ${CA} --dh ${DH} --cert ${SERVER_CERT} --key ${SE= RVER_KEY} --tls-auth ${TA} 0" diff --git a/tests/t_server_null_server.sh b/tests/t_server_null_server.sh index acf8479..d8fd1c4 100755 --- a/tests/t_server_null_server.sh +++ b/tests/t_server_null_server.sh @@ -11,20 +11,31 @@ # 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 + # Try to launch the server daemonized + $RUN_SUDO "${server_exec}" \ + $server_conf \ + --status "${status}" 1 \ + --log "${log}" \ + --writepid "${pid}" \ + --explicit-exit-notify 3 \ + --daemon + + sleep 1 + + # With --daemon OpenVPN's exit code is always 0, even when it failed to + # start. Therefore we check the pid-file and if it is missing or is em= pty + # we run OpenVPN without --daemon and --log to catch the underlying er= ror. + # By backgrounding the process in the shell we ensure that we don't bl= ock + # the test run in the (unlikely) case that OpenVPN startup actually + # succeeds. + if ! [ -r "$pid" ] || [ -z "$pid" ]; then + echo "ERROR: failed to start server $server_name" + $RUN_SUDO "${server_exec}" \ $server_conf \ --status "${status}" 1 \ - --log "${log}" \ --writepid "${pid}" \ - --explicit-exit-notify 3 + --explicit-exit-notify 3 & fi } -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1024?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: I39dc6b08952a06dae7901e468f9487c8541d83c3 Gerrit-Change-Number: 1024 Gerrit-PatchSet: 1 Gerrit-Owner: mattock Gerrit-Reviewer: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos Gerrit-Attention: flichtenheld Gerrit-MessageType: newchange --LGMguMEVWLU= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is currently required from: flichtenheld, plaisthos.

mattock would like plaisthos and flichtenheld to review= this change.

V= iew Change

t_server_null: print error when server startup fails

= The --daemon option has to be at the end of the command-line. Moreover,if a pid-file is not found or is empty, launch a new server instance
wi= thout --log or --daemon so that the error message is printed properly.
<= br>Change-Id: I39dc6b08952a06dae7901e468f9487c8541d83c3
Signed-off-by: S= amuli Sepp=C3=A4nen <samuli.seppanen@...277...>
---
M tests/t_s= erver_null_default.rc
M tests/t_server_null_server.sh
2 files changed= , 22 insertions(+), 11 deletions(-)

git pull ssh://gerrit.openvpn=
.net:29418/openvpn refs/changes/24/1024/1
diff --git a/tests/t_serv=
er_null_default.rc b/tests/t_server_null_default.rc
index 5= b74761..1f2fa2c 100755
--- a/tests/t_server_null_default.rc=
+++ b/tests/t_server_null_default.rc
@@ -3= 8,7 +38,7 @@
MAX_CLIENTS=3D"10"
= CLIENT_MATCH=3D"Test-Client"
SERVER_EXEC=3D&quo= t;${top_builddir}/src/openvpn/openvpn"
-SERVER_BASE_OPTS=3D"--daemon --dev tun --topolog= y subnet --max-clients $MAX_CLIENTS --persist-tun --verb 3 --duplicate-cn&q= uot;
+SERVER_BASE_OPT= S=3D"--dev tun --topology subnet --max-clients $MAX_CLIENTS --persist-= tun --verb 3 --duplicate-cn"
SERVER_BIND_OPTS=3D"= ;--local 127.0.0.1"
SERVER_CIPHER_OPTS=3D""=
SERVER_CERT_OPTS=3D"--ca ${CA} --dh ${DH} --cert ${S= ERVER_CERT} --key ${SERVER_KEY} --tls-auth ${TA} 0"
di= ff --git a/tests/t_server_null_server.sh b/tests/t_server_null_server.sh
index acf8479..d8fd1c4 100755
--- a/tests/t_s= erver_null_server.sh
+++ b/tests/t_server_null_server.sh
@@ -11,20 +11,31 @@
# Allow reading this= file even umask values are strict
touch "$log&qu= ot;

-= if [ -z "${RUN_SUDO}" ]; then
- "${server_exec}" \
- $server_conf \
- --status "${status}&qu= ot; 1 \

- --log= "${log}" \
-= --writepid "${pid}" \
- --explicit-exit-notify 3
- else
+ # Try to launch the server daemonized
+ $RUN_SUDO "${server_exe= c}" \

+ = $server_conf \
= + --status "${status}" 1 \
+ --log "${log}" \
+ --write= pid "${pid}" \
+ --explicit-exit-notify 3 \
+ --daemon
+
+ sleep 1
+
+ # With --da= emon OpenVPN's exit code is always 0, even when it failed to
= + # start. Therefore we chec= k the pid-file and if it is missing or is empty
+ # we run OpenVPN without --daemon and --log= to catch the underlying error.
+ # By backgrounding the process in the shell we ensure that = we don't block
+ = # the test run in the (unlikely) case that OpenVPN startup actually
+ # succeeds.+ if ! [ -r "$pid&quo= t; ] || [ -z "$pid" ]; then
+ echo "ERROR: failed to start server $server_= name"
+ $RUN_SUDO "${server_exec}" \
= $server_conf \
--statu= s "${status}" 1 \
- --log "${log}" \
= --writepid "${pid}" \
- --explicit-exit-notify 3+ --explici= t-exit-notify 3 &
fi
}
=

To view, visit change 1024. To unsu= bscribe, or for help writing mail filters, visit settings.

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I39dc6b08952a06dae7901e468f9= 487c8541d83c3
Gerrit-Change-Number: 1024
Gerrit-PatchSet: 1
Gerrit-Owner: mattock <sasepp@...2783...>= ;
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@...220...= ..1227...>
Gerrit-Attention: flichtenheld <frank@...2375...= 41...>
Gerrit-MessageType: newchange
--LGMguMEVWLU=--