Some more small changes

git-svn-id: https://shorewall.svn.sourceforge.net/svnroot/shorewall/trunk@5701 fbd18981-670d-0410-9b5c-8dc0c1a9a2bb
This commit is contained in:
teastep 2007-03-26 19:01:38 +00:00
parent 0161e15961
commit cf150dd591
2 changed files with 20 additions and 13 deletions

View File

@ -1022,13 +1022,10 @@ sub interface_address( $ ) {
# If this is the first time that the first address of an interface has been requested, emit a run-time command # If this is the first time that the first address of an interface has been requested, emit a run-time command
# that establishes the value of the associated address variable. # that establishes the value of the associated address variable.
# #
sub get_interface_address ( $$ ) { sub get_interface_address ( $ ) {
my ($chainref, $interface ) = @_; my ( $interface ) = $_[0];
unless ( $interfaceaddrs{$interface } ) { $interfaceaddrs{$interface} = interface_address( $interface ) . "=\$(find_first_interface_address $interface)";
add_command $chainref, interface_address( $interface ) . "=\$(find_first_interface_address $interface)";
$interfaceaddrs{$interface} = 1;
}
} }
# #
@ -1111,14 +1108,14 @@ sub expand_rule( $$$$$$$$$$ )
add_command $chainref, 'addresses='; add_command $chainref, 'addresses=';
for my $interface ( @interfaces ) { for my $interface ( @interfaces ) {
get_interface_address $chainref, $interface; get_interface_address $interface;
add_command $chainref , join( '', 'addresses="$addresses $', interface_address( $interface ). '"' ); add_command $chainref , join( '', 'addresses="$addresses $', interface_address( $interface ). '"' );
} }
add_command $chainref , 'for address in $addresses; do'; add_command $chainref , 'for address in $addresses; do';
$rule .= '-d $address '; $rule .= '-d $address ';
$loopcount++; $loopcount++;
} else { } else {
get_interface_address $chainref, $interfaces[0]; get_interface_address $interfaces[0];
$rule .= join ( '', '-d $', interface_address( $interfaces[0] ), ' ' ); $rule .= join ( '', '-d $', interface_address( $interfaces[0] ), ' ' );
} }
@ -1170,7 +1167,7 @@ sub expand_rule( $$$$$$$$$$ )
add_command $chainref, 'addresses='; add_command $chainref, 'addresses=';
for my $interface ( @interfaces ) { for my $interface ( @interfaces ) {
get_interface_address $chainref, $interface; get_interface_address $interface;
add_command $chainref , qq(addresses="\$addresses \$(find_first_interface_address $interface)"); add_command $chainref , qq(addresses="\$addresses \$(find_first_interface_address $interface)");
} }
@ -1178,7 +1175,7 @@ sub expand_rule( $$$$$$$$$$ )
$rule .= '-m conntrack --ctorigdst $address '; $rule .= '-m conntrack --ctorigdst $address ';
$loopcount++; $loopcount++;
} else { } else {
get_interface_address $chainref, $interfaces[0]; get_interface_address $interfaces[0];
$rule .= join( '', '-m conntrack --ctorigdst $', interface_address ( $interfaces[0] ), ' ' ); $rule .= join( '', '-m conntrack --ctorigdst $', interface_address ( $interfaces[0] ), ' ' );
} }
@ -1383,7 +1380,9 @@ my $state = NULL_STATE;
sub emitr( $ ) { sub emitr( $ ) {
my $rule = $_[0]; my $rule = $_[0];
if ( substr( $rule, 0, 1 ) eq '~' ) { unless ( $slowstart ) {
emit_unindented $rule;
} elsif ( substr( $rule, 0, 1 ) eq '~' ) {
# #
# A command # A command
# #
@ -1412,6 +1411,12 @@ sub create_netfilter_load() {
emit '{'; emit '{';
push_indent; push_indent;
for ( values %interfaceaddrs ) {
emit $_;
}
emit '';
if ( $slowstart ) { if ( $slowstart ) {
emit 'TEMPFILE=$(mktempfile)'; emit 'TEMPFILE=$(mktempfile)';
emit '[ -n "$TEMPFILE" ] || fatal_error "Cannot create temporary file in /tmp"'; emit '[ -n "$TEMPFILE" ] || fatal_error "Cannot create temporary file in /tmp"';

View File

@ -181,10 +181,12 @@ sub emit ( $ ) {
} }
# #
# Jacket for emit() that produces the same result as 'emit join( "\n", ... )' # Jacket for emit() that accepts an indefinite number of arguments; each argument will be emitted as a separate line
# #
sub emitj { sub emitj {
emit join ( "\n", @_ ) if $object; if ( $object ) {
for ( @_ ) { emit $_ };
}
} }