From bfee206c989a77ae56701aec25a435262dcda1ee Mon Sep 17 00:00:00 2001 From: Alexander Marx Date: Thu, 7 Feb 2013 12:12:11 +0100 Subject: [PATCH] Forward Firewall: When changing a service which is used in a rule, the rule was destroyed. Now the configfiles of the firewall are adapted as needed. --- html/cgi-bin/fwhosts.cgi | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/html/cgi-bin/fwhosts.cgi b/html/cgi-bin/fwhosts.cgi index 6b6a5ec23c..06522acc19 100755 --- a/html/cgi-bin/fwhosts.cgi +++ b/html/cgi-bin/fwhosts.cgi @@ -151,6 +151,30 @@ if ($fwhostsettings{'ACTION'} eq 'updateservice') $customservice{$key1}[3] = $fwhostsettings{'ICMP_TYPES'}; $customservice{$key1}[4] = $count; &General::writehasharray("$configsrv", \%customservice); + + #check if we need to update configfiles for rules + if ($fwhostsettings{'SRV_NAME'} ne $fwhostsettings{'oldsrvname'}){ + if ( ! -z $fwconfigfwd ){ + &General::readhasharray("$fwconfigfwd", \%fwfwd); + foreach my $key (sort keys %fwfwd){ + if ($fwfwd{$key}[15] eq $fwhostsettings{'oldsrvname'}){ + $fwfwd{$key}[15] = $fwhostsettings{'SRV_NAME'}; + } + } + &General::writehasharray("$fwconfigfwd", \%fwfwd); + $needrules='on'; + } + if ( ! -z $fwconfiginp ){ + &General::readhasharray("$fwconfiginp", \%fwinp); + foreach my $line (sort keys %fwinp){ + if ($fwfwd{$line}[15] eq $fwhostsettings{'oldsrvname'}){ + $fwfwd{$line}[15] = $fwhostsettings{'SRV_NAME'}; + } + } + &General::writehasharray("$fwconfiginp", \%fwinp); + } + $needrules='on'; + } if($fwhostsettings{'updatesrv'} eq 'on'){ if($count gt 0 && $fwhostsettings{'oldsrvport'} ne $fwhostsettings{'SRV_PORT'} ){ $needrules='on'; @@ -169,7 +193,6 @@ if ($fwhostsettings{'ACTION'} eq 'updateservice') $fwhostsettings{'updatesrv'}= 'on'; } if($needrules eq 'on'){ - $errormessage="reread!"; &rules; } &addservice; -- 2.39.2