mirror of
https://gitlab.com/shorewall/code.git
synced 2024-11-27 01:53:27 +01:00
First phase of producing consistent scripts with Perl >= 5.18.0
Beginning with Perl 5.18.0, the order of elements returned by the 'keys' and 'each' iterators is no longer deterministic. This is the first wave of Shorewall changes to compensate for this irrational behavior. Signed-off-by: Tom Eastep <teastep@shorewall.net>
This commit is contained in:
parent
bc8156b503
commit
014ec1af1d
@ -6816,22 +6816,28 @@ sub set_global_variables( $$ ) {
|
|||||||
my ( $setall, $conditional ) = @_;
|
my ( $setall, $conditional ) = @_;
|
||||||
|
|
||||||
if ( $conditional ) {
|
if ( $conditional ) {
|
||||||
my ( $interface, $code );
|
my ( $interface, @interfaces );
|
||||||
|
|
||||||
while ( ( $interface, $code ) = each %interfaceaddr ) {
|
@interfaces = sort keys %interfaceaddr;
|
||||||
emit( qq([ -z "\$interface" -o "\$interface" = "$interface" ] && $code) );
|
|
||||||
|
for $interface ( @interfaces ) {
|
||||||
|
emit( qq([ -z "\$interface" -o "\$interface" = "$interface" ] && $interfaceaddr{$interface}) );
|
||||||
}
|
}
|
||||||
|
|
||||||
while ( ( $interface, $code ) = each %interfacegateways ) {
|
@interfaces = sort keys %interfacegateways;
|
||||||
|
|
||||||
|
for $interface ( @interfaces ) {
|
||||||
emit( qq(if [ -z "\$interface" -o "\$interface" = "$interface" ]; then) );
|
emit( qq(if [ -z "\$interface" -o "\$interface" = "$interface" ]; then) );
|
||||||
push_indent;
|
push_indent;
|
||||||
emit( $code );
|
emit( $interfacegateways{$interface} );
|
||||||
pop_indent;
|
pop_indent;
|
||||||
emit( qq(fi\n) );
|
emit( qq(fi\n) );
|
||||||
}
|
}
|
||||||
|
|
||||||
while ( ( $interface, $code ) = each %interfacemacs ) {
|
@interfaces = sort keys %interfacemacs;
|
||||||
emit( qq([ -z "\$interface" -o "\$interface" = "$interface" ] && $code) );
|
|
||||||
|
for $interface ( @interfaces ) {
|
||||||
|
emit( qq([ -z "\$interface" -o "\$interface" = "$interface" ] && $interfacemacs{$interface}) );
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
emit $_ for values %interfaceaddr;
|
emit $_ for values %interfaceaddr;
|
||||||
|
@ -1579,7 +1579,7 @@ sub add_interface_jumps {
|
|||||||
our %input_jump_added;
|
our %input_jump_added;
|
||||||
our %output_jump_added;
|
our %output_jump_added;
|
||||||
our %forward_jump_added;
|
our %forward_jump_added;
|
||||||
my @interfaces = grep $_ ne '%vserver%', @_;
|
my @interfaces = sort grep $_ ne '%vserver%', @_;
|
||||||
my $dummy;
|
my $dummy;
|
||||||
my $lo_jump_added = interface_zone( loopback_interface ) && ! get_interface_option( loopback_interface, 'destonly' );
|
my $lo_jump_added = interface_zone( loopback_interface ) && ! get_interface_option( loopback_interface, 'destonly' );
|
||||||
#
|
#
|
||||||
|
@ -374,7 +374,7 @@ sub start_provider( $$$$$ ) {
|
|||||||
|
|
||||||
emit "\n#\n# Add $what $table ($number)\n#";
|
emit "\n#\n# Add $what $table ($number)\n#";
|
||||||
|
|
||||||
if ( $number ) {
|
if ( $number >= 0 ) {
|
||||||
emit "start_provider_$table() {";
|
emit "start_provider_$table() {";
|
||||||
} else {
|
} else {
|
||||||
emit "start_interface_$table() {";
|
emit "start_interface_$table() {";
|
||||||
@ -384,7 +384,7 @@ sub start_provider( $$$$$ ) {
|
|||||||
emit $test;
|
emit $test;
|
||||||
push_indent;
|
push_indent;
|
||||||
|
|
||||||
if ( $number ) {
|
if ( $number >= 0 ) {
|
||||||
emit "qt ip -$family route flush table $id";
|
emit "qt ip -$family route flush table $id";
|
||||||
emit "echo \"\$IP -$family route flush table $id > /dev/null 2>&1\" > \${VARDIR}/undo_${table}_routing";
|
emit "echo \"\$IP -$family route flush table $id > /dev/null 2>&1\" > \${VARDIR}/undo_${table}_routing";
|
||||||
} else {
|
} else {
|
||||||
@ -1442,10 +1442,13 @@ sub process_providers( $ ) {
|
|||||||
#
|
#
|
||||||
# Treat optional interfaces as pseudo-providers
|
# Treat optional interfaces as pseudo-providers
|
||||||
#
|
#
|
||||||
|
my $num = -65536;
|
||||||
|
|
||||||
for ( grep interface_is_optional( $_ ) && ! $provider_interfaces{ $_ }, all_real_interfaces ) {
|
for ( grep interface_is_optional( $_ ) && ! $provider_interfaces{ $_ }, all_real_interfaces ) {
|
||||||
|
$num++;
|
||||||
#
|
#
|
||||||
# TABLE NUMBER MARK DUPLICATE INTERFACE GATEWAY OPTIONS COPY
|
# TABLE NUMBER MARK DUPLICATE INTERFACE GATEWAY OPTIONS COPY
|
||||||
$currentline = var_base($_) ." 0 - - $_ - - -";
|
$currentline = var_base($_) . " $num - - $_ - - -";
|
||||||
#
|
#
|
||||||
$pseudoproviders += process_a_provider(1);
|
$pseudoproviders += process_a_provider(1);
|
||||||
}
|
}
|
||||||
|
@ -2170,8 +2170,10 @@ sub find_hosts_by_option( $ ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for my $zone ( grep ! ( $zones{$_}{type} & FIREWALL ) , @zones ) {
|
for my $zone ( grep ! ( $zones{$_}{type} & FIREWALL ) , @zones ) {
|
||||||
while ( my ($type, $interfaceref) = each %{$zones{$zone}{hosts}} ) {
|
for my $type (keys %{$zones{$zone}{hosts}} ) {
|
||||||
while ( my ( $interface, $arrayref) = ( each %{$interfaceref} ) ) {
|
my $interfaceref = $zones{$zone}{hosts}->{$type};
|
||||||
|
for my $interface ( keys %$interfaceref ) {
|
||||||
|
my $arrayref = $interfaceref->{$interface};
|
||||||
for my $host ( @{$arrayref} ) {
|
for my $host ( @{$arrayref} ) {
|
||||||
my $ipsec = $host->{ipsec};
|
my $ipsec = $host->{ipsec};
|
||||||
unless ( $done{$interface} ) {
|
unless ( $done{$interface} ) {
|
||||||
@ -2210,7 +2212,9 @@ sub find_zone_hosts_by_option( $$ ) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
\@hosts;
|
my @sorted = sort { $a->[0] cmp $b->[0] } @hosts;
|
||||||
|
|
||||||
|
\@sorted
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
|
Loading…
Reference in New Issue
Block a user