From: "plaisthos (Code Review)" Date: Mon, 4 Mar 2024 14:54:35 +0000 References: Reply-To: arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: <1af6c91fafd75497cc417e91903d7eb164c00bbe-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="rsWE+5BJKxQ="; charset=UTF-8 Subject: [Openvpn-devel] [XS] Change in openvpn[master]: Avoid SIGUR1 to SIGHUP when the configuration is read from stdin List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: flichtenheld Cc: openvpn-devel --rsWE+5BJKxQ= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: flichtenheld. Hello flichtenheld, I'd like you to do a code review. Please visit http://gerrit.openvpn.net/c/openvpn/+/533?usp=3Demail to review the following change. Change subject: Avoid SIGUR1 to SIGHUP when the configuration is read from = stdin ...................................................................... Avoid SIGUR1 to SIGHUP when the configuration is read from stdin If the configuration is read from stdin, we cannot reread the configuration as stdin provides the configuration only once. So whenever we hit the "close_context usr1 to hup" logic, the OpenVPN process will fail as tries to restart with an empty configuration. Change-Id: Icfc179490d6821e22d14817941fb0bad667c713f Signed-off-by: Arne Schwabe --- M src/openvpn/openvpn.c 1 file changed, 5 insertions(+), 3 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/33/533/1 diff --git a/src/openvpn/openvpn.c b/src/openvpn/openvpn.c index 874facf..4d1437d 100644 --- a/src/openvpn/openvpn.c +++ b/src/openvpn/openvpn.c @@ -32,6 +32,7 @@ #include "multi.h" #include "win32.h" #include "platform.h" +#include "string.h" #include "memdbg.h" @@ -60,9 +61,10 @@ /* set point-to-point mode */ c->mode =3D CM_P2P; - - /* initialize tunnel instance */ - init_instance_handle_signals(c, c->es, CC_HARD_USR1_TO_HUP); + /* initialize tunnel instance, avoid SIGHUP when config is stdin since + * reading the config from stdin will not work */ + bool stdin_config =3D c->options.config && (strcmp(c->options.config, = "stdin") =3D=3D 0); + init_instance_handle_signals(c, c->es, stdin_config ? 0 : CC_HARD_USR1= _TO_HUP); if (IS_SIG(c)) { return; -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/533?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: Icfc179490d6821e22d14817941fb0bad667c713f Gerrit-Change-Number: 533 Gerrit-PatchSet: 1 Gerrit-Owner: plaisthos Gerrit-Reviewer: flichtenheld Gerrit-CC: openvpn-devel Gerrit-Attention: flichtenheld Gerrit-MessageType: newchange --rsWE+5BJKxQ= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is currently required from: flichtenheld.

plaisthos would like flichtenheld to review this change.

Vi= ew Change

Avoid SIGUR1 to SIGHUP when the configuration is read from st=
din

If the configuration is read from stdin, we cannot reread the co= nfiguration
as stdin provides the configuration only once. So whenever w= e hit the
"close_context usr1 to hup" logic, the OpenVPN proce= ss will fail as tries
to restart with an empty configuration.

Cha= nge-Id: Icfc179490d6821e22d14817941fb0bad667c713f
Signed-off-by: Arne Sc= hwabe <arne@...1227...>
---
M src/openvpn/openvpn.c
1 file c= hanged, 5 insertions(+), 3 deletions(-)

git pull ssh://gerrit.ope=
nvpn.net:29418/openvpn refs/changes/33/533/1
diff --git a/src/openv=
pn/openvpn.c b/src/openvpn/openvpn.c
index 874facf..4d1437d= 100644
--- a/src/openvpn/openvpn.c
+++ b/s= rc/openvpn/openvpn.c
@@ -32,6 +32,7 @@
#in= clude "multi.h"
#include "win32.h"
#include "platform.h"
+#include "string.h"

#include "memdbg.h"

<= span>@@ -60,9 +61,10 @@


/* set point= -to-point mode */
c->mode =3D CM_P2P;
-

- /* initialize tunnel instance */
- init_instance_handle_signals(c, c->= ;es, CC_HARD_USR1_TO_HUP);
+ /* initialize tunnel instance, avoid SIGHUP when config is stdin= since
+ * readin= g the config from stdin will not work */
+ bool stdin_config =3D c->options.config &&a= mp; (strcmp(c->options.config, "stdin") =3D=3D 0);
<= span style=3D"color: hsl(120, 100%, 40%);">+ init_instance_handle_signal= s(c, c->es, stdin_config ? 0 : CC_HARD_USR1_TO_HUP);
= if (IS_SIG(c))
{
return;

To view, visit change 533. To unsubscribe, or = for help writing mail filters, visit settings.

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Icfc179490d6821e22d14817941f= b0bad667c713f
Gerrit-Change-Number: 533
Gerrit-PatchSet: 1
Gerrit-Owner: plaisthos <arne-openvpn@...1711...= 27...>
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-Attention: flichtenheld <frank@...2375...= 41...>
Gerrit-MessageType: newchange
--rsWE+5BJKxQ=--