OpenVPN: Stop N2N connection before remove.

Message ID 20200324102905.27038-1-ummeegge@ipfire.org
State Accepted
Commit 6ad43b0f218faa004986fca0c79e1446697c7b27
Headers
Series OpenVPN: Stop N2N connection before remove. |

Commit Message

ummeegge March 24, 2020, 10:29 a.m. UTC
  Fix #12334

Signed-off-by: Erik Kapfer <ummeegge@ipfire.org>
---
 html/cgi-bin/ovpnmain.cgi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Michael Tremer March 24, 2020, 11:31 a.m. UTC | #1
Hello,

Brilliant fix. Thanks for looking into this so quickly.

Did you check if we have any other issues like this?

Best,
-Michael

Reviewed-by: Michael Tremer <michael.tremer@ipfire.org>

> On 24 Mar 2020, at 10:29, Erik Kapfer <ummeegge@ipfire.org> wrote:
> 
> Fix #12334
> 
> Signed-off-by: Erik Kapfer <ummeegge@ipfire.org>
> ---
> html/cgi-bin/ovpnmain.cgi | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/html/cgi-bin/ovpnmain.cgi b/html/cgi-bin/ovpnmain.cgi
> index e76a688fe..a6fdd6d75 100644
> --- a/html/cgi-bin/ovpnmain.cgi
> +++ b/html/cgi-bin/ovpnmain.cgi
> @@ -2464,7 +2464,7 @@ else
> 
> 		if ($confighash{$cgiparams{'KEY'}}[3] eq 'net') {
> 			# Stop the N2N connection before it is removed
> -			system("/usr/local/bin/openvpnctrl -kn2n $confighash{$cgiparams{'KEY'}}[1] &>/dev/null");
> +			system('/usr/local/bin/openvpnctrl', '-kn2n', $confighash{$cgiparams{'KEY'}}[1]);
> 
> 			my $conffile = glob("${General::swroot}/ovpn/n2nconf/$confighash{$cgiparams{'KEY'}}[1]/$confighash{$cgiparams{'KEY'}}[1].conf");
> 			my $certfile = glob("${General::swroot}/ovpn/certs/$confighash{$cgiparams{'KEY'}}[1].p12");
> -- 
> 2.12.2
>
  
ummeegge March 24, 2020, 12:31 p.m. UTC | #2
Hi Michael,

Am Dienstag, den 24.03.2020, 11:31 +0000 schrieb Michael Tremer:
> Hello,
> 
> Brilliant fix. Thanks for looking into this so quickly.
your welcome.

> 
> Did you check if we have any other issues like this?
Not similar to that one as far as i can see.
This one -->
https://git.ipfire.org/?p=ipfire-2.x.git;a=blob;f=html/cgi-bin/ovpnmain.cgi;hb=91457877199d3ac8438efc7be4cd6a50e48e37e4#l1221
comes closer but it works.
Should i nevertheless ?

Best,

Erik

> 
> Best,
> -Michael
> 
> Reviewed-by: Michael Tremer <michael.tremer@ipfire.org>
> 
> > On 24 Mar 2020, at 10:29, Erik Kapfer <ummeegge@ipfire.org> wrote:
> > 
> > Fix #12334
> > 
> > Signed-off-by: Erik Kapfer <ummeegge@ipfire.org>
> > ---
> > html/cgi-bin/ovpnmain.cgi | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/html/cgi-bin/ovpnmain.cgi b/html/cgi-bin/ovpnmain.cgi
> > index e76a688fe..a6fdd6d75 100644
> > --- a/html/cgi-bin/ovpnmain.cgi
> > +++ b/html/cgi-bin/ovpnmain.cgi
> > @@ -2464,7 +2464,7 @@ else
> > 
> > 		if ($confighash{$cgiparams{'KEY'}}[3] eq 'net') {
> > 			# Stop the N2N connection before it is removed
> > -			system("/usr/local/bin/openvpnctrl -kn2n
> > $confighash{$cgiparams{'KEY'}}[1] &>/dev/null");
> > +			system('/usr/local/bin/openvpnctrl', '-kn2n',
> > $confighash{$cgiparams{'KEY'}}[1]);
> > 
> > 			my $conffile =
> > glob("${General::swroot}/ovpn/n2nconf/$confighash{$cgiparams{'KEY'}
> > }[1]/$confighash{$cgiparams{'KEY'}}[1].conf");
> > 			my $certfile =
> > glob("${General::swroot}/ovpn/certs/$confighash{$cgiparams{'KEY'}}[
> > 1].p12");
> > -- 
> > 2.12.2
> > 
> 
>
  
Michael Tremer March 24, 2020, 2:42 p.m. UTC | #3
Yes, please. If we spot a bug, we should of course fix it :)

> On 24 Mar 2020, at 12:31, ummeegge <ummeegge@ipfire.org> wrote:
> 
> Hi Michael,
> 
> Am Dienstag, den 24.03.2020, 11:31 +0000 schrieb Michael Tremer:
>> Hello,
>> 
>> Brilliant fix. Thanks for looking into this so quickly.
> your welcome.
> 
>> 
>> Did you check if we have any other issues like this?
> Not similar to that one as far as i can see.
> This one -->
> https://git.ipfire.org/?p=ipfire-2.x.git;a=blob;f=html/cgi-bin/ovpnmain.cgi;hb=91457877199d3ac8438efc7be4cd6a50e48e37e4#l1221
> comes closer but it works.
> Should i nevertheless ?
> 
> Best,
> 
> Erik
> 
>> 
>> Best,
>> -Michael
>> 
>> Reviewed-by: Michael Tremer <michael.tremer@ipfire.org>
>> 
>>> On 24 Mar 2020, at 10:29, Erik Kapfer <ummeegge@ipfire.org> wrote:
>>> 
>>> Fix #12334
>>> 
>>> Signed-off-by: Erik Kapfer <ummeegge@ipfire.org>
>>> ---
>>> html/cgi-bin/ovpnmain.cgi | 2 +-
>>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>> 
>>> diff --git a/html/cgi-bin/ovpnmain.cgi b/html/cgi-bin/ovpnmain.cgi
>>> index e76a688fe..a6fdd6d75 100644
>>> --- a/html/cgi-bin/ovpnmain.cgi
>>> +++ b/html/cgi-bin/ovpnmain.cgi
>>> @@ -2464,7 +2464,7 @@ else
>>> 
>>> 		if ($confighash{$cgiparams{'KEY'}}[3] eq 'net') {
>>> 			# Stop the N2N connection before it is removed
>>> -			system("/usr/local/bin/openvpnctrl -kn2n
>>> $confighash{$cgiparams{'KEY'}}[1] &>/dev/null");
>>> +			system('/usr/local/bin/openvpnctrl', '-kn2n',
>>> $confighash{$cgiparams{'KEY'}}[1]);
>>> 
>>> 			my $conffile =
>>> glob("${General::swroot}/ovpn/n2nconf/$confighash{$cgiparams{'KEY'}
>>> }[1]/$confighash{$cgiparams{'KEY'}}[1].conf");
>>> 			my $certfile =
>>> glob("${General::swroot}/ovpn/certs/$confighash{$cgiparams{'KEY'}}[
>>> 1].p12");
>>> -- 
>>> 2.12.2
>>> 
>> 
>> 
>
  
ummeegge March 25, 2020, 12:09 p.m. UTC | #4
Am Dienstag, den 24.03.2020, 14:42 +0000 schrieb Michael Tremer:
> Yes, please. If we spot a bug, we should of course fix it :)
OK, will send another patch for this. May at the evening.

Best,

Erik

> 
> > On 24 Mar 2020, at 12:31, ummeegge <ummeegge@ipfire.org> wrote:
> > 
> > Hi Michael,
> > 
> > Am Dienstag, den 24.03.2020, 11:31 +0000 schrieb Michael Tremer:
> > > Hello,
> > > 
> > > Brilliant fix. Thanks for looking into this so quickly.
> > 
> > your welcome.
> > 
> > > 
> > > Did you check if we have any other issues like this?
> > 
> > Not similar to that one as far as i can see.
> > This one -->
> > 
https://git.ipfire.org/?p=ipfire-2.x.git;a=blob;f=html/cgi-bin/ovpnmain.cgi;hb=91457877199d3ac8438efc7be4cd6a50e48e37e4#l1221
> > comes closer but it works.
> > Should i nevertheless ?
> > 
> > Best,
> > 
> > Erik
> > 
> > > 
> > > Best,
> > > -Michael
> > > 
> > > Reviewed-by: Michael Tremer <michael.tremer@ipfire.org>
> > > 
> > > > On 24 Mar 2020, at 10:29, Erik Kapfer <ummeegge@ipfire.org>
> > > > wrote:
> > > > 
> > > > Fix #12334
> > > > 
> > > > Signed-off-by: Erik Kapfer <ummeegge@ipfire.org>
> > > > ---
> > > > html/cgi-bin/ovpnmain.cgi | 2 +-
> > > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > > > 
> > > > diff --git a/html/cgi-bin/ovpnmain.cgi b/html/cgi-
> > > > bin/ovpnmain.cgi
> > > > index e76a688fe..a6fdd6d75 100644
> > > > --- a/html/cgi-bin/ovpnmain.cgi
> > > > +++ b/html/cgi-bin/ovpnmain.cgi
> > > > @@ -2464,7 +2464,7 @@ else
> > > > 
> > > > 		if ($confighash{$cgiparams{'KEY'}}[3] eq 'net')
> > > > {
> > > > 			# Stop the N2N connection before it is
> > > > removed
> > > > -			system("/usr/local/bin/openvpnctrl
> > > > -kn2n
> > > > $confighash{$cgiparams{'KEY'}}[1] &>/dev/null");
> > > > +			system('/usr/local/bin/openvpnctrl', '-
> > > > kn2n',
> > > > $confighash{$cgiparams{'KEY'}}[1]);
> > > > 
> > > > 			my $conffile =
> > > > glob("${General::swroot}/ovpn/n2nconf/$confighash{$cgiparams{'K
> > > > EY'}
> > > > }[1]/$confighash{$cgiparams{'KEY'}}[1].conf");
> > > > 			my $certfile =
> > > > glob("${General::swroot}/ovpn/certs/$confighash{$cgiparams{'KEY
> > > > '}}[
> > > > 1].p12");
> > > > -- 
> > > > 2.12.2
> > > > 
> > > 
> > > 
> 
>
  
ummeegge March 25, 2020, 5:48 p.m. UTC | #5
Have had a double look into this one specific and it should be left as
it is since it works and the other solution will breaks it. But have
found some more. Need a little more time.

Best,

Erik

Am Mittwoch, den 25.03.2020, 13:09 +0100 schrieb ummeegge:
> Am Dienstag, den 24.03.2020, 14:42 +0000 schrieb Michael Tremer:
> > Yes, please. If we spot a bug, we should of course fix it :)
> 
> OK, will send another patch for this. May at the evening.
> 
> Best,
> 
> Erik
> 
> > 
> > > On 24 Mar 2020, at 12:31, ummeegge <ummeegge@ipfire.org> wrote:
> > > 
> > > Hi Michael,
> > > 
> > > Am Dienstag, den 24.03.2020, 11:31 +0000 schrieb Michael Tremer:
> > > > Hello,
> > > > 
> > > > Brilliant fix. Thanks for looking into this so quickly.
> > > 
> > > your welcome.
> > > 
> > > > 
> > > > Did you check if we have any other issues like this?
> > > 
> > > Not similar to that one as far as i can see.
> > > This one -->
> > > 
> 
> 
https://git.ipfire.org/?p=ipfire-2.x.git;a=blob;f=html/cgi-bin/ovpnmain.cgi;hb=91457877199d3ac8438efc7be4cd6a50e48e37e4#l1221
> > > comes closer but it works.
> > > Should i nevertheless ?
> > > 
> > > Best,
> > > 
> > > Erik
> > > 
> > > > 
> > > > Best,
> > > > -Michael
> > > > 
> > > > Reviewed-by: Michael Tremer <michael.tremer@ipfire.org>
> > > > 
> > > > > On 24 Mar 2020, at 10:29, Erik Kapfer <ummeegge@ipfire.org>
> > > > > wrote:
> > > > > 
> > > > > Fix #12334
> > > > > 
> > > > > Signed-off-by: Erik Kapfer <ummeegge@ipfire.org>
> > > > > ---
> > > > > html/cgi-bin/ovpnmain.cgi | 2 +-
> > > > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > > > > 
> > > > > diff --git a/html/cgi-bin/ovpnmain.cgi b/html/cgi-
> > > > > bin/ovpnmain.cgi
> > > > > index e76a688fe..a6fdd6d75 100644
> > > > > --- a/html/cgi-bin/ovpnmain.cgi
> > > > > +++ b/html/cgi-bin/ovpnmain.cgi
> > > > > @@ -2464,7 +2464,7 @@ else
> > > > > 
> > > > > 		if ($confighash{$cgiparams{'KEY'}}[3] eq 'net')
> > > > > {
> > > > > 			# Stop the N2N connection before it is
> > > > > removed
> > > > > -			system("/usr/local/bin/openvpnctrl
> > > > > -kn2n
> > > > > $confighash{$cgiparams{'KEY'}}[1] &>/dev/null");
> > > > > +			system('/usr/local/bin/openvpnctrl', '-
> > > > > kn2n',
> > > > > $confighash{$cgiparams{'KEY'}}[1]);
> > > > > 
> > > > > 			my $conffile =
> > > > > glob("${General::swroot}/ovpn/n2nconf/$confighash{$cgiparams{
> > > > > 'K
> > > > > EY'}
> > > > > }[1]/$confighash{$cgiparams{'KEY'}}[1].conf");
> > > > > 			my $certfile =
> > > > > glob("${General::swroot}/ovpn/certs/$confighash{$cgiparams{'K
> > > > > EY
> > > > > '}}[
> > > > > 1].p12");
> > > > > -- 
> > > > > 2.12.2
> > > > > 
> > > > 
> > > > 
> > 
> > 
> 
>
  

Patch

diff --git a/html/cgi-bin/ovpnmain.cgi b/html/cgi-bin/ovpnmain.cgi
index e76a688fe..a6fdd6d75 100644
--- a/html/cgi-bin/ovpnmain.cgi
+++ b/html/cgi-bin/ovpnmain.cgi
@@ -2464,7 +2464,7 @@  else
 
 		if ($confighash{$cgiparams{'KEY'}}[3] eq 'net') {
 			# Stop the N2N connection before it is removed
-			system("/usr/local/bin/openvpnctrl -kn2n $confighash{$cgiparams{'KEY'}}[1] &>/dev/null");
+			system('/usr/local/bin/openvpnctrl', '-kn2n', $confighash{$cgiparams{'KEY'}}[1]);
 
 			my $conffile = glob("${General::swroot}/ovpn/n2nconf/$confighash{$cgiparams{'KEY'}}[1]/$confighash{$cgiparams{'KEY'}}[1].conf");
 			my $certfile = glob("${General::swroot}/ovpn/certs/$confighash{$cgiparams{'KEY'}}[1].p12");