From: "cron2 (Code Review)" Date: Tue, 17 Sep 2024 11:00:43 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: <1f6f7177756d3cf388eedc3ccf0c524d5ae7a88a-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="6huD4XhXMe0="; charset=UTF-8 Subject: [Openvpn-devel] [XS] Change in openvpn[master]: Avoid SIGUSR1 to SIGHUP remapping when the configuration is read from... List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos Cc: flichtenheld , openvpn-devel --6huD4XhXMe0= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/53= 3?usp=3Demail ) Change subject: Avoid SIGUSR1 to SIGHUP remapping when the configuration is= read from stdin ...................................................................... Avoid SIGUSR1 to SIGHUP remapping 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. While OpenVPN tries to block USR1 from normal unix signal, I have observed cases in my app which sends USR1 from management interface where the CC_HARD_USR1_TO_HUP logic is trigger and breaking the OpenVPN process. Change-Id: Icfc179490d6821e22d14817941fb0bad667c713f Signed-off-by: Arne Schwabe Acked-by: Frank Lichtenheld Message-Id: <20240719131016.75042-1-frank@...2641...> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg28= 941.html Signed-off-by: Gert Doering --- M src/openvpn/openvpn.c 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/openvpn/openvpn.c b/src/openvpn/openvpn.c index 0e85ebc..16147b7 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 + * re-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: 4 Gerrit-Owner: plaisthos Gerrit-Reviewer: flichtenheld Gerrit-CC: openvpn-devel Gerrit-MessageType: merged --6huD4XhXMe0= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

cron2 submitted this change.

View Change

Avoid SIGUSR1 to SIGHUP remapping when the con=
figuration is read from stdin

If the configuration is read from stdi= n, we cannot reread the configuration
as stdin provides the configuratio= n 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.

While OpenVPN tries to block USR1 from normal unix = signal, I have observed
cases in my app which sends USR1 from management= interface where the
CC_HARD_USR1_TO_HUP logic is trigger and breaking t= he OpenVPN process.

Change-Id: Icfc179490d6821e22d14817941fb0bad667c= 713f
Signed-off-by: Arne Schwabe <arne@...1227...>
Acked-by: Fr= ank Lichtenheld <frank@...2641...>
Message-Id: <20240719131016.= 75042-1-frank@...2641...>
URL: https://www.mail-archive.com/openvpn-d= evel@lists.sourceforge.net/msg28941.html
Signed-off-by: Gert Doering <= ;gert@...1296...>
---
M src/openvpn/openvpn.c
1 file changed, 5= insertions(+), 3 deletions(-)

diff --git a/src/openvpn/openvpn.c b/src/openvpn/openvpn.c
index 0e85ebc..16147b7 100644
--- a/src/openvpn/openvpn.= c
+++ b/src/openvpn/openvpn.c
@@ -32,6 +32,= 7 @@
#include "multi.h"
#includ= e "win32.h"
#include "platform.h"
+#include "string.h&= quot;

#include "memdbg.h"

@@ -60,9 +61,10 @@
/* set point-to-point mode */
c->mode = =3D CM_P2P;
-- /* initialize tunnel instan= ce */
- init_instanc= e_handle_signals(c, c->es, CC_HARD_USR1_TO_HUP);
+ /* initialize tunnel instance, avoid = SIGHUP when config is stdin since
+ * re-reading the config from stdin will not work */
+ bool stdin_config = =3D c->options.config && (strcmp(c->options.config, "std= in") =3D=3D 0);
= + init_instance_handle_signals(c, c->es, stdin_config ? 0 : CC_HARD_U= SR1_TO_HUP);
if (IS_SIG(c))
{

return;

To view, = visit cha= nge 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: 4
Gerrit-Owner: plaisthos <arne-openvpn@...1711...= 27...>
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-MessageType: merged
--6huD4XhXMe0=--