]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/commitdiff
firewall: Fix using aliases.
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 5 Apr 2014 15:09:56 +0000 (17:09 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 5 Apr 2014 15:09:56 +0000 (17:09 +0200)
Fix coding errors, actually read aliases configuration
and fall back to default RED IP address if no suitable
alias was found.

config/firewall/firewall-lib.pl
config/firewall/rules.pl

index ae2a462284fd0484be4f88d3fce4585b72b99fb3..9f546a9ef25be3122b3d919ccee8170534891e9c 100755 (executable)
@@ -64,6 +64,7 @@ my $netsettings               = "${General::swroot}/ethernet/settings";
 &General::readhasharray("$configipsec", \%ipsecconf);
 &General::readhasharray("$configsrv", \%customservice);
 &General::readhasharray("$configsrvgrp", \%customservicegrp);
 &General::readhasharray("$configipsec", \%ipsecconf);
 &General::readhasharray("$configsrv", \%customservice);
 &General::readhasharray("$configsrvgrp", \%customservicegrp);
+&General::get_aliases(\%aliases);
 
 sub get_srv_prot
 {
 
 sub get_srv_prot
 {
@@ -388,9 +389,9 @@ sub get_address
 
                # Aliases
                } else {
 
                # Aliases
                } else {
-                       my %alias = &get_alias($value);
-                       if (%alias) {
-                               push(@ret, $alias{"IPT"});
+                       my $alias = &get_alias($value);
+                       if ($alias) {
+                               push(@ret, $alias);
                        }
                }
 
                        }
                }
 
@@ -423,12 +424,12 @@ sub get_alias
 
        foreach my $alias (sort keys %aliases) {
                if ($id eq $alias) {
 
        foreach my $alias (sort keys %aliases) {
                if ($id eq $alias) {
-                       return $aliases{$alias};
+                       return $aliases{$alias}{"IPT"};
                }
        }
 }
                }
        }
 }
-sub get_nat_address
-{
+
+sub get_nat_address {
        my $zone = shift;
        my $source = shift;
 
        my $zone = shift;
        my $source = shift;
 
@@ -451,15 +452,20 @@ sub get_nat_address
        } elsif ($zone eq "RED" || $zone eq "GREEN" || $zone eq "ORANGE" || $zone eq "BLUE") {
                return $netsettings{$zone . "_ADDRESS"};
 
        } elsif ($zone eq "RED" || $zone eq "GREEN" || $zone eq "ORANGE" || $zone eq "BLUE") {
                return $netsettings{$zone . "_ADDRESS"};
 
-       } elsif ($zone eq "Default IP") {
+       } elsif ($zone ~~ ["Default IP", "ALL"]) {
                return &get_external_address();
 
        } else {
                return &get_external_address();
 
        } else {
-               return &get_alias($zone);
+               my $alias = &get_alias($zone);
+               unless ($alias) {
+                       $alias = &get_external_address();
+               }
+               return $alias;
        }
 
        print_error("Could not find NAT address");
 }
        }
 
        print_error("Could not find NAT address");
 }
+
 sub get_internal_firewall_ip_addresses
 {
        my $use_orange = shift;
 sub get_internal_firewall_ip_addresses
 {
        my $use_orange = shift;
index a0bc32c9665da8e34d5af3c37ef82b50c3d02ca8..dae2d5269a22392cf44af3407f8dfaa8d5809ca0 100755 (executable)
@@ -53,7 +53,6 @@ my %customgrp=();
 my %configinputfw=();
 my %configoutgoingfw=();
 my %confignatfw=();
 my %configinputfw=();
 my %configoutgoingfw=();
 my %confignatfw=();
-my %aliases=();
 my @p2ps=();
 
 my $configfwdfw                = "${General::swroot}/firewall/config";
 my @p2ps=();
 
 my $configfwdfw                = "${General::swroot}/firewall/config";
@@ -69,7 +68,6 @@ my $netsettings               = "${General::swroot}/ethernet/settings";
 &General::readhasharray($configinput, \%configinputfw);
 &General::readhasharray($configoutgoing, \%configoutgoingfw);
 &General::readhasharray($configgrp, \%customgrp);
 &General::readhasharray($configinput, \%configinputfw);
 &General::readhasharray($configoutgoing, \%configoutgoingfw);
 &General::readhasharray($configgrp, \%customgrp);
-&General::get_aliases(\%aliases);
 
 my @log_limit_options = &make_log_limit_options();
 
 
 my @log_limit_options = &make_log_limit_options();