X-Git-Url: http://git.ipfire.org/?p=people%2Fteissler%2Fipfire-2.x.git;a=blobdiff_plain;f=html%2Fcgi-bin%2Ffwhosts.cgi;h=90e1fb305c39fa788fe3d1ec6ca5455d4827b009;hp=5a838369268502e93f5ad799a51b888af738c506;hb=d928d79566cd802f85cd38bcd8bd76f4bb112547;hpb=62fc8511664c6646d706aa42927bac53ac6a5b5f
diff --git a/html/cgi-bin/fwhosts.cgi b/html/cgi-bin/fwhosts.cgi
index 5a8383692..90e1fb305 100755
--- a/html/cgi-bin/fwhosts.cgi
+++ b/html/cgi-bin/fwhosts.cgi
@@ -80,6 +80,11 @@ unless (-e $configsrvgrp) { system("touch $configsrvgrp"); }
&Header::openbigbox('100%', 'center');
## ACTION ####
+if ($fwhostsettings{'ACTION'} eq $Lang::tr{'fwdfw reread'})
+{
+ &reread_rules;
+ &showmenu;
+}
# Update
if ($fwhostsettings{'ACTION'} eq 'updatenet' )
{
@@ -108,30 +113,29 @@ if ($fwhostsettings{'ACTION'} eq 'updatehost')
{
if($customhost{$key}[0] eq $fwhostsettings{'orgname'})
{
- $fwhostsettings{'orgname'} = $customhost{$key}[0];
if ($customhost{$key}[1] eq 'ip'){
($ip,$subnet) = split (/\//,$customhost{$key}[2]);
}else{
$ip = $customhost{$key}[2];
}
$fwhostsettings{'orgip'} = $ip;
- $fwhostsettings{'count'} = $customhost{$key}[3];
+ $fwhostsettings{'count'} = $customhost{$key}[4];
delete $customhost{$key};
+ &General::writehasharray("$confighost", \%customhost);
}
}
- &General::writehasharray("$confighost", \%customhost);
-
-
-
$fwhostsettings{'actualize'} = 'on';
+ if($fwhostsettings{'orgip'}){
$fwhostsettings{'ACTION'} = 'savehost';
+ }else{
+ $fwhostsettings{'ACTION'} = $Lang::tr{'fwhost newhost'};
+ }
}
if ($fwhostsettings{'ACTION'} eq 'updateservice')
{
my $count=0;
my $needrules=0;
$errormessage=&checkports(\%customservice);
-
if (!$errormessage){
&General::readhasharray("$configsrv", \%customservice);
foreach my $key (keys %customservice)
@@ -155,30 +159,54 @@ if ($fwhostsettings{'ACTION'} eq 'updateservice')
$customservice{$key1}[3] = $fwhostsettings{'ICMP_TYPES'};
$customservice{$key1}[4] = $count;
&General::writehasharray("$configsrv", \%customservice);
- if($fwhostsettings{'updatesrv'} eq 'on'){
- if($count gt 0 && $fwhostsettings{'oldsrvport'} ne $fwhostsettings{'SRV_PORT'} ){
- $needrules='on';
+ #check if we need to update firewallrules
+ 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);
+ }
+ 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);
}
- if($count gt 0 && $fwhostsettings{'oldsrvprot'} ne $fwhostsettings{'PROT'} ){
- $needrules='on';
+ #check if we need to update groups
+ &General::readhasharray("$configsrvgrp", \%customservicegrp);
+ foreach my $key (sort keys %customservicegrp){
+ if($customservicegrp{$key}[2] eq $fwhostsettings{'oldsrvname'}){
+ $customservicegrp{$key}[2] = $fwhostsettings{'SRV_NAME'};
+ }
}
+ &General::writehasharray("$configsrvgrp", \%customservicegrp);
+ $needrules='on';
+ }
+ if($count gt 0 && $fwhostsettings{'oldsrvport'} ne $fwhostsettings{'SRV_PORT'} ){
+ $needrules='on';
+ }
+ if($count gt 0 && $fwhostsettings{'oldsrvprot'} ne $fwhostsettings{'PROT'} ){
+ $needrules='on';
}
$fwhostsettings{'SRV_NAME'} = '';
$fwhostsettings{'SRV_PORT'} = '';
$fwhostsettings{'PROT'} = '';
-
}else{
$fwhostsettings{'SRV_NAME'} = $fwhostsettings{'oldsrvname'};
$fwhostsettings{'SRV_PORT'} = $fwhostsettings{'oldsrvport'};
$fwhostsettings{'PROT'} = $fwhostsettings{'oldsrvprot'};
$fwhostsettings{'updatesrv'}= 'on';
}
-
if($needrules eq 'on'){
- $errormessage="reread!";
&rules;
}
-
&addservice;
}
# save
@@ -187,7 +215,6 @@ if ($fwhostsettings{'ACTION'} eq 'savenet' )
my $count=0;
my $needrules=0;
if ($fwhostsettings{'orgname'} eq ''){$fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};}
-
#check if all fields are set
if ($fwhostsettings{'HOSTNAME'} eq '' || $fwhostsettings{'IP'} eq '' || $fwhostsettings{'SUBNET'} eq '')
{
@@ -207,7 +234,6 @@ if ($fwhostsettings{'ACTION'} eq 'savenet' )
if(&General::iporsubtocidr($fwhostsettings{'SUBNET'}) eq '32')
{
$errormessage=$errormessage.$Lang::tr{'fwhost err sub32'};
-
}
if($fwhostsettings{'error'} ne 'on'){
#check if we use one of ipfire's networks (green,orange,blue)
@@ -240,14 +266,12 @@ if ($fwhostsettings{'ACTION'} eq 'savenet' )
if (!$errormessage){
&plausicheck("editnet");
}
-
#check if network ip is part of an already used one
if(&checksubnet(\%customnetwork))
{
$errormessage=$errormessage.$Lang::tr{'fwhost err partofnet'};
$fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
}
-
if($fwhostsettings{'actualize'} eq 'on' && $fwhostsettings{'newnet'} ne 'on' && $errormessage)
{
$fwhostsettings{'actualize'} = '';
@@ -260,7 +284,6 @@ if ($fwhostsettings{'ACTION'} eq 'savenet' )
&General::writehasharray("$confignet", \%customnetwork);
undef %customnetwork;
}
-
if (!$errormessage){
&General::readhasharray("$confignet", \%customnetwork);
if ($fwhostsettings{'ACTION'} eq 'updatenet'){
@@ -345,23 +368,19 @@ if ($fwhostsettings{'ACTION'} eq 'savenet' )
&viewtablenet;
}
}
-
}
if ($fwhostsettings{'ACTION'} eq 'savehost')
{
my $count=0;
my $needrules=0;
if ($fwhostsettings{'orgname'} eq ''){$fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};}
-
$fwhostsettings{'SUBNET'}='32';
-
#check if all fields are set
if ($fwhostsettings{'HOSTNAME'} eq '' || $fwhostsettings{'IP'} eq '' || $fwhostsettings{'SUBNET'} eq '')
{
$errormessage=$errormessage.$Lang::tr{'fwhost err empty'};
$fwhostsettings{'ACTION'} = 'edithost';
}else{
-
if($fwhostsettings{'type'} eq 'ip' && $fwhostsettings{'IP'}=~/^([0-9a-fA-F]{1,2}:){5}[0-9a-fA-F]{1,2}$/){
$fwhostsettings{'type'} = 'mac';
}elsif($fwhostsettings{'type'} eq 'mac' && $fwhostsettings{'IP'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
@@ -374,15 +393,17 @@ if ($fwhostsettings{'ACTION'} eq 'savehost')
$fwhostsettings{'type'} = '';
$errormessage=$Lang::tr{'fwhost err ipmac'};
}
-
if($fwhostsettings{'type'} eq 'mac' )
{
if ($fwhostsettings{'IP'}!~/^([0-9a-fA-F]{1,2}:){5}[0-9a-fA-F]{1,2}$/ )
{
$errormessage=$Lang::tr{'fwhost err mac'};
-
}
}
+ #check remark
+ if ($fwhostsettings{'HOSTREMARK'} ne '' && !&validremark($fwhostsettings{'HOSTREMARK'})){
+ $errormessage=$Lang::tr{'fwhost err remark'};
+ }
#CHECK IP-PART
if ($fwhostsettings{'type'} eq 'ip'){
#check for subnet
@@ -392,7 +413,6 @@ if ($fwhostsettings{'ACTION'} eq 'savehost')
$errormessage.=$errormessage.$Lang::tr{'fwhost err ip'};
$fwhostsettings{'error'}='on';
}
-
}elsif(rindex($fwhostsettings{'IP'},'/') ne '-1' ){
$errormessage=$errormessage.$Lang::tr{'fwhost err ipwithsub'};
$fwhostsettings{'error'}='on';
@@ -403,18 +423,14 @@ if ($fwhostsettings{'ACTION'} eq 'savehost')
$errormessage=$Lang::tr{'fwhost err hostip'};
}
}
-
-
-
#only check plausi when no error till now
if (!$errormessage){
&plausicheck("edithost");
}
-
if($fwhostsettings{'actualize'} eq 'on' && $fwhostsettings{'newhost'} ne 'on' && $errormessage){
$fwhostsettings{'actualize'} = '';
my $key = &General::findhasharraykey (\%customhost);
- foreach my $i (0 .. 3) { $customhost{$key}[$i] = "";}
+ foreach my $i (0 .. 4) { $customhost{$key}[$i] = "";}
$customhost{$key}[0] = $fwhostsettings{'orgname'} ;
$customhost{$key}[1] = $fwhostsettings{'type'} ;
if($customhost{$key}[1] eq 'ip'){
@@ -422,12 +438,11 @@ if ($fwhostsettings{'ACTION'} eq 'savehost')
}else{
$customhost{$key}[2] = $fwhostsettings{'orgip'};
}
- $customhost{$key}[3] = $fwhostsettings{'count'};
+ $customhost{$key}[3] = $fwhostsettings{'HOSTREMARK'};
+ $customhost{$key}[4] = $fwhostsettings{'count'};
&General::writehasharray("$confighost", \%customhost);
undef %customhost;
-
}
-
if (!$errormessage){
#get count if host was edited
if($fwhostsettings{'actualize'} eq 'on'){
@@ -470,7 +485,7 @@ if ($fwhostsettings{'ACTION'} eq 'savehost')
}
}
my $key = &General::findhasharraykey (\%customhost);
- foreach my $i (0 .. 3) { $customhost{$key}[$i] = "";}
+ foreach my $i (0 .. 4) { $customhost{$key}[$i] = "";}
$customhost{$key}[0] = $fwhostsettings{'HOSTNAME'} ;
$customhost{$key}[1] = $fwhostsettings{'type'} ;
if ($fwhostsettings{'type'} eq 'ip'){
@@ -482,14 +497,14 @@ if ($fwhostsettings{'ACTION'} eq 'savehost')
$customhost{$key}[2] = $fwhostsettings{'IP'};
}
if($fwhostsettings{'newhost'} eq 'on'){$count=0;}
- $customhost{$key}[3] = $count;
+ $customhost{$key}[3] = $fwhostsettings{'HOSTREMARK'};
+ $customhost{$key}[4] =$count;
&General::writehasharray("$confighost", \%customhost);
-
- #$fwhostsettings{'IP'} = $fwhostsettings{'IP'}."/".&General::iporsubtodec($fwhostsettings{'SUBNET'});
undef %customhost;
$fwhostsettings{'HOSTNAME'}='';
$fwhostsettings{'IP'}='';
$fwhostsettings{'type'}='';
+ $fwhostsettings{'HOSTREMARK'}='';
#check if we need to update rules while host was edited
if($needrules eq 'on'){
&rules;
@@ -500,13 +515,11 @@ if ($fwhostsettings{'ACTION'} eq 'savehost')
&addhost;
&viewtablehost;
}
-
}
-
}
if ($fwhostsettings{'ACTION'} eq 'savegrp')
{
- my $grp;
+ my $grp=$fwhostsettings{'grp_name'};;
my $rem=$fwhostsettings{'remark'};
my $count;
my $type;
@@ -516,121 +529,108 @@ if ($fwhostsettings{'ACTION'} eq 'savegrp')
&General::readhasharray("$configgrp", \%customgrp);
&General::readhasharray("$confignet", \%customnetwork);
&General::readhasharray("$confighost", \%customhost);
- $grp=$fwhostsettings{'grp_name'};
-
- if (!&General::validhostname($grp)){$errormessage=$errormessage.$Lang::tr{'fwhost err name'};}
-
- ###check standard networks
- if ($fwhostsettings{'grp2'} eq 'std_net'){
- @target=$fwhostsettings{'DEFAULT_SRC_ADR'};
- $type='Standard Network';
- }
- ##check custom networks
- if ($fwhostsettings{'grp2'} eq 'cust_net' && $fwhostsettings{'CUST_SRC_NET'} ne ''){
- @target=$fwhostsettings{'CUST_SRC_NET'};
- $updcounter='net';
- $type='Custom Network';
- }elsif($fwhostsettings{'grp2'} eq 'cust_net' && $fwhostsettings{'CUST_SRC_NET'} eq ''){
- $errormessage=$Lang::tr{'fwhost err groupempty'}."
";
- $fwhostsettings{'grp_name'}='';
- $fwhostsettings{'remark'}='';
- }
- #check custom addresses
- if ($fwhostsettings{'grp2'} eq 'cust_host' && $fwhostsettings{'CUST_SRC_HOST'} ne ''){
- @target=$fwhostsettings{'CUST_SRC_HOST'};
- $updcounter='host';
- $type='Custom Host';
- }elsif($fwhostsettings{'grp2'} eq 'cust_host' && $fwhostsettings{'CUST_SRC_HOST'} eq ''){
- $errormessage=$Lang::tr{'fwhost err groupempty'}."
";
- $fwhostsettings{'grp_name'}='';
- $fwhostsettings{'remark'}='';
- }
- #get address from ovpn ccd static net
- if ($fwhostsettings{'grp2'} eq 'ovpn_net' && $fwhostsettings{'OVPN_CCD_NET'} ne ''){
- @target=$fwhostsettings{'OVPN_CCD_NET'};
- $type='OpenVPN static network';
- }elsif($fwhostsettings{'grp2'} eq 'ovpn_net' && $fwhostsettings{'OVPN_CCD_NET'} eq ''){
- $errormessage=$Lang::tr{'fwhost err groupempty'};
- $fwhostsettings{'grp_name'}='';
- $fwhostsettings{'remark'}='';
- }
- #get address from ovpn ccd static host
- if ($fwhostsettings{'grp2'} eq 'ovpn_host' && $fwhostsettings{'OVPN_CCD_HOST'} ne ''){
- @target=$fwhostsettings{'OVPN_CCD_HOST'};
- $type='OpenVPN static host';
- }elsif ($fwhostsettings{'grp2'} eq 'ovpn_host' && $fwhostsettings{'OVPN_CCD_HOST'} eq ''){
- $errormessage=$Lang::tr{'fwhost err groupempty'};
- }
- #get address from ovpn ccd Net-2-Net
- if ($fwhostsettings{'grp2'} eq 'ovpn_n2n' && $fwhostsettings{'OVPN_N2N'} ne ''){
- @target=$fwhostsettings{'OVPN_N2N'};
- $type='OpenVPN N-2-N';
- }elsif ($fwhostsettings{'grp2'} eq 'ovpn_n2n' && $fwhostsettings{'OVPN_N2N'} eq ''){
- $errormessage=$Lang::tr{'fwhost err groupempty'};
- $fwhostsettings{'grp_name'}='';
- $fwhostsettings{'remark'}='';
- }
-
- #get address from IPSEC HOST
- if ($fwhostsettings{'grp2'} eq 'ipsec_host' && $fwhostsettings{'IPSEC_HOST'} ne ''){
- @target=$fwhostsettings{'IPSEC_HOST'};
- $type='IpSec Host';
- }elsif ($fwhostsettings{'grp2'} eq 'ipsec_host' && $fwhostsettings{'IPSEC_HOST'} eq ''){
- $errormessage=$Lang::tr{'fwhost err groupempty'};
- $fwhostsettings{'grp_name'}='';
- $fwhostsettings{'remark'}='';
- }
- #get address from IPSEC NETWORK
- if ($fwhostsettings{'grp2'} eq 'ipsec_net' && $fwhostsettings{'IPSEC_NET'} ne ''){
- @target=$fwhostsettings{'IPSEC_NET'};
- $type='IpSec Network';
- }elsif ($fwhostsettings{'grp2'} eq 'ipsec_net' && $fwhostsettings{'IPSEC_NET'} eq ''){
- $errormessage=$Lang::tr{'fwhost err groupempty'};
- $fwhostsettings{'grp_name'}='';
- $fwhostsettings{'remark'}='';
- }
-
- #check if host/net exists in grp
- my $test="$grp,$fwhostsettings{'oldremark'},@target";
- foreach my $key (keys %customgrp) {
- my $test1="$customgrp{$key}[0],$customgrp{$key}[1],$customgrp{$key}[2]";
- if ($test1 eq $test){
- $errormessage=$Lang::tr{'fwhost err isingrp'};
- $fwhostsettings{'update'} = 'on';
+ #check name
+ if (!&validhostname($grp)){$errormessage.=$Lang::tr{'fwhost err name'};}
+ #check remark
+ if ($rem ne '' && !&validremark($rem) && $fwhostsettings{'update'} ne 'on'){
+ $errormessage.=$Lang::tr{'fwhost err remark'};
+ }
+ if ($fwhostsettings{'update'} eq 'on'){
+ #check standard networks
+ if ($fwhostsettings{'grp2'} eq 'std_net'){
+ @target=$fwhostsettings{'DEFAULT_SRC_ADR'};
+ $type='Standard Network';
+ }
+ #check custom networks
+ if ($fwhostsettings{'grp2'} eq 'cust_net' && $fwhostsettings{'CUST_SRC_NET'} ne ''){
+ @target=$fwhostsettings{'CUST_SRC_NET'};
+ $updcounter='net';
+ $type='Custom Network';
+ }elsif($fwhostsettings{'grp2'} eq 'cust_net' && $fwhostsettings{'CUST_SRC_NET'} eq ''){
+ $errormessage=$Lang::tr{'fwhost err groupempty'}."
";
+ $fwhostsettings{'grp_name'}='';
+ $fwhostsettings{'remark'}='';
+ }
+ #check custom addresses
+ if ($fwhostsettings{'grp2'} eq 'cust_host' && $fwhostsettings{'CUST_SRC_HOST'} ne ''){
+ @target=$fwhostsettings{'CUST_SRC_HOST'};
+ $updcounter='host';
+ $type='Custom Host';
+ }elsif($fwhostsettings{'grp2'} eq 'cust_host' && $fwhostsettings{'CUST_SRC_HOST'} eq ''){
+ $errormessage=$Lang::tr{'fwhost err groupempty'}."
";
+ $fwhostsettings{'grp_name'}='';
+ $fwhostsettings{'remark'}='';
+ }
+ #get address from ovpn ccd static net
+ if ($fwhostsettings{'grp2'} eq 'ovpn_net' && $fwhostsettings{'OVPN_CCD_NET'} ne ''){
+ @target=$fwhostsettings{'OVPN_CCD_NET'};
+ $type='OpenVPN static network';
+ }elsif($fwhostsettings{'grp2'} eq 'ovpn_net' && $fwhostsettings{'OVPN_CCD_NET'} eq ''){
+ $errormessage=$Lang::tr{'fwhost err groupempty'};
+ $fwhostsettings{'grp_name'}='';
+ $fwhostsettings{'remark'}='';
+ }
+ #get address from ovpn ccd static host
+ if ($fwhostsettings{'grp2'} eq 'ovpn_host' && $fwhostsettings{'OVPN_CCD_HOST'} ne ''){
+ @target=$fwhostsettings{'OVPN_CCD_HOST'};
+ $type='OpenVPN static host';
+ }elsif ($fwhostsettings{'grp2'} eq 'ovpn_host' && $fwhostsettings{'OVPN_CCD_HOST'} eq ''){
+ $errormessage=$Lang::tr{'fwhost err groupempty'};
+ }
+ #get address from ovpn ccd Net-2-Net
+ if ($fwhostsettings{'grp2'} eq 'ovpn_n2n' && $fwhostsettings{'OVPN_N2N'} ne ''){
+ @target=$fwhostsettings{'OVPN_N2N'};
+ $type='OpenVPN N-2-N';
+ }elsif ($fwhostsettings{'grp2'} eq 'ovpn_n2n' && $fwhostsettings{'OVPN_N2N'} eq ''){
+ $errormessage=$Lang::tr{'fwhost err groupempty'};
+ $fwhostsettings{'grp_name'}='';
+ $fwhostsettings{'remark'}='';
+ }
+ #get address from IPSEC HOST
+ if ($fwhostsettings{'grp2'} eq 'ipsec_host' && $fwhostsettings{'IPSEC_HOST'} ne ''){
+ @target=$fwhostsettings{'IPSEC_HOST'};
+ $type='IpSec Host';
+ }elsif ($fwhostsettings{'grp2'} eq 'ipsec_host' && $fwhostsettings{'IPSEC_HOST'} eq ''){
+ $errormessage=$Lang::tr{'fwhost err groupempty'};
+ $fwhostsettings{'grp_name'}='';
+ $fwhostsettings{'remark'}='';
+ }
+ #get address from IPSEC NETWORK
+ if ($fwhostsettings{'grp2'} eq 'ipsec_net' && $fwhostsettings{'IPSEC_NET'} ne ''){
+ @target=$fwhostsettings{'IPSEC_NET'};
+ $type='IpSec Network';
+ }elsif ($fwhostsettings{'grp2'} eq 'ipsec_net' && $fwhostsettings{'IPSEC_NET'} eq ''){
+ $errormessage=$Lang::tr{'fwhost err groupempty'};
+ $fwhostsettings{'grp_name'}='';
+ $fwhostsettings{'remark'}='';
+ }
+ #check if host/net exists in grp
+
+ my $test="$grp,$fwhostsettings{'oldremark'},@target";
+ foreach my $key (keys %customgrp) {
+ my $test1="$customgrp{$key}[0],$customgrp{$key}[1],$customgrp{$key}[2]";
+ if ($test1 eq $test){
+ $errormessage=$Lang::tr{'fwhost err isingrp'};
+ $fwhostsettings{'update'} = 'on';
+ }
}
}
-
+
if (!$errormessage){
#on first save, we have an empty @target, so fill it with nothing
my $targetvalues=@target;
if ($targetvalues == '0'){
- @target=$Lang::tr{'fwhost empty'};
+ @target="none";
}
#on update, we have to delete the dummy entry
-
foreach my $key (keys %customgrp){
- if ($customgrp{$key}[0] eq $grp && $customgrp{$key}[2] eq $Lang::tr{'fwhost empty'}){
+ if ($customgrp{$key}[0] eq $grp && $customgrp{$key}[2] eq "none"){
delete $customgrp{$key};
last;
}
}
&General::writehasharray("$configgrp", \%customgrp);
&General::readhasharray("$configgrp", \%customgrp);
-
-
-
- #check if remark has also changed
- if ($fwhostsettings{'remark'} ne $fwhostsettings{'oldremark'} && $fwhostsettings{'update'} eq 'on')
- {
- foreach my $key (keys %customgrp)
- {
- if($customgrp{$key}[0] eq $grp && $customgrp{$key}[1] eq $fwhostsettings{'oldremark'})
- {
- $customgrp{$key}[1]='';
- $customgrp{$key}[1]=$rem;
- }
- }
- }
#get count used
foreach my $key (keys %customgrp)
{
@@ -658,7 +658,6 @@ if ($fwhostsettings{'ACTION'} eq 'savegrp')
$customgrp{$key}[4] = $count;
}
&General::writehasharray("$configgrp", \%customgrp);
-
#update counter in Host/Net
if($updcounter eq 'net'){
foreach my $key (keys %customnetwork) {
@@ -671,30 +670,13 @@ if ($fwhostsettings{'ACTION'} eq 'savegrp')
}elsif($updcounter eq 'host'){
foreach my $key (keys %customhost) {
if ($customhost{$key}[0] eq $fwhostsettings{'CUST_SRC_HOST'}){
- $customhost{$key}[3]=$customhost{$key}[3]+1;
+ $customhost{$key}[4]=$customhost{$key}[3]+1;
}
}
&General::writehasharray("$confighost", \%customhost);
}
-
$fwhostsettings{'update'}='on';
-
}
- if ($fwhostsettings{'remark'} ne $fwhostsettings{'oldremark'} && $errormessage)
- {
- foreach my $key (keys %customgrp)
- {
- if($customgrp{$key}[0] eq $grp && $customgrp{$key}[1] eq $fwhostsettings{'oldremark'})
- {
- $customgrp{$key}[1]='';
- $customgrp{$key}[1]=$rem;
- }
- }
- &General::writehasharray("$configsrvgrp", \%customservicegrp);
- $errormessage='';
- $hint=$Lang::tr{'fwhost changeremark'};
- $fwhostsettings{'update'}='on';
- }
#check if ruleupdate is needed
if($count > 0 )
{
@@ -702,15 +684,12 @@ if ($fwhostsettings{'ACTION'} eq 'savegrp')
}
&addgrp;
&viewtablegrp;
-
}
if ($fwhostsettings{'ACTION'} eq 'saveservice')
{
my $ICMP;
-
&General::readhasharray("$configsrv", \%customservice );
$errormessage=&checkports(\%customservice);
-
if ($fwhostsettings{'PROT'} eq 'ICMP'){
&General::readhasharray("${General::swroot}/fwhosts/icmp-types", \%icmptypes);
foreach my $key (keys %icmptypes){
@@ -721,7 +700,6 @@ if ($fwhostsettings{'ACTION'} eq 'saveservice')
}
if($ICMP eq ''){$ICMP='BLANK';}
if (!$errormessage){
-
my $key = &General::findhasharraykey (\%customservice);
foreach my $i (0 .. 4) { $customservice{$key}[$i] = "";}
$customservice{$key}[0] = $fwhostsettings{'SRV_NAME'};
@@ -735,11 +713,8 @@ if ($fwhostsettings{'ACTION'} eq 'saveservice')
$fwhostsettings{'SRV_PORT'}='';
$fwhostsettings{'PROT'}='';
$fwhostsettings{'ICMP_TYPES'}='';
-
}
-
&addservice;
-
}
if ($fwhostsettings{'ACTION'} eq 'saveservicegrp')
{
@@ -748,16 +723,15 @@ if ($fwhostsettings{'ACTION'} eq 'saveservicegrp')
my $count=0;
&General::readhasharray("$configsrvgrp", \%customservicegrp );
&General::readhasharray("$configsrv", \%customservice );
-
$errormessage=&checkservicegroup;
-
if (!$errormessage){
#on first save, we have to enter a dummy value
- if ($fwhostsettings{'CUST_SRV'} eq ''){$fwhostsettings{'CUST_SRV'}=$Lang::tr{'fwhost empty'};}
-
+ if ($fwhostsettings{'CUST_SRV'} eq ''){
+ $fwhostsettings{'CUST_SRV'}='none';
+ }
#on update, we have to delete the dummy entry
foreach my $key (keys %customservicegrp){
- if ($customservicegrp{$key}[2] eq $Lang::tr{'fwhost empty'}){
+ if ($customservicegrp{$key}[2] eq 'none'){
delete $customservicegrp{$key};
last;
}
@@ -780,7 +754,7 @@ if ($fwhostsettings{'ACTION'} eq 'saveservicegrp')
{
if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'})
{
- $count=$customservicegrp{$key}[5];
+ $count=$customservicegrp{$key}[3];
last;
}
}
@@ -794,32 +768,15 @@ if ($fwhostsettings{'ACTION'} eq 'saveservicegrp')
}
}
&General::writehasharray("$configsrv", \%customservice );
-
my $key = &General::findhasharraykey (\%customservicegrp);
foreach my $i (0 .. 3) { $customservice{$key}[$i] = "";}
$customservicegrp{$key}[0] = $fwhostsettings{'SRVGRP_NAME'};
$customservicegrp{$key}[1] = $fwhostsettings{'SRVGRP_REMARK'};
$customservicegrp{$key}[2] = $fwhostsettings{'CUST_SRV'};
- $customservicegrp{$key}[3] = $port;
- $customservicegrp{$key}[4] = $prot;
- $customservicegrp{$key}[5] = $count;
+ $customservicegrp{$key}[3] = $count;
&General::writehasharray("$configsrvgrp", \%customservicegrp );
$fwhostsettings{'updatesrvgrp'}='on';
}
- if ($fwhostsettings{'SRVGRP_REMARK'} ne $fwhostsettings{'oldsrvgrpremark'} && $errormessage){
- foreach my $key (keys %customservicegrp)
- {
- if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'} && $customservicegrp{$key}[1] eq $fwhostsettings{'oldsrvgrpremark'})
- {
- $customservicegrp{$key}[1]='';
- $customservicegrp{$key}[1]=$fwhostsettings{'SRVGRP_REMARK'};
- }
- }
- &General::writehasharray("$configsrvgrp", \%customservicegrp);
- $errormessage='';
- $hint=$Lang::tr{'fwhost changeremark'};
- $fwhostsettings{'update'}='on';
- }
if ($count gt 0){
&rules;
}
@@ -895,10 +852,11 @@ if ($fwhostsettings{'ACTION'} eq 'delhost')
}
&addhost;
&viewtablehost;
-
}
if ($fwhostsettings{'ACTION'} eq 'deletegrphost')
{
+ my $grpremark;
+ my $grpname;
&General::readhasharray("$configgrp", \%customgrp);
foreach my $key (keys %customgrp){
if($customgrp{$key}[0].",".$customgrp{$key}[1].",".$customgrp{$key}[2].",".$customgrp{$key}[3] eq $fwhostsettings{'delhost'}){
@@ -917,17 +875,23 @@ if ($fwhostsettings{'ACTION'} eq 'deletegrphost')
&General::readhasharray("$confighost", \%customhost);
foreach my $key1 (keys %customhost){
if ($customhost{$key1}[0] eq $customgrp{$key}[2]){
- $customhost{$key1}[3] = $customhost{$key1}[3]-1;
+ $customhost{$key1}[4] = $customhost{$key1}[4]-1;
last;
}
}
&General::writehasharray("$confighost", \%customhost);
}
+ $grpname=$customgrp{$key}[0];
+ $grpremark=$customgrp{$key}[1];
delete $customgrp{$key};
}
}
&General::writehasharray("$configgrp", \%customgrp);
- &rules;
+ if ($fwhostsettings{'grpcnt'} > 0){&rules;}
+ if ($fwhostsettings{'update'} eq 'on'){
+ $fwhostsettings{'remark'}= $grpremark;
+ $fwhostsettings{'grp_name'}=$grpname;
+ }
&addgrp;
&viewtablegrp;
}
@@ -981,6 +945,8 @@ if ($fwhostsettings{'ACTION'} eq 'delservicegrp')
}
if ($fwhostsettings{'ACTION'} eq 'delgrpservice')
{
+ my $grpname;
+ my $grpremark;
&General::readhasharray("$configsrvgrp", \%customservicegrp);
&General::readhasharray("$configsrv", \%customservice);
foreach my $key (keys %customservicegrp){
@@ -994,11 +960,18 @@ if ($fwhostsettings{'ACTION'} eq 'delgrpservice')
}
}
&General::writehasharray("$configsrv", \%customservice);
- delete $customservicegrp{$key}
+ $grpname=$customservicegrp{$key}[0];
+ $grpremark=$customservicegrp{$key}[1];
+ delete $customservicegrp{$key};
}
}
&General::writehasharray("$configsrvgrp", \%customservicegrp);
&rules;
+ if ($fwhostsettings{'updatesrvgrp'} eq 'on'){
+ #$fwhostsettings{'updatesrvgrp'}='on';
+ $fwhostsettings{'SRVGRP_NAME'}=$grpname;
+ $fwhostsettings{'SRVGRP_REMARK'}=$grpremark;
+ }
&addservicegrp;
&viewtableservicegrp;
@@ -1027,6 +1000,62 @@ if ($fwhostsettings{'ACTION'} eq $Lang::tr{'fwhost newservicegrp'})
&addservicegrp;
&viewtableservicegrp;
}
+if ($fwhostsettings{'ACTION'} eq 'changegrpremark')
+{
+ &General::readhasharray("$configgrp", \%customgrp);
+ if ($fwhostsettings{'oldrem'} ne $fwhostsettings{'newrem'} && (&validremark($fwhostsettings{'newrem'}) || $fwhostsettings{'newrem'} eq '')){
+ foreach my $key (sort keys %customgrp)
+ {
+ #$customgrp{$key}[1]=~ s/\|/,/g;
+ if($customgrp{$key}[0] eq $fwhostsettings{'grp'} && $customgrp{$key}[1] eq $fwhostsettings{'oldrem'})
+ {
+ #$fwhostsettings{'newrem'}=~ s/,/\|/g;
+ $customgrp{$key}[1]='';
+ $customgrp{$key}[1]=$fwhostsettings{'newrem'};
+ }
+ }
+ &General::writehasharray("$configgrp", \%customgrp);
+ $fwhostsettings{'update'}='on';
+ #$fwhostsettings{'newrem'}=~ s/\|/,/g;
+ $fwhostsettings{'remark'}=$fwhostsettings{'newrem'};
+ }else{
+ $errormessage=$Lang::tr{'fwhost err remark'};
+ $fwhostsettings{'remark'}=$fwhostsettings{'oldrem'};
+ $fwhostsettings{'grp_name'}=$fwhostsettings{'grp'};
+ $fwhostsettings{'update'} = 'on';
+ }
+ $fwhostsettings{'grp_name'}=$fwhostsettings{'grp'};
+ &addgrp;
+ &viewtablegrp;
+}
+if ($fwhostsettings{'ACTION'} eq 'changesrvgrpremark')
+{
+ &General::readhasharray("$configsrvgrp", \%customservicegrp );
+ if ($fwhostsettings{'oldsrvrem'} ne $fwhostsettings{'newsrvrem'} && (&validremark($fwhostsettings{'newsrvrem'}) || $fwhostsettings{'newsrvrem'} eq '')){
+ foreach my $key (sort keys %customservicegrp)
+ {
+ #$customservicegrp{$key}[1]=~ s/\|/,/g;
+ if($customservicegrp{$key}[0] eq $fwhostsettings{'srvgrp'} && $customservicegrp{$key}[1] eq $fwhostsettings{'oldsrvrem'})
+ {
+ #$fwhostsettings{'newsrvrem'}=~ s/,/|/g;
+ $customservicegrp{$key}[1]='';
+ $customservicegrp{$key}[1]=$fwhostsettings{'newsrvrem'};
+ }
+ }
+ &General::writehasharray("$configsrvgrp", \%customservicegrp);
+ $fwhostsettings{'updatesrvgrp'}='on';
+ #$fwhostsettings{'newsrvrem'}=~ s/\|/,/g;
+ $fwhostsettings{'SRVGRP_REMARK'}=$fwhostsettings{'newsrvrem'};
+ }else{
+ $errormessage=$Lang::tr{'fwhost err remark'};
+ $fwhostsettings{'SRVGRP_REMARK'}=$fwhostsettings{'oldsrvrem'};
+ $fwhostsettings{'SRVGRP_NAME'}=$fwhostsettings{'srvgrp'};
+ $fwhostsettings{'updatesrvgrp'} = 'on';
+ }
+ $fwhostsettings{'SRVGRP_NAME'}=$fwhostsettings{'srvgrp'};
+ &addservicegrp;
+ &viewtableservicegrp;
+}
### VIEW ###
if($fwhostsettings{'ACTION'} eq '')
{
@@ -1041,9 +1070,15 @@ sub showmenu