From 8385ebaa314f3579658ed58d44994f4acbe7f576 Mon Sep 17 00:00:00 2001 From: teastep Date: Tue, 8 May 2007 00:48:05 +0000 Subject: [PATCH] Try to fix section bugs git-svn-id: https://shorewall.svn.sourceforge.net/svnroot/shorewall/trunk@6275 fbd18981-670d-0410-9b5c-8dc0c1a9a2bb --- Shorewall-perl/Shorewall/Chains.pm | 4 ++-- Shorewall-perl/Shorewall/Rules.pm | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Shorewall-perl/Shorewall/Chains.pm b/Shorewall-perl/Shorewall/Chains.pm index d52c27f20..1430cf452 100644 --- a/Shorewall-perl/Shorewall/Chains.pm +++ b/Shorewall-perl/Shorewall/Chains.pm @@ -539,7 +539,7 @@ sub ensure_filter_chain( $$ ) if ( $populate and ! $chainref->{referenced} ) { if ( $section eq 'NEW' or $section eq 'DONE' ) { finish_chain_section $chainref , 'ESTABLISHED,RELATED'; - } elsif ( $section eq 'ESTABLISHED' ) { + } elsif ( $section eq 'RELATED' ) { finish_chain_section $chainref , 'ESTABLISHED'; } } @@ -646,7 +646,7 @@ sub finish_section ( $ ) { for my $zone ( @zones ) { for my $zone1 ( @zones ) { - my $chainref = $chain_table{'filter'}{"$zone}2${zone1}"}; + my $chainref = $chain_table{'filter'}{"${zone}2${zone1}"}; if ( $chainref->{referenced} ) { finish_chain_section $chainref, $sections; } diff --git a/Shorewall-perl/Shorewall/Rules.pm b/Shorewall-perl/Shorewall/Rules.pm index 27606c194..a50116dfa 100644 --- a/Shorewall-perl/Shorewall/Rules.pm +++ b/Shorewall-perl/Shorewall/Rules.pm @@ -977,6 +977,7 @@ sub process_rule1 ( $$$$$$$$$$ ) { # $rule = join( '', do_proto($proto, $ports, $sports), do_ratelimit( $ratelimit, $basictarget ) , do_user( $user ) , do_test( $mark , 0xFF ) ); + $rule .= "-m state --state $section " if $section eq 'ESTABLISHED' || $section eq 'RELATED'; # # Generate NAT rule(s), if any # @@ -1277,10 +1278,10 @@ sub process_rules() { $sectioned = 1; $sections{$source} = 1; - if ( $section eq 'RELATED' ) { + if ( $source eq 'RELATED' ) { $sections{ESTABLISHED} = 1; finish_section 'ESTABLISHED'; - } elsif ( $section eq 'NEW' ) { + } elsif ( $source eq 'NEW' ) { @sections{'ESTABLISHED','RELATED'} = ( 1, 1 ); finish_section ( ( $section eq 'RELATED' ) ? 'RELATED' : 'ESTABLISHED,RELATED' ); }