X-Git-Url: http://git.ipfire.org/?p=people%2Fteissler%2Fipfire-2.x.git;a=blobdiff_plain;f=html%2Fcgi-bin%2Ffwhosts.cgi;h=444b3660eb73841497ddd7bc73c965a60c57f4d2;hp=d39fe124b6aa68bf0b317dd810a71608524f6a6d;hb=fb0ce57589a8ba724d3c446b612181f6d7f3b8c5;hpb=3f8fe51ef093987c5633a9564648b1d3fe2e5087
diff --git a/html/cgi-bin/fwhosts.cgi b/html/cgi-bin/fwhosts.cgi
index d39fe124b..444b3660e 100755
--- a/html/cgi-bin/fwhosts.cgi
+++ b/html/cgi-bin/fwhosts.cgi
@@ -26,6 +26,7 @@ use strict;
# enable only the following on debugging purpose
use warnings;
+use Sort::Naturally;
use CGI::Carp 'fatalsToBrowser';
no warnings 'uninitialized';
require '/var/ipfire/general-functions.pl';
@@ -96,7 +97,8 @@ if ($fwhostsettings{'ACTION'} eq 'updatenet' )
$fwhostsettings{'orgname'} = $customnetwork{$key}[0];
$fwhostsettings{'orgip'} = $customnetwork{$key}[1];
$fwhostsettings{'orgsub'} = $customnetwork{$key}[2];
- $fwhostsettings{'count'} = $customnetwork{$key}[3];
+ $fwhostsettings{'netremark'} = $customnetwork{$key}[3];
+ $fwhostsettings{'count'} = $customnetwork{$key}[4];
delete $customnetwork{$key};
}
@@ -119,7 +121,7 @@ if ($fwhostsettings{'ACTION'} eq 'updatehost')
$ip = $customhost{$key}[2];
}
$fwhostsettings{'orgip'} = $ip;
- $fwhostsettings{'count'} = $customhost{$key}[3];
+ $fwhostsettings{'count'} = $customhost{$key}[4];
delete $customhost{$key};
&General::writehasharray("$confighost", \%customhost);
}
@@ -230,6 +232,11 @@ if ($fwhostsettings{'ACTION'} eq 'savenet' )
$fwhostsettings{'NOCHECK'} ='false';
$fwhostsettings{'error'} ='on';
}
+ #check remark
+ if ($fwhostsettings{'NETREMARK'} ne '' && !&validremark($fwhostsettings{'NETREMARK'})){
+ $errormessage=$Lang::tr{'fwhost err remark'};
+ $fwhostsettings{'error'} ='on';
+ }
#check if subnet is sigle host
if(&General::iporsubtocidr($fwhostsettings{'SUBNET'}) eq '32')
{
@@ -280,17 +287,19 @@ if ($fwhostsettings{'ACTION'} eq 'savenet' )
$customnetwork{$key}[0] = $fwhostsettings{'orgname'} ;
$customnetwork{$key}[1] = $fwhostsettings{'orgip'} ;
$customnetwork{$key}[2] = $fwhostsettings{'orgsub'};
- $customnetwork{$key}[3] = $fwhostsettings{'count'};
+ $customnetwork{$key}[3] = $fwhostsettings{'orgnetremark'};
+ $customnetwork{$key}[4] = $fwhostsettings{'count'};
&General::writehasharray("$confignet", \%customnetwork);
undef %customnetwork;
}
if (!$errormessage){
+
&General::readhasharray("$confignet", \%customnetwork);
if ($fwhostsettings{'ACTION'} eq 'updatenet'){
if ($fwhostsettings{'update'} == '0'){
foreach my $key (keys %customnetwork) {
if($customnetwork{$key}[0] eq $fwhostsettings{'orgname'}){
- $count=$customnetwork{$key}[3];
+ $count=$customnetwork{$key}[4];
delete $customnetwork{$key};
last;
}
@@ -340,22 +349,24 @@ if ($fwhostsettings{'ACTION'} eq 'savenet' )
}
}
my $key = &General::findhasharraykey (\%customnetwork);
- foreach my $i (0 .. 3) { $customnetwork{$key}[$i] = "";}
+ foreach my $i (0 .. 4) { $customnetwork{$key}[$i] = "";}
$fwhostsettings{'SUBNET'} = &General::iporsubtocidr($fwhostsettings{'SUBNET'});
$customnetwork{$key}[0] = $fwhostsettings{'HOSTNAME'};
#convert ip when leading '0' in byte
- $fwhostsettings{'IP'}=&General::ip2dec($fwhostsettings{'IP'});
- $fwhostsettings{'IP'}=&General::dec2ip($fwhostsettings{'IP'});
+ $fwhostsettings{'IP'} =&General::ip2dec($fwhostsettings{'IP'});
+ $fwhostsettings{'IP'} =&General::dec2ip($fwhostsettings{'IP'});
$customnetwork{$key}[1] = &General::getnetworkip($fwhostsettings{'IP'},$fwhostsettings{'SUBNET'}) ;
$customnetwork{$key}[2] = &General::iporsubtodec($fwhostsettings{'SUBNET'}) ;
if($fwhostsettings{'newnet'} eq 'on'){$count=0;}
- $customnetwork{$key}[3] = $count;
+ $customnetwork{$key}[3] = $fwhostsettings{'NETREMARK'};
+ $customnetwork{$key}[4] = $count;
&General::writehasharray("$confignet", \%customnetwork);
$fwhostsettings{'IP'}=$fwhostsettings{'IP'}."/".&General::iporsubtodec($fwhostsettings{'SUBNET'});
undef %customnetwork;
$fwhostsettings{'HOSTNAME'}='';
$fwhostsettings{'IP'}='';
$fwhostsettings{'SUBNET'}='';
+ $fwhostsettings{'NETREMARK'}='';
#check if an edited net affected groups and need to reload rules
if ($needrules eq 'on'){
&rules;
@@ -381,24 +392,17 @@ if ($fwhostsettings{'ACTION'} eq 'savehost')
$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}$/){
+ if($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})$/){
- $fwhostsettings{'type'} = 'ip';
- }elsif($fwhostsettings{'type'} eq 'mac' && $fwhostsettings{'IP'}=~/^([0-9a-fA-F]{1,2}:){5}[0-9a-fA-F]{1,2}$/){
- $fwhostsettings{'type'} = 'mac';
- }elsif($fwhostsettings{'type'} eq 'ip' && $fwhostsettings{'IP'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
+ }elsif($fwhostsettings{'IP'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
$fwhostsettings{'type'} = 'ip';
}else{
$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'){
@@ -426,7 +430,7 @@ if ($fwhostsettings{'ACTION'} eq 'savehost')
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'){
@@ -434,7 +438,8 @@ if ($fwhostsettings{'ACTION'} eq 'savehost')
}else{
$customhost{$key}[2] = $fwhostsettings{'orgip'};
}
- $customhost{$key}[3] = $fwhostsettings{'count'};
+ $customhost{$key}[3] = $fwhostsettings{'orgremark'};
+ $customhost{$key}[4] = $fwhostsettings{'count'};
&General::writehasharray("$confighost", \%customhost);
undef %customhost;
}
@@ -451,7 +456,6 @@ if ($fwhostsettings{'ACTION'} eq 'savehost')
foreach my $key (sort keys %customgrp){
if($customgrp{$key}[2] eq $fwhostsettings{'orgname'}){
$customgrp{$key}[2]=$fwhostsettings{'HOSTNAME'};
- last;
}
}
&General::writehasharray("$configgrp", \%customgrp);
@@ -480,7 +484,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'){
@@ -492,12 +496,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);
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;
@@ -527,10 +533,6 @@ if ($fwhostsettings{'ACTION'} eq 'savegrp')
#check remark
if ($rem ne '' && !&validremark($rem) && $fwhostsettings{'update'} ne 'on'){
$errormessage.=$Lang::tr{'fwhost err remark'};
- $fwhostsettings{'update'} = 'on';
- $fwhostsettings{'remark'}=$fwhostsettings{'oldremark'};
- &addgrp;
- &viewtablegrp;
}
if ($fwhostsettings{'update'} eq 'on'){
#check standard networks
@@ -659,7 +661,7 @@ if ($fwhostsettings{'ACTION'} eq 'savegrp')
if($updcounter eq 'net'){
foreach my $key (keys %customnetwork) {
if($customnetwork{$key}[0] eq $fwhostsettings{'CUST_SRC_NET'}){
- $customnetwork{$key}[3] = $customnetwork{$key}[3]+1;
+ $customnetwork{$key}[4] = $customnetwork{$key}[4]+1;
last;
}
}
@@ -667,7 +669,7 @@ 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}[4]+1;
}
}
&General::writehasharray("$confighost", \%customhost);
@@ -721,6 +723,10 @@ if ($fwhostsettings{'ACTION'} eq 'saveservicegrp')
&General::readhasharray("$configsrvgrp", \%customservicegrp );
&General::readhasharray("$configsrv", \%customservice );
$errormessage=&checkservicegroup;
+ #check remark
+ if ($fwhostsettings{'SRVGRP_REMARK'} ne '' && !&validremark($fwhostsettings{'SRVGRP_REMARK'})){
+ $errormessage=$Lang::tr{'fwhost err remark'};
+ }
if (!$errormessage){
#on first save, we have to enter a dummy value
if ($fwhostsettings{'CUST_SRV'} eq ''){
@@ -862,7 +868,7 @@ if ($fwhostsettings{'ACTION'} eq 'deletegrphost')
&General::readhasharray("$confignet", \%customnetwork);
foreach my $key1 (keys %customnetwork){
if ($customnetwork{$key1}[0] eq $customgrp{$key}[2]){
- $customnetwork{$key1}[3] = $customnetwork{$key1}[3]-1;
+ $customnetwork{$key1}[4] = $customnetwork{$key1}[4]-1;
last;
}
}
@@ -872,7 +878,7 @@ 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;
}
}
@@ -884,7 +890,7 @@ if ($fwhostsettings{'ACTION'} eq 'deletegrphost')
}
}
&General::writehasharray("$configgrp", \%customgrp);
- &rules;
+ if ($fwhostsettings{'grpcnt'} > 0){&rules;}
if ($fwhostsettings{'update'} eq 'on'){
$fwhostsettings{'remark'}= $grpremark;
$fwhostsettings{'grp_name'}=$grpname;
@@ -965,7 +971,6 @@ if ($fwhostsettings{'ACTION'} eq 'delgrpservice')
&General::writehasharray("$configsrvgrp", \%customservicegrp);
&rules;
if ($fwhostsettings{'updatesrvgrp'} eq 'on'){
- #$fwhostsettings{'updatesrvgrp'}='on';
$fwhostsettings{'SRVGRP_NAME'}=$grpname;
$fwhostsettings{'SRVGRP_REMARK'}=$grpremark;
}
@@ -1000,20 +1005,17 @@ if ($fwhostsettings{'ACTION'} eq $Lang::tr{'fwhost newservicegrp'})
if ($fwhostsettings{'ACTION'} eq 'changegrpremark')
{
&General::readhasharray("$configgrp", \%customgrp);
- if ($fwhostsettings{'oldrem'} ne $fwhostsettings{'newrem'} && &validremark($fwhostsettings{'newrem'})){
+ 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'};
@@ -1028,20 +1030,17 @@ if ($fwhostsettings{'ACTION'} eq 'changegrpremark')
if ($fwhostsettings{'ACTION'} eq 'changesrvgrpremark')
{
&General::readhasharray("$configsrvgrp", \%customservicegrp );
- if ($fwhostsettings{'oldsrvrem'} ne $fwhostsettings{'newsrvrem'} && &validremark($fwhostsettings{'newsrvrem'})){
+ 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'};
@@ -1061,21 +1060,16 @@ if($fwhostsettings{'ACTION'} eq '')
### FUNCTIONS ###
sub showmenu
{
-
+ if (-f "${General::swroot}/forward/reread"){
+ print "
";
+ }
&Header::openbox('100%', 'left',$Lang::tr{'fwhost menu'});
print<
END
-
-
- if (-f "${General::swroot}/fwhosts/reread"){
- print " $Lang::tr{'fwhost reread'} ";
- }
- print" ";
-
&Header::closebox();
}
@@ -1086,14 +1080,18 @@ sub addnet
&showmenu;
&Header::openbox('100%', 'left', $Lang::tr{'fwhost addnet'});
$fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};
+ $fwhostsettings{'orgnetremark'}=$fwhostsettings{'NETREMARK'};
print<";
&Header::closebox();
@@ -1135,7 +1131,14 @@ sub addgrp
&showmenu;
&Header::openbox('100%', 'left', $Lang::tr{'fwhost addgrp'});
&General::setup_default_networks(\%defaultNetworks);
+ &General::readhasharray("$configccdnet", \%ccdnet);
+ &General::readhasharray("$confignet", \%customnetwork);
+ &General::readhasharray("$configccdhost", \%ccdhost);
+ &General::readhasharray("$confighost", \%customhost);
+ &General::readhasharray("$configipsec", \%ipsecconf);
+
my %checked=();
+ my $show='';
$checked{'check1'}{'off'} = '';
$checked{'check1'}{'on'} = '';
$checked{'grp2'}{$fwhostsettings{'grp2'}} = 'CHECKED';
@@ -1145,19 +1148,25 @@ sub addgrp
if ($fwhostsettings{'update'} eq ''){
print<
- $Lang::tr{'fwhost addgrpname'} $Lang::tr{'remark'}:
-
+ $Lang::tr{'fwhost addgrpname'}
+ $Lang::tr{'remark'}:
+
END
}else{
print<
- $Lang::tr{'fwhost addgrpname'} $Lang::tr{'remark'}:
+ $Lang::tr{'fwhost addgrpname'}
+ $Lang::tr{'remark'}:
END
}
if ($fwhostsettings{'update'} eq 'on'){
print< ";
print"$Lang::tr{'fwhost attention'}: $Lang::tr{'fwhost macwarn'} ";
}
- print"";
+ print"";
&Header::closebox();
}
sub addservice
@@ -1253,7 +1252,8 @@ sub addservice
}
print<
- $Lang::tr{'fwhost srv_name'}: $Lang::tr{'fwhost prot'}:
+ $Lang::tr{'fwhost srv_name'}:
+ $Lang::tr{'fwhost prot'}:
END
foreach ("TCP","UDP","ICMP")
{
@@ -1265,18 +1265,19 @@ END
}
}
print< $Lang::tr{'fwhost port'}:
- $Lang::tr{'fwhost icmptype'}
+
+ $Lang::tr{'fwhost icmptype'}
END
&General::readhasharray("${General::swroot}/fwhosts/icmp-types", \%icmptypes);
print"All ICMP-Types ";
- foreach my $key (sort { uc($icmptypes{$a}[0]) cmp uc($icmptypes{$b}[0]) }keys %icmptypes){
+ foreach my $key (sort { ncmp($icmptypes{$a}[0],$icmptypes{$b}[0]) }keys %icmptypes){
print"$icmptypes{$key}[0] ($icmptypes{$key}[1]) ";
}
print<
-
+
+ $Lang::tr{'fwhost port'}:
+
END
if ($fwhostsettings{'updatesrv'} eq 'on')
@@ -1311,15 +1312,17 @@ sub addservicegrp
if ($fwhostsettings{'updatesrvgrp'} eq ''){
print<
- $Lang::tr{'fwhost addgrpname'} $Lang::tr{'remark'}:
-
+ $Lang::tr{'fwhost addgrpname'}
+ $Lang::tr{'remark'}:
+
END
}else{
print<
- $Lang::tr{'fwhost addgrpname'} $Lang::tr{'remark'}:
-
+ $Lang::tr{'fwhost addgrpname'}
+ $Lang::tr{'remark'}:
+
END
}
@@ -1329,13 +1332,13 @@ END
$Lang::tr{'fwhost cust service'}
END
&General::readhasharray("$configsrv", \%customservice);
- foreach my $key (sort { uc($customservice{$a}[0]) cmp uc($customservice{$b}[0])|| $a <=> $b } keys %customservice)
+ foreach my $key (sort { ncmp($customservice{$a}[0],$customservice{$b}[0]) } keys %customservice)
{
print "$customservice{$key}[0] ";
}
print<
-
+
END
@@ -1358,12 +1361,12 @@ sub viewtablenet
print "$Lang::tr{'fwhost empty'} ";
}else{
print<
- $Lang::tr{'name'} $Lang::tr{'fwhost netaddress'} $Lang::tr{'netmask'} $Lang::tr{'used'}
+
+ $Lang::tr{'name'} $Lang::tr{'fwhost netaddress'} $Lang::tr{'netmask'} $Lang::tr{'remark'} $Lang::tr{'used'}
END
}
my $count=0;
- foreach my $key (sort {$a <=> $b} keys %customnetwork) {
+ foreach my $key (sort {ncmp($a,$b)} keys %customnetwork) {
if ($fwhostsettings{'ACTION'} eq 'editnet' && $fwhostsettings{'HOSTNAME'} eq $customnetwork{$key}[0]) {
print" ";
}elsif ($count % 2)
@@ -1374,15 +1377,16 @@ END
print" ";
}
print<$customnetwork{$key}[0]$customnetwork{$key}[1] $customnetwork{$key}[2] $customnetwork{$key}[3]x
+ $customnetwork{$key}[0] $customnetwork{$key}[1] $customnetwork{$key}[2] $customnetwork{$key}[3] $customnetwork{$key}[4]x
+
END
- if($customnetwork{$key}[3] == '0')
+ if($customnetwork{$key}[4] == '0')
{
print" ";
}else{
@@ -1405,28 +1409,29 @@ sub viewtablehost
print "$Lang::tr{'fwhost empty'} ";
}else{
print<
- $Lang::tr{'name'} $Lang::tr{'fwhost ip_mac'} $Lang::tr{'used'}
+
+ $Lang::tr{'name'} $Lang::tr{'fwhost ip_mac'} $Lang::tr{'remark'} $Lang::tr{'used'}
END
}
my $count=0;
- foreach my $key (sort { uc($customhost{$a}[0]) cmp uc($customhost{$b}[0])|| $a <=> $b } keys %customhost) {
+ foreach my $key (sort { ncmp ($customhost{$a}[0],$customhost{$b}[0])} keys %customhost) {
if ( ($fwhostsettings{'ACTION'} eq 'edithost' || $fwhostsettings{'error'}) && $fwhostsettings{'HOSTNAME'} eq $customhost{$key}[0]) {
print" ";
}elsif ($count % 2){ print" ";}
else{ print" ";}
my ($ip,$sub)=split(/\//,$customhost{$key}[2]);
- $customhost{$key}[3]=~s/\s+//g;
+ $customhost{$key}[4]=~s/\s+//g;
print<$customhost{$key}[0]$ip $customhost{$key}[3]x
+ $customhost{$key}[0] $ip $customhost{$key}[3] $customhost{$key}[4]x
+
END
- if($customhost{$key}[3] == '0')
+ if($customhost{$key}[4] == '0')
{
print" ";
}else{
@@ -1459,16 +1464,16 @@ sub viewtablegrp
{
print "$Lang::tr{'fwhost empty'} ";
}else{
- foreach my $key (sort { uc($customgrp{$a}[0]) cmp uc($customgrp{$b}[0]) } sort { uc($customgrp{$a}[2]) cmp uc($customgrp{$b}[2]) } keys %customgrp){
+ foreach my $key (sort { ncmp($customgrp{$a}[0],$customgrp{$b}[0]) } sort { ncmp ($customgrp{$a}[2],$customgrp{$b}[2]) } keys %customgrp){
$count++;
if ($helper ne $customgrp{$key}[0]){
$delflag='0';
- foreach my $key1 (sort { uc($customgrp{$a}[0]) cmp uc($customgrp{$b}[0]) } sort { uc($customgrp{$a}[2]) cmp uc($customgrp{$b}[2]) } keys %customgrp){
+ foreach my $key1 (sort { ncmp($customgrp{$a}[0],$customgrp{$b}[0]) } sort { ncmp($customgrp{$a}[2],$customgrp{$b}[2]) } keys %customgrp){
if ($customgrp{$key}[0] eq $customgrp{$key1}[0])
{
$delflag++;
}
- if($delflag > 0){
+ if($delflag > 1){
last;
}
}
@@ -1485,7 +1490,7 @@ sub viewtablegrp
print" ";
}
print" ";
- print"Name $Lang::tr{'ip address'} $Lang::tr{'fwhost type'} ";
+ print"Name $Lang::tr{'ip address'} $Lang::tr{'fwhost type'} ";
}
if ( ($fwhostsettings{'ACTION'} eq 'editgrp' || $fwhostsettings{'update'} ne '') && $fwhostsettings{'grp_name'} eq $customgrp{$key}[0]) {
@@ -1497,21 +1502,21 @@ sub viewtablegrp
}
my $ip=&getipforgroup($customgrp{$key}[2],$customgrp{$key}[3]);
if ($ip eq ''){print"";}
- print "";
+ print " ";
if($customgrp{$key}[3] eq 'Standard Network'){
print &get_name($customgrp{$key}[2])." ";
}else{
print "$customgrp{$key}[2]";
}
if ($ip eq '' && $customgrp{$key}[2] ne $Lang::tr{'fwhost empty'}){
- print "$Lang::tr{'fwhost deleted'} $customgrp{$key}[3] ";
+ print "$Lang::tr{'fwhost deleted'} $customgrp{$key}[3] ";
}else{
- print"$ip $customgrp{$key}[3] ";
+ print"$ip $customgrp{$key}[3] ";
}
if ($delflag > '1' && $ip ne ''){
print" ";
}
- print" ";
+ print" ";
$helper=$customgrp{$key}[0];
$number++;
@@ -1531,10 +1536,10 @@ sub viewtableservice
&Header::openbox('100%', 'left', $Lang::tr{'fwhost services'});
&General::readhasharray("$configsrv", \%customservice);
print<
+
$Lang::tr{'fwhost srv_name'} $Lang::tr{'fwhost prot'} $Lang::tr{'fwhost port'} ICMP $Lang::tr{'fwhost used'}
END
- foreach my $key (sort { uc($customservice{$a}[0]) cmp uc($customservice{$b}[0])|| $a <=> $b } keys %customservice)
+ foreach my $key (sort { ncmp($customservice{$a}[0],$customservice{$b}[0])} keys %customservice)
{
$count++;
if ( ($fwhostsettings{'updatesrv'} eq 'on' || $fwhostsettings{'error'}) && $fwhostsettings{'SRV_NAME'} eq $customservice{$key}[0]) {
@@ -1571,16 +1576,17 @@ sub viewtableservicegrp
my $helper;
my $port;
my $protocol;
+ my $delflag;
if (! -z $configsrvgrp){
&Header::openbox('100%', 'left', $Lang::tr{'fwhost cust srvgrp'});
&General::readhasharray("$configsrvgrp", \%customservicegrp);
&General::readhasharray("$configsrv", \%customservice);
my $number= keys %customservicegrp;
- foreach my $key (sort { uc($customservicegrp{$a}[0]) cmp uc($customservicegrp{$b}[0])|| $a <=> $b } keys %customservicegrp){
+ foreach my $key (sort { ncmp($customservicegrp{$a}[0],$customservicegrp{$b}[0]) } keys %customservicegrp){
$count++;
if ($helper ne $customservicegrp{$key}[0]){
$delflag=0;
- foreach my $key1 (sort { uc($customservicegrp{$a}[0]) cmp uc($customservicegrp{$b}[0]) } sort { uc($customservicegrp{$a}[2]) cmp uc($customservicegrp{$b}[2]) } keys %customservicegrp){
+ foreach my $key1 (sort { ncmp($customservicegrp{$a}[0],$customservicegrp{$b}[0]) } sort { ncmp($customservicegrp{$a}[2],$customservicegrp{$b}[2]) } keys %customservicegrp){
if ($customservicegrp{$key}[0] eq $customservicegrp{$key1}[0])
{
$delflag++;
@@ -1592,6 +1598,8 @@ sub viewtableservicegrp
$grpname=$customservicegrp{$key}[0];
if ($customservicegrp{$key}[2] eq "none"){
$customservicegrp{$key}[2]=$Lang::tr{'fwhost empty'};
+ $port='';
+ $protocol='';
}
$remark="$customservicegrp{$key}[1]";
if($count >=2){print"
";}
@@ -1603,7 +1611,7 @@ sub viewtableservicegrp
print" ";
}
print" ";
- print"Name $Lang::tr{'port'} $Lang::tr{'fwhost prot'} ";
+ print"Name $Lang::tr{'port'} $Lang::tr{'fwhost prot'} ";
}
if( $fwhostsettings{'SRVGRP_NAME'} eq $customservicegrp{$key}[0]) {
print" ";
@@ -1747,10 +1755,9 @@ sub deletefromgrp
}
sub plausicheck
{
-
my $edit=shift;
#check hostname
- if (!&General::validhostname($fwhostsettings{'HOSTNAME'}))
+ if (!&validhostname($fwhostsettings{'HOSTNAME'}))
{
$errormessage=$errormessage.$Lang::tr{'fwhost err name'};
$fwhostsettings{'BLK_IP'}='readonly';
@@ -1758,7 +1765,6 @@ sub plausicheck
if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
}
#check if name collides with CCD Netname
-
&General::readhasharray("$configccdnet", \%ccdnet);
foreach my $key (keys %ccdnet) {
if($ccdnet{$key}[0] eq $fwhostsettings{'HOSTNAME'}){
@@ -1768,7 +1774,6 @@ sub plausicheck
last;
}
}
-
#check if IP collides with CCD NetIP
if ($fwhostsettings{'type'} ne 'mac'){
&General::readhasharray("$configccdnet", \%ccdnet);
@@ -1783,9 +1788,6 @@ sub plausicheck
}
}
}
-
-
-
#check if name collides with CCD Hostname
&General::readhasharray("$configccdhost", \%ccdhost);
foreach my $key (keys %ccdhost) {
@@ -1835,8 +1837,6 @@ sub plausicheck
{
$errormessage=$errormessage." ".$Lang::tr{'fwhost err ipcheck'};
}
-
-
return;
}
sub getipforgroup
@@ -1954,6 +1954,7 @@ sub rules
{
if (!-f "${General::swroot}/fwhosts/reread"){
system("touch ${General::swroot}/fwhosts/reread");
+ system("touch ${General::swroot}/forward/reread");
}
}
sub reread_rules
@@ -1961,6 +1962,7 @@ sub reread_rules
system ("/usr/local/bin/forwardfwctrl");
if ( -f "${General::swroot}/fwhosts/reread"){
system("rm ${General::swroot}/fwhosts/reread");
+ system("rm ${General::swroot}/forward/reread");
}
}
@@ -1973,7 +1975,7 @@ sub decrease
if ( ($customgrp{$key}[0] eq $grp) && ($customgrp{$key}[3] eq 'Custom Network')){
foreach my $key1 (sort keys %customnetwork){
if ($customnetwork{$key1}[0] eq $customgrp{$key}[2]){
- $customnetwork{$key1}[3]=$customnetwork{$key1}[3]-1;
+ $customnetwork{$key1}[4]=$customnetwork{$key1}[4]-1;
last;
}
}
@@ -1982,7 +1984,7 @@ sub decrease
if (($customgrp{$key}[0] eq $grp) && ($customgrp{$key}[3] eq 'Custom Host')){
foreach my $key2 (sort keys %customhost){
if ($customhost{$key2}[0] eq $customgrp{$key}[2]){
- $customhost{$key2}[3]=$customhost{$key2}[3]-1;
+ $customhost{$key2}[4]=$customhost{$key2}[4]-1;
last;
}
}
@@ -2059,7 +2061,7 @@ sub validhostname
if (length ($hostname) < 1 || length ($hostname) > 63) {
return 0;}
# Only valid characters are a-z, A-Z, 0-9 and -
- if ($hostname !~ /^[a-zA-ZäöüÃÃÃ0-9-_()\/\s]*$/) {
+ if ($hostname !~ /^[a-zA-ZäöüÃÃÃ0-9-_.;()\/\s]*$/) {
return 0;}
# First character can only be a letter or a digit
if (substr ($hostname, 0, 1) !~ /^[a-zA-ZöäüÃÃÃ0-9]*$/) {
@@ -2078,13 +2080,13 @@ sub validremark
if (length ($remark) < 1 || length ($remark) > 255) {
return 0;}
# Only valid characters are a-z, A-Z, 0-9 and -
- if ($remark !~ /^[a-zäöüA-ZÃÃÃ0-9-.:;_\/\s]*$/) {
+ if ($remark !~ /^[a-zäöüA-ZÃÃÃ0-9-.:;\|_()\/\s]*$/) {
return 0;}
# First character can only be a letter or a digit
if (substr ($remark, 0, 1) !~ /^[a-zäöüA-ZÃÃÃ0-9]*$/) {
return 0;}
# Last character can only be a letter or a digit
- if (substr ($remark, -1, 1) !~ /^[a-zöäüA-ZÃÃÃ0-9.]*$/) {
+ if (substr ($remark, -1, 1) !~ /^[a-zöäüA-ZÃÃÃ0-9.:;_)]*$/) {
return 0;}
return 1;
}