]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blobdiff - html/cgi-bin/forwardfw.cgi
Firewall: added some more plausichecks and additional errormessages
[people/teissler/ipfire-2.x.git] / html / cgi-bin / forwardfw.cgi
index b45afade0eb279c5f4623a4fac3d0c041ec0e9d4..c16fd0ade785a7dcc244faae05f937f20ab7a7f9 100755 (executable)
@@ -115,20 +115,15 @@ print<<END;
 function checkradio(a){
        \$(a).attr('checked', true);
 }
-function toggle_elements()
-{
-       var elementNames = toggle_elements.arguments;
-       for (var i=0; i<elementNames.length; i++)
+function toggle_elements( id ) {
+       if(document.getElementById(id).style.display== "none")
        {
-               var elementName = elementNames[i];
-               if ( \$('input[name="USE_NAT"]').is(':checked') || \$('input[name="USE_SRC_PORT"]').is(':checked') || \$('input[name="USESRV"]').is(':checked'))
-               {
-                       document.getElementById(elementName).style.display='block';
-               }
-               else{
-                       document.getElementById(elementName).style.display='none';
-               }
+               document.getElementById(id).style.display='block';
        }
+       else{
+               document.getElementById(id).style.display='none';
+       }
+       return true;
 }
 function hide_elements()
 {
@@ -275,8 +270,8 @@ if ($fwdfwsettings{'ACTION'} eq 'saverule')
                }
                #increase counters
                if (!$errormessage){
-                       &checkcounter($fwdfwsettings{'oldgrp1a'},$fwdfwsettings{'oldgrp1b'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
-                       &checkcounter($fwdfwsettings{'oldgrp2a'},$fwdfwsettings{'oldgrp2b'},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}});
+                &checkcounter($fwdfwsettings{'oldgrp1a'},$fwdfwsettings{'oldgrp1b'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
+                &checkcounter($fwdfwsettings{'oldgrp2a'},$fwdfwsettings{'oldgrp2b'},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}});
                        if($fwdfwsettings{'oldusesrv'} eq '' &&  $fwdfwsettings{'USESRV'} eq 'ON'){
                                &checkcounter(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
                        }elsif ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'oldusesrv'} eq 'ON') {
@@ -810,7 +805,17 @@ sub checkrule
                        }
                }
        }
-       #check source and destination protocol if source manual and dest single service
+       #When using source- or targetport, the protocol has to be TCP or UDP
+       if (($fwdfwsettings{'USESRV'} eq 'ON' || $fwdfwsettings{'USE_SRC_PORT'} eq 'ON') && ($fwdfwsettings{'SRC_PORT'} ne '' || $fwdfwsettings{'TGT_PORT'} ne '') && ($fwdfwsettings{'PROT'} ne 'TCP' && $fwdfwsettings{'PROT'} ne 'UDP')){
+               $errormessage.=$Lang::tr{'fwdfw err prot_port1'};
+               return;
+       }
+       #when icmp selected, no targetport allowed
+       if (($fwdfwsettings{'PROT'} ne '' && $fwdfwsettings{'PROT'} ne 'TCP' && $fwdfwsettings{'PROT'} ne 'UDP') && ($fwdfwsettings{'USESRV'} eq 'ON' || $fwdfwsettings{'USE_SRC_PORT'} eq 'ON')){
+               $errormessage.=$Lang::tr{'fwdfw err prot_port'};
+               return;
+       }
+       #change protocol if prot not equal dest single service
        if ($fwdfwsettings{'grp3'} eq 'cust_srv'){
                foreach my $key (sort keys %customservice){
                        if($customservice{$key}[0] eq $fwdfwsettings{$fwdfwsettings{'grp3'}}){
@@ -831,7 +836,7 @@ sub checkrule
        if ($fwdfwsettings{'PROT'} eq 'ICMP'){
                $fwdfwsettings{'USE_SRC_PORT'}='';
                $fwdfwsettings{'SRC_PORT'}='';
-               $fwdfwsettings{'USESRV'}='';
+               #$fwdfwsettings{'USESRV'}='';
                $fwdfwsettings{'TGT_PORT'}='';
                &General::readhasharray("${General::swroot}/fwhosts/icmp-types", \%icmptypes);
                foreach my $key (keys %icmptypes){
@@ -1259,7 +1264,7 @@ sub get_serviceports
                }
        }
        if($tcp && $udp && $icmp){
-               push (@protocols,"All");
+               push (@protocols,"TCP,UDP, <br>ICMP");
                return @protocols;
        }
        if($tcp){
@@ -1661,7 +1666,7 @@ END
                <tr><td><select name='PROT'  id='PROT' onchange="getdropdown()">
 END
                if ($fwdfwsettings{'PROT'} eq ''){
-                               print"<option selected>$Lang::tr{'all'}</option>";
+                               print"<option value='' selected>$Lang::tr{'all'}</option>";
                }else{
                        print"<option value=''>$Lang::tr{'all'}</option>";
                }
@@ -2249,7 +2254,7 @@ END
                                push (@protocols,$Lang::tr{'all'});
                        }
                        my $protz=join(",",@protocols);
-                       if($protz eq 'ICMP'){
+                       if($protz eq 'ICMP' && $$hash{$key}[9] ne 'All ICMP-Types'){
                                &General::readhasharray("${General::swroot}/fwhosts/icmp-types", \%icmptypes);
                                foreach my $keyicmp (sort { ncmp($icmptypes{$a}[0],$icmptypes{$b}[0]) }keys %icmptypes){
                                        if($$hash{$key}[9] eq "$icmptypes{$keyicmp}[0]"){