diff --git a/Shorewall/Perl/Shorewall/Accounting.pm b/Shorewall/Perl/Shorewall/Accounting.pm index d81c6f417..bcb42d612 100644 --- a/Shorewall/Perl/Shorewall/Accounting.pm +++ b/Shorewall/Perl/Shorewall/Accounting.pm @@ -414,8 +414,6 @@ sub setup_accounting() { $nonEmpty |= process_accounting_rule while read_a_line( NORMAL_READ ); - clear_comment; - if ( $nonEmpty ) { my $tableref = $chain_table{$acctable}; diff --git a/Shorewall/Perl/Shorewall/Config.pm b/Shorewall/Perl/Shorewall/Config.pm index dbc1ee1cf..fd1af773c 100644 --- a/Shorewall/Perl/Shorewall/Config.pm +++ b/Shorewall/Perl/Shorewall/Config.pm @@ -1961,8 +1961,8 @@ sub no_comment() { # Clear the $comment variable and the comment stack # sub clear_comment() { - $comment = ''; - @comments = (); + $comment = ''; + @comments = (); } # @@ -2007,16 +2007,18 @@ sub do_open_file( $ ) { } sub open_file( $;$$$ ) { - my $fname = find_file $_[0]; + my ( $fname, $mf, $ca, $nc ) = @_; + + $fname = find_file $fname; assert( ! defined $currentfile ); if ( -f $fname && -s _ ) { $first_entry = 0; $file_format = 1; - $max_format = supplied $_[1] ? $_[1] : 1; - $comments_allowed = supplied $_[2] ? $_[2] : 0; - $nocomment = supplied $_[3] ? $_[3] && no_comment : 0; + $max_format = supplied $mf ? $mf : 1; + $comments_allowed = supplied $ca ? $ca : 0; + $nocomment++ if supplied( $ca ) && no_comment; do_open_file $fname;; } else { $ifstack = @ifstack; @@ -2038,10 +2040,12 @@ sub pop_include() { if ( $arrayref ) { ( $currentfile, $currentfilename, $currentlinenumber, $ifstack, $file_format, $max_format, $nocomment ) = @$arrayref; + $comment = '' unless @openstack; } else { $currentfile = undef; $currentlinenumber = 'EOF'; - $nocomment = $comment = 0; + clear_comment; + $nocomment = 0; } } @@ -2960,7 +2964,7 @@ sub read_a_line($) { } if ( $comments_allowed && $currentline =~ /^\s*COMMENT\b/ ) { - process_comment; + process_comment unless $nocomment; $currentline = ''; $currentlinenumber = 0; next diff --git a/Shorewall/Perl/Shorewall/Misc.pm b/Shorewall/Perl/Shorewall/Misc.pm index ae8a3c880..ac070f503 100644 --- a/Shorewall/Perl/Shorewall/Misc.pm +++ b/Shorewall/Perl/Shorewall/Misc.pm @@ -746,8 +746,6 @@ sub process_stoppedrules() { } } - clear_comment; - $result; } @@ -1254,8 +1252,6 @@ sub setup_mac_lists( $ ) { progress_message " Maclist entry \"$currentline\" $done"; } - - clear_comment; } # # Generate jumps from the input and forward chains diff --git a/Shorewall/Perl/Shorewall/Nat.pm b/Shorewall/Perl/Shorewall/Nat.pm index 24c0dea6e..7e66c4bf7 100644 --- a/Shorewall/Perl/Shorewall/Nat.pm +++ b/Shorewall/Perl/Shorewall/Nat.pm @@ -282,8 +282,6 @@ sub setup_masq() first_entry( sub { progress_message2 "$doing $fn..."; require_capability 'NAT_ENABLED' , 'a non-empty masq file' , 's'; } ); process_one_masq while read_a_line( NORMAL_READ ); - - clear_comment; } } @@ -396,8 +394,6 @@ sub setup_nat() { progress_message " NAT entry \"$currentline\" $done"; } - - clear_comment; } } @@ -509,8 +505,6 @@ sub setup_netmap() { progress_message " Network $net1 on $iface mapped to $net2 ($type)"; } } - - clear_comment; } } diff --git a/Shorewall/Perl/Shorewall/Raw.pm b/Shorewall/Perl/Shorewall/Raw.pm index 184039940..e3e358743 100644 --- a/Shorewall/Perl/Shorewall/Raw.pm +++ b/Shorewall/Perl/Shorewall/Raw.pm @@ -274,8 +274,6 @@ sub setup_conntrack() { } } - clear_comment; - if ( $name eq 'notrack') { if ( $empty ) { if ( unlink( $fn ) ) { diff --git a/Shorewall/Perl/Shorewall/Rules.pm b/Shorewall/Perl/Shorewall/Rules.pm index ef9fc5a41..db967fd31 100644 --- a/Shorewall/Perl/Shorewall/Rules.pm +++ b/Shorewall/Perl/Shorewall/Rules.pm @@ -1632,8 +1632,6 @@ sub use_policy_action( $ ) { sub process_macro ($$$$$$$$$$$$$$$$$$$) { my ($macro, $chainref, $target, $param, $source, $dest, $proto, $ports, $sports, $origdest, $rate, $user, $mark, $connlimit, $time, $headers, $condition, $helper, $wildcard ) = @_; - my $nocomment = no_comment; - my $generated = 0; @@ -1746,8 +1744,6 @@ sub process_macro ($$$$$$$$$$$$$$$$$$$) { progress_message "..End Macro $macrofile"; - clear_comment unless $nocomment; - return $generated; } @@ -1757,8 +1753,6 @@ sub process_macro ($$$$$$$$$$$$$$$$$$$) { sub process_inline ($$$$$$$$$$$$$$$$$$$$) { my ($inline, $chainref, $loglevel, $target, $param, $source, $dest, $proto, $ports, $sports, $origdest, $rate, $user, $mark, $connlimit, $time, $headers, $condition, $helper, $wildcard ) = @_; - my $nocomment = no_comment; - my $generated = 0; my ( $level, $tag ) = split( ':', $loglevel, 2 ); @@ -1867,8 +1861,6 @@ sub process_inline ($$$$$$$$$$$$$$$$$$$$) { pop_action_params( $oldparms ); - clear_comment unless $nocomment; - return $generated; } @@ -2737,8 +2729,6 @@ sub process_rules( $ ) { ); process_rule while read_a_line( NORMAL_READ ); - - clear_comment; } $section = ''; @@ -2757,8 +2747,6 @@ sub process_rules( $ ) { first_entry "$doing $fn..."; process_rule while read_a_line( NORMAL_READ ); - - clear_comment; } $section = 'DEFAULTACTION'; diff --git a/Shorewall/Perl/Shorewall/Tc.pm b/Shorewall/Perl/Shorewall/Tc.pm index bd7404736..5281f88bc 100644 --- a/Shorewall/Perl/Shorewall/Tc.pm +++ b/Shorewall/Perl/Shorewall/Tc.pm @@ -1869,8 +1869,6 @@ sub process_tcpri() { process_tc_priority while read_a_line( NORMAL_READ ); - clear_comment; - if ( $ipp2p ) { insert_irule( $mangle_table->{tcpost} , j => 'CONNMARK --restore-mark --ctmask ' . in_hex( $globals{TC_MASK} ) , @@ -2394,8 +2392,6 @@ sub setup_tc() { process_tc_rule while read_a_line( NORMAL_READ ); - clear_comment; - } if ( my $fn = open_file( 'secmarks', 1, 1 ) ) { @@ -2404,7 +2400,6 @@ sub setup_tc() { process_secmark_rule while read_a_line( NORMAL_READ ); - clear_comment; } handle_stickiness( $sticky ); diff --git a/Shorewall/Perl/Shorewall/Tunnels.pm b/Shorewall/Perl/Shorewall/Tunnels.pm index 9d7f45dcf..35c2a0083 100644 --- a/Shorewall/Perl/Shorewall/Tunnels.pm +++ b/Shorewall/Perl/Shorewall/Tunnels.pm @@ -298,8 +298,6 @@ sub setup_tunnels() { fatal_error 'ZONE must be specified' if $zone eq '-'; setup_one_tunnel $kind, $zone, $gateway, $gatewayzones; } - - clear_comment; } }