diff --git a/Shorewall/Perl/Shorewall/Chains.pm b/Shorewall/Perl/Shorewall/Chains.pm index eca19bc0b..5a0f437aa 100644 --- a/Shorewall/Perl/Shorewall/Chains.pm +++ b/Shorewall/Perl/Shorewall/Chains.pm @@ -2330,7 +2330,7 @@ sub ensure_audit_blacklog_chain( $$$ ) { sub ensure_audit_chain( $;$$ ) { my ( $target, $action, $tgt ) = @_; - push_comment( '' ); + my $save_comment = push_comment; my $ref = $filter_table->{$target}; @@ -2353,7 +2353,7 @@ sub ensure_audit_chain( $;$$ ) { } } - pop_comment; + pop_comment( $save_comment ); return $target; } diff --git a/Shorewall/Perl/Shorewall/Config.pm b/Shorewall/Perl/Shorewall/Config.pm index 6805cc324..45f720c08 100644 --- a/Shorewall/Perl/Shorewall/Config.pm +++ b/Shorewall/Perl/Shorewall/Config.pm @@ -135,7 +135,6 @@ our %EXPORT_TAGS = ( internal => [ qw( create_temp_script process_comment no_comment macro_comment - clear_comment push_comment pop_comment dump_mark_layout @@ -495,7 +494,6 @@ our $first_entry; # Message to output or function to call on first no our $file_format; # Format of configuration file. our $max_format; # Max format value our $comment; # Current COMMENT -our @comments; our $comments_allowed; our $nocomment; our $warningcount; @@ -623,7 +621,6 @@ sub initialize( $;$$) { # Contents of last COMMENT line. # $comment = ''; - @comments = (); $warningcount = 0; $warningcount1 = 0; $warningcount2 = 0; @@ -1962,26 +1959,20 @@ sub no_comment() { # sub clear_comment() { $comment = ''; - @comments = (); + $nocomment = 0; } # # Push and Pop comment stack # -sub push_comment( $ ) { - push @comments, $comment; - $comment = shift; +sub push_comment() { + my $return = $comment; + $comment = ''; + $return; } -sub pop_comment() { - $comment = pop @comments; -} - -# -# Set comment -# -sub set_comment( $ ) { - $comment = shift; +sub pop_comment( $ ) { + $comment = $_[0]; } # @@ -2073,7 +2064,6 @@ sub pop_include() { $currentfile = undef; $currentlinenumber = 'EOF'; clear_comment; - $nocomment = 0; } } diff --git a/Shorewall/Perl/Shorewall/Rules.pm b/Shorewall/Perl/Shorewall/Rules.pm index 909deca36..dfa22d248 100644 --- a/Shorewall/Perl/Shorewall/Rules.pm +++ b/Shorewall/Perl/Shorewall/Rules.pm @@ -842,8 +842,7 @@ sub finish_chain_section ($$) { my $chain = $chainref->{name}; my $related_level = $config{RELATED_LOG_LEVEL}; my $related_target = $globals{RELATED_TARGET}; - - push_comment(''); #These rules should not have comments + my $save_comment = push_comment; if ( $state =~ /RELATED/ && ( $related_level || $related_target ne 'ACCEPT' ) ) { @@ -890,7 +889,7 @@ sub finish_chain_section ($$) { $chainref->{new} = @{$chainref->{rules}}; } - pop_comment; + pop_comment( $save_comment ); } # @@ -1561,7 +1560,7 @@ sub process_action($) { $active{$action}++; push @actionstack, $wholeaction; - push_comment( '' ); + my $save_comment = push_comment; while ( read_a_line( NORMAL_READ ) ) { @@ -1603,7 +1602,7 @@ sub process_action($) { 0 ); } - pop_comment; + pop_comment( $save_comment ); $active{$action}--; pop @actionstack; @@ -1769,7 +1768,7 @@ sub process_inline ($$$$$$$$$$$$$$$$$$$$) { push_open $inlinefile, 2, 1; - push_comment(''); + my $save_comment = push_comment; while ( read_a_line( NORMAL_READ ) ) { my ( $mtarget, @@ -1855,7 +1854,7 @@ sub process_inline ($$$$$$$$$$$$$$$$$$$$) { progress_message " Rule \"$currentline\" $done"; } - pop_comment; + pop_comment( $save_comment ); pop_open;