]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blobdiff - html/cgi-bin/routing.cgi
remote.cgi: Fix splitting output from ssh-keygen.
[people/pmueller/ipfire-2.x.git] / html / cgi-bin / routing.cgi
index c460a74e7ca1ab56d4d2dd44f8ecc9d69f9df6c2..e69dc425ab26abbc6d100806c13cfcd262c47f30 100644 (file)
@@ -40,7 +40,7 @@ our $datafile = "${General::swroot}/main/routing";            #(our: used in subroutine)
 my %color = ();
 my %mainsettings = ();
 &General::readhash("${General::swroot}/main/settings", \%mainsettings);
-&General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color);
+&General::readhash("/srv/web/ipfire/html/themes/ipfire/include/colors.txt", \%color);
 
 our %settings = ();
 
@@ -118,12 +118,15 @@ if ($settings{'ACTION'} eq $Lang::tr{'toggle enable disable'}) {
 }
 
 if ($settings{'ACTION'} eq $Lang::tr{'add'}) {
-       # Convert subnet masks to CIDR notation.
-       $settings{'IP'} = &General::iporsubtocidr($settings{'IP'});
-
-# Validate inputs
-       if (( !&General::validip($settings{'IP'})) and ( !&General::validipandmask($settings{'IP'}))){
-       $errormessage = $Lang::tr{'invalid ip'}." / ".$Lang::tr{'invalid netmask'};
+       # Validate inputs
+       if (!&General::validipandmask($settings{'IP'})){
+               $errormessage = $Lang::tr{'invalid ip'}." / ".$Lang::tr{'invalid netmask'};
+       }else{
+               #set networkip if not already correctly defined
+               my($ip,$cidr) = split(/\//,$settings{'IP'});
+               $cidr = &General::iporsubtocidr($cidr);
+               my $netip=&General::getnetworkip($ip,$cidr);
+               $settings{'IP'} = "$netip/$cidr";
        }
 
        if ($settings{'IP'} =~ /^0\.0\.0\.0/){
@@ -134,6 +137,9 @@ if ($settings{'ACTION'} eq $Lang::tr{'add'}) {
        $errormessage = $Lang::tr{'invalid ip'}. " - ".$Lang::tr{'gateway ip'};
        }
 
+       # Escape input in REMARK field
+       $settings{'REMARK'} = &Header::escape($settings{'REMARK'});
+
        #set networkip if not already correctly defined
        my($ip,$cidr) = split(/\//,$settings{'IP'});
        my $netip=&General::getnetworkip($ip,$cidr);
@@ -146,12 +152,12 @@ if ($settings{'ACTION'} eq $Lang::tr{'add'}) {
                $temp[2] ='' unless defined $temp[2]; # not always populated
                $temp[3] ='' unless defined $temp[2]; # not always populated
                #Same ip already used?
-               if($temp[1] eq $settings{'IP'}){
+               if($temp[1] eq $settings{'IP'} && $settings{'KEY1'} eq ''){
                        $errormessage = $Lang::tr{'ccd err irouteexist'};
                        last;
                }
                #Is the network part of an internal network?
-               $errormessage .= &General::check_net_internal($settings{'IP'});
+               $errormessage .= &General::check_net_internal_exact($settings{'IP'});
                last;
        }
 
@@ -468,5 +474,5 @@ sub SortDataFile
 # Build the configuration file
 #
 sub BuildConfiguration {
-    system '/usr/local/bin/rebuildroutes';
+    &General::system('/usr/local/bin/rebuildroutes');
 }