BUG:11312 When renaming a GeoIP Group, the corresponding names in firewallrules (if any) are not changed accordingly. Now when changing a GeoIP Group the firewallrules are renamed correctly.

Message ID afc6319d-1bb8-84bf-d59a-ef4f5cacbb90@link38.eu
State Accepted
Commit 40a930bda59180d3d88affd8bec028ebb375c05d
Headers
Series BUG:11312 When renaming a GeoIP Group, the corresponding names in firewallrules (if any) are not changed accordingly. Now when changing a GeoIP Group the firewallrules are renamed correctly. |

Commit Message

Peter Müller April 27, 2018, 1:31 a.m. UTC
  Slightly improved first version of this patch (contained
a blank line with trailing whitespace). No functionality
changed, patch has been confirmed as working correctly.

Fixes: #11312
Signed-off-by: Peter Müller <peter.mueller@link38.eu>
Signed-off-by: Alexander Marx <alexander.marx@ipfire.org>
---
 html/cgi-bin/fwhosts.cgi | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
  

Comments

Michael Tremer April 27, 2018, 3:03 a.m. UTC | #1
Merged, but please don't do subject lines of that length again :)

On Thu, 2018-04-26 at 17:31 +0200, Peter Müller wrote:
> Slightly improved first version of this patch (contained
> a blank line with trailing whitespace). No functionality
> changed, patch has been confirmed as working correctly.
> 
> Fixes: #11312
> Signed-off-by: Peter Müller <peter.mueller@link38.eu>
> Signed-off-by: Alexander Marx <alexander.marx@ipfire.org>
> ---
>  html/cgi-bin/fwhosts.cgi | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/html/cgi-bin/fwhosts.cgi b/html/cgi-bin/fwhosts.cgi
> index a2ade8a20..10217425d 100644
> --- a/html/cgi-bin/fwhosts.cgi
> +++ b/html/cgi-bin/fwhosts.cgi
> @@ -1278,7 +1278,7 @@ if ($fwhostsettings{'ACTION'} eq 'changegeoipgrpname')
>  			}
>  			&General::writehasharray("$configgeoipgrp",
> \%customgeoipgrp );
>  			#change name in FW Rules
> -			&changenameinfw($fwhostsettings{'oldgrpname'},$fwhost
> settings{'grp'},6);
> +			&changenameinfw($fwhostsettings{'oldgrpname'},$fwhost
> settings{'grp'},4,"geoip");
>  		}
>  	}
>  	&addgeoipgrp;
> @@ -3052,6 +3052,12 @@ sub changenameinfw
>  	my $old=shift;
>  	my $new=shift;
>  	my $fld=shift;
> +	my $type=shift;
> +
> +	if ($type eq 'geoip'){
> +		$old="group:$old";
> +		$new="group:$new";
> +	}
>  	&General::readhasharray("$fwconfigfwd", \%fwfwd);
>  	&General::readhasharray("$fwconfiginp", \%fwinp);
>  	&General::readhasharray("$fwconfigout", \%fwout);
  

Patch

diff --git a/html/cgi-bin/fwhosts.cgi b/html/cgi-bin/fwhosts.cgi
index a2ade8a20..10217425d 100644
--- a/html/cgi-bin/fwhosts.cgi
+++ b/html/cgi-bin/fwhosts.cgi
@@ -1278,7 +1278,7 @@  if ($fwhostsettings{'ACTION'} eq 'changegeoipgrpname')
 			}
 			&General::writehasharray("$configgeoipgrp", \%customgeoipgrp );
 			#change name in FW Rules
-			&changenameinfw($fwhostsettings{'oldgrpname'},$fwhostsettings{'grp'},6);
+			&changenameinfw($fwhostsettings{'oldgrpname'},$fwhostsettings{'grp'},4,"geoip");
 		}
 	}
 	&addgeoipgrp;
@@ -3052,6 +3052,12 @@  sub changenameinfw
 	my $old=shift;
 	my $new=shift;
 	my $fld=shift;
+	my $type=shift;
+
+	if ($type eq 'geoip'){
+		$old="group:$old";
+		$new="group:$new";
+	}
 	&General::readhasharray("$fwconfigfwd", \%fwfwd);
 	&General::readhasharray("$fwconfiginp", \%fwinp);
 	&General::readhasharray("$fwconfigout", \%fwout);