diff --git a/html/cgi-bin/keepalivedvs.cgi b/html/cgi-bin/keepalivedvs.cgi new file mode 100644 index 0000000000..4f13128dfc --- /dev/null +++ b/html/cgi-bin/keepalivedvs.cgi @@ -0,0 +1,894 @@ +#!/usr/bin/perl +############################################################################### +# # +# IPFire.org - A linux based firewall # +# Copyright (C) 2013 Alexander Marx # +# Copyright (C) 2024 BPFire # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +############################################################################### +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'; +require '/var/ipfire/network-functions.pl'; +require "/var/ipfire/location-functions.pl"; +require "/usr/lib/firewall/firewall-lib.pl"; +require "${General::swroot}/lang.pl"; +require "${General::swroot}/header.pl"; + +my %hasettings=(); +my %virtualserver=(); +my %realserver=(); +my %icmptypes=(); +my %color=(); +my %defaultNetworks=(); +my %mainsettings=(); +my %ownnet=(); +my %fwfwd=(); +my %fwinp=(); +my %fwout=(); +my %netsettings=(); +my %optionsfw=(); + +my $errormessage; +my $hint; +my $update=0; +my $configvs = "${General::swroot}/keepalived/configvs"; +my $configrs = "${General::swroot}/keepalived/configrs"; +my $fwoptions = "${General::swroot}/optionsfw/settings"; + +unless (-e $configvs) { &General::system("touch", "$configvs"); } +unless (-e $configrs) { &General::system("touch", "$configrs"); } + +&General::readhash("${General::swroot}/main/settings", \%mainsettings); +&General::readhash("/srv/web/ipfire/html/themes/ipfire/include/colors.txt", \%color); +&General::readhash("${General::swroot}/ethernet/settings", \%ownnet); +&General::readhash("/var/ipfire/ethernet/settings", \%netsettings); +&General::readhash($fwoptions, \%optionsfw); + +&Header::getcgihash(\%hasettings); +&Header::showhttpheaders(); +&Header::openpage($Lang::tr{'fwhost menu'}, 1, ''); +&Header::openbigbox('100%', 'center'); + +#### JAVA SCRIPT #### +print< + var PROTOCOLS_WITH_PORTS = ["TCP", "UDP"]; + var update_protocol = function() { + var protocol = \$("#protocol").val(); + + if (protocol === undefined) + return; + + // Check if we are dealing with a protocol, that knows ports. + if (\$.inArray(protocol, PROTOCOLS_WITH_PORTS) >= 0) { + \$("#PORT").show(); + \$("#PROTOKOLL").hide(); + } else { + \$("#PORT").hide(); + \$("#PROTOKOLL").show(); + } + }; + + \$(document).ready(function() { + var protocol = \$("#protocol").val(); + \$("#protocol").change(update_protocol); + update_protocol(); + // Automatically select radio buttons when corresponding + // dropdown menu changes. + \$("select").change(function() { + var id = \$(this).attr("name"); + \$('#' + id).prop("checked", true); + }); + }); + +END + +## ACTION #### +# Update +if ($hasettings{'ACTION'} eq 'updatevs' ) +{ + &General::readhasharray("$configvs", \%virtualserver); + foreach my $key (keys %virtualserver) + { + if($virtualserver{$key}[0] eq $hasettings{'orgname'}) + { + $hasettings{'orgname'} = $virtualserver{$key}[0]; + $hasettings{'orgip'} = $virtualserver{$key}[1]; + $hasettings{'orgsub'} = $virtualserver{$key}[2]; + $hasettings{'netremark'} = $virtualserver{$key}[3]; + $hasettings{'count'} = $virtualserver{$key}[4]; + delete $virtualserver{$key}; + + } + } + &General::writehasharray("$configvs", \%virtualserver); + $hasettings{'actualize'} = 'on'; + $hasettings{'ACTION'} = 'savevs'; +} +if ($hasettings{'ACTION'} eq 'updaters') +{ + my ($ip,$subnet); + &General::readhasharray("$configrs", \%realserver); + foreach my $key (keys %realserver) + { + if($realserver{$key}[0] eq $hasettings{'orgname'}) + { + if ($realserver{$key}[1] eq 'ip'){ + ($ip,$subnet) = split (/\//,$realserver{$key}[2]); + }else{ + $ip = $realserver{$key}[2]; + } + $hasettings{'orgip'} = $ip; + delete $realserver{$key}; + &General::writehasharray("$configrs", \%realserver); + } + } + $hasettings{'actualize'} = 'on'; + if($hasettings{'orgip'}){ + $hasettings{'ACTION'} = 'savers'; + }else{ + $hasettings{'ACTION'} = $Lang::tr{'fwhost newhost'}; + } +} +# save +if ($hasettings{'ACTION'} eq 'savevs' ) +{ + my $needrules=0; + if ($hasettings{'orgname'} eq ''){$hasettings{'orgname'}=$hasettings{'HOSTNAME'};} + #check if all fields are set + if ($hasettings{'HOSTNAME'} eq '' || $hasettings{'IP'} eq '' || $hasettings{'SUBNET'} eq '') + { + $errormessage=$errormessage.$Lang::tr{'fwhost err empty'}; + &addvs; + &viewtablevs; + }else{ + #convert ip if leading '0' exists + $hasettings{'IP'} = &Network::ip_remove_zero($hasettings{'IP'}); + + #check valid ip + if (!&General::validipandmask($hasettings{'IP'}."/".$hasettings{'SUBNET'})) + { + $errormessage=$errormessage.$Lang::tr{'fwhost err addr'}; + $hasettings{'BLK_HOST'} ='readonly'; + $hasettings{'NOCHECK'} ='false'; + $hasettings{'error'} ='on'; + } + #check remark + if ($hasettings{'NETREMARK'} ne '' && !&validremark($hasettings{'NETREMARK'})){ + $errormessage=$Lang::tr{'fwhost err remark'}; + $hasettings{'error'} ='on'; + } + #check if subnet is sigle host + if(&General::iporsubtocidr($hasettings{'SUBNET'}) eq '32') + { + $errormessage=$errormessage.$Lang::tr{'fwhost err sub32'}; + } + if($hasettings{'error'} ne 'on'){ + my $fullip="$hasettings{'IP'}/".&General::iporsubtocidr($hasettings{'SUBNET'}); + $errormessage=$errormessage.&General::checksubnets($hasettings{'HOSTNAME'},$fullip,"","exact"); + } + #only check plausi when no error till now + if (!$errormessage){ + &plausicheck("editvs"); + } + if($hasettings{'actualize'} eq 'on' && $hasettings{'newnet'} ne 'on' && $errormessage) + { + $hasettings{'actualize'} = ''; + my $key = &General::findhasharraykey (\%virtualserver); + foreach my $i (0 .. 3) { $virtualserver{$key}[$i] = "";} + $virtualserver{$key}[0] = $hasettings{'orgname'} ; + $virtualserver{$key}[1] = $hasettings{'orgip'} ; + $virtualserver{$key}[2] = $hasettings{'orgsub'}; + $virtualserver{$key}[3] = $hasettings{'orgnetremark'}; + &General::writehasharray("$configvs", \%virtualserver); + undef %virtualserver; + } + if (!$errormessage){ + &General::readhasharray("$configvs", \%virtualserver); + if ($hasettings{'ACTION'} eq 'updatevs'){ + if ($hasettings{'update'} == '0'){ + foreach my $key (keys %virtualserver) { + if($virtualserver{$key}[0] eq $hasettings{'orgname'}){ + delete $virtualserver{$key}; + last; + } + } + } + } + #get count if actualize is 'on' + if($hasettings{'actualize'} eq 'on'){ + $hasettings{'actualize'} = ''; + #check if we need to reload rules + if($hasettings{'orgip'} ne $hasettings{'IP'}){ + $needrules='on'; + } + if ($hasettings{'orgname'} ne $hasettings{'HOSTNAME'}){ + } + } + my $key = &General::findhasharraykey (\%virtualserver); + foreach my $i (0 .. 3) { $virtualserver{$key}[$i] = "";} + $hasettings{'SUBNET'} = &General::iporsubtocidr($hasettings{'SUBNET'}); + $virtualserver{$key}[0] = $hasettings{'HOSTNAME'}; + $virtualserver{$key}[1] = &General::getnetworkip($hasettings{'IP'},$hasettings{'SUBNET'}) ; + $virtualserver{$key}[2] = &General::iporsubtodec($hasettings{'SUBNET'}) ; + $virtualserver{$key}[3] = $hasettings{'NETREMARK'}; + &General::writehasharray("$configvs", \%virtualserver); + $hasettings{'IP'}=$hasettings{'IP'}."/".&General::iporsubtodec($hasettings{'SUBNET'}); + undef %virtualserver; + $hasettings{'HOSTNAME'}=''; + $hasettings{'IP'}=''; + $hasettings{'SUBNET'}=''; + $hasettings{'NETREMARK'}=''; + #check if an edited net affected groups and need to reload rules + if ($needrules eq 'on'){ + &General::firewall_config_changed(); + } + &addvs; + &viewtablevs; + }else{ + $hasettings{'HOSTNAME'} = $hasettings{'orgname'}; + &addvs; + &viewtablevs; + } + } +} +if ($hasettings{'ACTION'} eq 'savers') +{ + my $needrules=0; + if ($hasettings{'orgname'} eq ''){$hasettings{'orgname'}=$hasettings{'HOSTNAME'};} + $hasettings{'SUBNET'}='32'; + #check if all fields are set + if ($hasettings{'HOSTNAME'} eq '' || $hasettings{'IP'} eq '' || $hasettings{'SUBNET'} eq '') + { + $errormessage=$errormessage.$Lang::tr{'fwhost err empty'}; + $hasettings{'ACTION'} = 'editrs'; + }else{ + if($hasettings{'IP'}=~/^([0-9a-fA-F]{1,2}:){5}[0-9a-fA-F]{1,2}$/){ + $hasettings{'type'} = 'mac'; + }elsif($hasettings{'IP'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){ + $hasettings{'type'} = 'ip'; + }else{ + $hasettings{'type'} = ''; + $errormessage=$Lang::tr{'fwhost err ipmac'}; + } + #check remark + if ($hasettings{'HOSTREMARK'} ne '' && !&validremark($hasettings{'HOSTREMARK'})){ + $errormessage=$Lang::tr{'fwhost err remark'}; + } + #CHECK IP-PART + if ($hasettings{'type'} eq 'ip'){ + #convert ip if leading '0' exists + $hasettings{'IP'} = &Network::ip_remove_zero($hasettings{'IP'}); + + #check for subnet + if (rindex($hasettings{'IP'},'/') eq '-1' ){ + if($hasettings{'type'} eq 'ip' && !&General::validipandmask($hasettings{'IP'}."/32")) + { + $errormessage.=$errormessage.$Lang::tr{'fwhost err ip'}; + $hasettings{'error'}='on'; + } + }elsif(rindex($hasettings{'IP'},'/') ne '-1' ){ + $errormessage=$errormessage.$Lang::tr{'fwhost err ipwithsub'}; + $hasettings{'error'}='on'; + } + #check if net or broadcast + my @tmp= split (/\./,$hasettings{'IP'}); + if (($tmp[3] eq "0") || ($tmp[3] eq "255")){ + $errormessage=$Lang::tr{'fwhost err hostip'}; + } + } + #only check plausi when no error till now + if (!$errormessage){ + &plausicheck("editrs"); + } + if($hasettings{'actualize'} eq 'on' && $hasettings{'newrs'} ne 'on' && $errormessage){ + $hasettings{'actualize'} = ''; + my $key = &General::findhasharraykey (\%realserver); + foreach my $i (0 .. 3) { $realserver{$key}[$i] = "";} + $realserver{$key}[0] = $hasettings{'orgname'} ; + $realserver{$key}[1] = $hasettings{'type'} ; + if($realserver{$key}[1] eq 'ip'){ + $realserver{$key}[2] = $hasettings{'orgip'}."/".&General::iporsubtodec($hasettings{'SUBNET'}); + }else{ + $realserver{$key}[2] = $hasettings{'orgip'}; + } + $realserver{$key}[3] = $hasettings{'orgremark'}; + &General::writehasharray("$configrs", \%realserver); + undef %realserver; + } + if (!$errormessage){ + #get count if host was edited + if($hasettings{'actualize'} eq 'on'){ + if($hasettings{'orgip'} ne $hasettings{'IP'}){ + $needrules='on'; + } + if($hasettings{'orgname'} ne $hasettings{'HOSTNAME'}){ + #check if we need to update firewallrules + } + } + my $key = &General::findhasharraykey (\%realserver); + foreach my $i (0 .. 3) { $realserver{$key}[$i] = "";} + $realserver{$key}[0] = $hasettings{'HOSTNAME'} ; + $realserver{$key}[1] = $hasettings{'type'} ; + if ($hasettings{'type'} eq 'ip'){ + $realserver{$key}[2] = $hasettings{'IP'}."/".&General::iporsubtodec($hasettings{'SUBNET'}); + }else{ + $realserver{$key}[2] = $hasettings{'IP'}; + } + $realserver{$key}[3] = $hasettings{'HOSTREMARK'}; + &General::writehasharray("$configrs", \%realserver); + undef %realserver; + $hasettings{'HOSTNAME'}=''; + $hasettings{'IP'}=''; + $hasettings{'type'}=''; + $hasettings{'HOSTREMARK'}=''; + #check if we need to update rules while host was edited + if($needrules eq 'on'){ + &General::firewall_config_changed(); + } + &addrs; + &viewtablers; + }else{ + &addrs; + &viewtablers; + } + } +} +# edit +if ($hasettings{'ACTION'} eq 'editvs') +{ + &addvs; + &viewtablevs; +} +if ($hasettings{'ACTION'} eq 'editrs') +{ + &addrs; + &viewtablers; +} +# reset +if ($hasettings{'ACTION'} eq 'resetvs') +{ + $hasettings{'HOSTNAME'} =""; + $hasettings{'IP'} =""; + $hasettings{'SUBNET'} =""; + &showmenu; +} +if ($hasettings{'ACTION'} eq 'resetrs') +{ + $hasettings{'HOSTNAME'} =""; + $hasettings{'IP'} =""; + $hasettings{'type'} =""; + &showmenu; +} +# delete +if ($hasettings{'ACTION'} eq 'delnet') +{ + &General::readhasharray("$configvs", \%virtualserver); + foreach my $key (keys %virtualserver) { + if($hasettings{'key'} eq $virtualserver{$key}[0]){ + delete $virtualserver{$key}; + &General::writehasharray("$configvs", \%virtualserver); + last; + } + } + &addvs; + &viewtablevs; +} +if ($hasettings{'ACTION'} eq 'delhost') +{ + &General::readhasharray("$configrs", \%realserver); + foreach my $key (keys %realserver) { + if($hasettings{'key'} eq $realserver{$key}[0]){ + delete $realserver{$key}; + &General::writehasharray("$configrs", \%realserver); + last; + } + } + &addrs; + &viewtablers; +} +if ($hasettings{'ACTION'} eq $Lang::tr{'fwhost newnet'}) +{ + &addvs; + &viewtablevs; +} +if ($hasettings{'ACTION'} eq $Lang::tr{'fwhost newhost'}) +{ + &addrs; + &viewtablers; +} +### VIEW ### +if($hasettings{'ACTION'} eq '') +{ + &showmenu; +} +### FUNCTIONS ### +sub showmenu { + &Header::openbox('100%', 'left',); + print "$Lang::tr{'fwhost welcome'}"; + print<
+ + +
+END + &Header::closebox(); + +} +# Add +sub addvs { + &error; + &showmenu; + &Header::openbox('100%', 'left', $Lang::tr{'fwhost addnet'}); + $hasettings{'orgname'} = $hasettings{'HOSTNAME'}; + $hasettings{'orgnetremark'} = $hasettings{'NETREMARK'}; + + print < + + $Lang::tr{'name'}: + +
+ + + + + + $Lang::tr{'fwhost netaddress'}: + + + + $Lang::tr{'netmask'}: + + + + $Lang::tr{'remark'}: + + + +
+ + +END + + if ($hasettings{'ACTION'} eq 'editvs' || $hasettings{'error'} eq 'on') { + print < + + + + + + + + +END + } else { + print < + + + + + +END + } + + print < + + + + + + +END + + &Header::closebox(); +} + +sub addrs { + &error; + &showmenu; + &Header::openbox('100%', 'left', $Lang::tr{'fwhost addhost'}); + + $hasettings{'orgname'} = $hasettings{'HOSTNAME'}; + $hasettings{'orgremark'} = $hasettings{'HOSTREMARK'}; + + print < + + $Lang::tr{'name'}: + +
+ + + + + + IP/MAC: + + + + $Lang::tr{'remark'}: + + + +
+ + +END + + if ($hasettings{'ACTION'} eq 'editrs' || $hasettings{'error'} eq 'on') { + print < + + + + + + + +END + } else { + print < + + + + +END + } + + print < + + + + + +END + + &Header::closebox(); +} + +# View + +sub viewtablers { + if (!-z $configrs) { + &Header::openbox('100%', 'left', $Lang::tr{'fwhost cust addr'}); + &General::readhasharray("$configrs", \%realserver); + + if (!keys %realserver) { + print "
$Lang::tr{'fwhost empty'}"; + } else { + print < + + $Lang::tr{'name'} + $Lang::tr{'fwhost ip_mac'} + $Lang::tr{'remark'} + + + +END + } + + my $count = 0; + my $col = ''; + + foreach my $key (sort { ncmp($realserver{$a}[0], $realserver{$b}[0]) } keys %realserver) { + if (($hasettings{'ACTION'} eq 'editrs' || $hasettings{'error'}) && $hasettings{'HOSTNAME'} eq $realserver{$key}[0]) { + print ""; + $col = "bgcolor='${Header::colouryellow}'"; + } elsif ($count % 2) { + print ""; + $col = "bgcolor='$color{'color20'}'"; + } else { + $col = "bgcolor='$color{'color22'}'"; + print ""; + } + + my ($ip, $sub) = split(/\//, $realserver{$key}[2]); + + print "$realserver{$key}[0]"; + print "" . &getcolor($ip) . ""; + print "$realserver{$key}[3]"; + + print < +
+ + + + + + +
+ +END + + print "
"; + print ""; + print ""; + print ""; + print "
"; + + $count++; + } + + print ""; + &Header::closebox(); + } +} + +sub viewtablevs { + if (!-z $configvs) { + &Header::openbox('100%', 'left', $Lang::tr{'fwhost cust net'}); + &General::readhasharray("$configvs", \%virtualserver); + + if (!keys %virtualserver) { + print "
$Lang::tr{'fwhost empty'}"; + } else { + print < + + $Lang::tr{'name'} + $Lang::tr{'fwhost netaddress'} + $Lang::tr{'remark'} + + + +END + } + + my $count = 0; + my $col = ''; + + foreach my $key (sort { ncmp($a, $b) } keys %virtualserver) { + if ($hasettings{'ACTION'} eq 'editvs' && $hasettings{'HOSTNAME'} eq $virtualserver{$key}[0]) { + print " "; + $col = "bgcolor='${Header::colouryellow}'"; + } elsif ($count % 2) { + $col = "bgcolor='$color{'color20'}'"; + print " "; + } else { + $col = "bgcolor='$color{'color22'}'"; + print " "; + } + + my $colnet = "$virtualserver{$key}[1]/" . &General::subtocidr($virtualserver{$key}[2]); + + print "
$virtualserver{$key}[0]"; + print "" . &getcolor($colnet) . ""; + print "$virtualserver{$key}[3]"; + + print < + + + + + + + +END + + print "
"; + print ""; + print ""; + print ""; + print "
"; + + $count++; + } + + print ""; + &Header::closebox(); + } +} + +sub getcolor +{ + my $c=shift; + my $sip; + my $scidr; + my $tdcolor=''; + #Check if MAC + if (&General::validmac($c)){ return $c;} + + #Check if we got a full IP with subnet then split it + if($c =~ /^(.*?)\/(.*?)$/){ + ($sip,$scidr) = split ("/",$c); + }else{ + $sip=$c; + } + + #Now check if IP is part of ORANGE,BLUE or GREEN + if ( &Header::orange_used() && &General::IpInSubnet($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){ + $tdcolor="$c"; + return $tdcolor; + } + if ( &General::IpInSubnet($sip,$netsettings{'GREEN_ADDRESS'},$netsettings{'GREEN_NETMASK'})){ + $tdcolor="$c"; + return $tdcolor; + } + if ( &Header::blue_used() && &General::IpInSubnet($sip,$netsettings{'BLUE_ADDRESS'},$netsettings{'BLUE_NETMASK'})){ + $tdcolor="$c"; + return $tdcolor; + } + if ("$sip/$scidr" eq "0.0.0.0/0"){ + $tdcolor="$c"; + return $tdcolor; + } + + return "$c"; +} + + +sub checkname +{ + my %hash=%{(shift)}; + foreach my $key (keys %hash) { + if($hash{$key}[0] eq $hasettings{'HOSTNAME'}){ + return 0; + } + } + return 1; + +} +sub checkip +{ + + my %hash=%{(shift)}; + my $a=shift; + foreach my $key (keys %hash) { + if($hash{$key}[$a] eq $hasettings{'IP'}."/".&General::iporsubtodec($hasettings{'SUBNET'})){ + return 0; + } + } + return 1; +} +sub error +{ + if ($errormessage) { + &Header::openbox('100%', 'left', $Lang::tr{'error messages'}); + print "$errormessage\n"; + print " \n"; + &Header::closebox(); + } +} +sub hint +{ + if ($hint) { + &Header::openbox('100%', 'left', $Lang::tr{'fwhost hint'}); + print "$hint\n"; + print " \n"; + &Header::closebox(); + } +} +sub get_name +{ + my $val=shift; + &General::setup_default_networks(\%defaultNetworks); + foreach my $network (sort keys %defaultNetworks) + { + return "$network" if ($val eq $defaultNetworks{$network}{'NAME'}); + } +} +sub gethostcount +{ + my $searchstring=shift; +} +sub getnetcount +{ + my $searchstring=shift; +} +sub plausicheck +{ + my $edit=shift; + #check hostname + if (!&validhostname($hasettings{'HOSTNAME'})) + { + $errormessage=$errormessage.$Lang::tr{'fwhost err name'}; + $hasettings{'BLK_IP'}='readonly'; + $hasettings{'HOSTNAME'} = $hasettings{'orgname'}; + if ($hasettings{'update'} eq 'on'){$hasettings{'ACTION'}=$edit;} + } + #check if network with this name already exists + &General::readhasharray("$configvs", \%virtualserver); + if (!&checkname(\%virtualserver)) + { + $errormessage=$errormessage."
".$Lang::tr{'fwhost err netexist'}; + $hasettings{'HOSTNAME'} = $hasettings{'orgname'}; + if ($hasettings{'update'} eq 'on'){$hasettings{'ACTION'}=$edit;} + } + #check if network ip already exists + if (!&checkip(\%virtualserver,1)) + { + $errormessage=$errormessage."
".$Lang::tr{'fwhost err net'}; + if ($hasettings{'update'} eq 'on'){$hasettings{'ACTION'}=$edit;} + } + #check if host with this name already exists + &General::readhasharray("$configrs", \%realserver); + if (!&checkname(\%realserver)) + { + $errormessage.="
".$Lang::tr{'fwhost err hostexist'}; + $hasettings{'HOSTNAME'} = $hasettings{'orgname'}; + if ($hasettings{'update'} eq 'on'){$hasettings{'ACTION'}=$edit;} + } + #check if host with this ip already exists + if (!&checkip(\%realserver,2)) + { + $errormessage=$errormessage."
".$Lang::tr{'fwhost err ipcheck'}; + } + return; +} +sub decrease +{ + &General::readhasharray("$configvs", \%virtualserver); + &General::readhasharray("$configrs", \%realserver); + &General::writehasharray("$configvs", \%virtualserver); + &General::writehasharray("$configrs", \%realserver); +} +sub validhostname +{ + # Checks a hostname against RFC1035 + my $hostname = $_[0]; + + # Each part should be at least two characters in length + # but no more than 63 characters + 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]*$/) { + return 0;} + # First character can only be a letter or a digit + if (substr ($hostname, 0, 1) !~ /^[a-zA-ZöäüÖÄÜ0-9]*$/) { + return 0;} + # Last character can only be a letter or a digit + if (substr ($hostname, -1, 1) !~ /^[a-zA-ZöäüÖÄÜ0-9()]*$/) { + return 0;} + return 1; +} +sub validremark +{ + # Checks a hostname against RFC1035 + my $remark = $_[0]; + # Each part should be at least two characters in length + # but no more than 63 characters + 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]*$/) { + 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.:;_)]*$/) { + return 0;} + return 1; +} +&Header::closebigbox(); +&Header::closepage(); diff --git a/lfs/configroot b/lfs/configroot index afda8910d4..b939c5df2d 100644 --- a/lfs/configroot +++ b/lfs/configroot @@ -68,7 +68,7 @@ $(TARGET) : fwhosts/customnetworks fwhosts/customhosts fwhosts/customgroups fwhosts/customservicegrp fwhosts/customlocationgrp fwlogs/ipsettings fwlogs/portsettings ipblocklist/modified \ ipblocklist/settings mac/settings main/hosts main/routing main/security main/settings optionsfw/settings \ ovpn/ccd.conf ovpn/ccdroute ovpn/ccdroute2 pakfire/settings portfw/config ppp/settings-1 ppp/settings-2 ppp/settings-3 ppp/settings-4 \ - ppp/settings-5 ppp/settings proxy/settings proxy/squid.conf proxy/advanced/settings proxy/advanced/cre/enable remote/settings ddos/settings ddos/tcp_ports ddos/udp-ddos-settings ddos/udp_ports ddos/dns-ddos-settings loxilb/settings keepalived/keepalived.conf keepalived/runsettings keepalived/settings qos/settings qos/classes qos/subclasses qos/level7config qos/portconfig \ + ppp/settings-5 ppp/settings proxy/settings proxy/squid.conf proxy/advanced/settings proxy/advanced/cre/enable remote/settings ddos/settings ddos/tcp_ports ddos/udp-ddos-settings ddos/udp_ports ddos/dns-ddos-settings loxilb/settings keepalived/keepalived.conf keepalived/runsettings keepalived/settings keepalived/configvs keepalived/configrs qos/settings qos/classes qos/subclasses qos/level7config qos/portconfig \ qos/tosconfig suricata/settings vpn/config vpn/settings vpn/ipsec.conf \ vpn/ipsec.secrets vpn/caconfig wakeonlan/clients.conf wireless/config wireless/settings; do \ touch $(CONFIG_ROOT)/$$i; \