From 8dc60e788f72f0b011e1453ed947265c6e6004a0 Mon Sep 17 00:00:00 2001 From: Tom Eastep Date: Sat, 8 Jan 2011 14:05:27 -0800 Subject: [PATCH] Avoid early return in process_action() --- Shorewall/Perl/Shorewall/Rules.pm | 127 +++++++++++++++--------------- 1 file changed, 63 insertions(+), 64 deletions(-) diff --git a/Shorewall/Perl/Shorewall/Rules.pm b/Shorewall/Perl/Shorewall/Rules.pm index 07d211353..c31a78f7f 100644 --- a/Shorewall/Perl/Shorewall/Rules.pm +++ b/Shorewall/Perl/Shorewall/Rules.pm @@ -689,71 +689,70 @@ sub process_action( $) { if ( $targets{$action} & BUILTIN ) { $level = '' if $level =~ /none!?/; $builtinops{$action}->( $chainref, $level, $tag, $param ); - return; + } else { + my $actionfile = find_file "action.$action"; + my $format = 1; + + fatal_error "Missing Action File ($actionfile)" unless -f $actionfile; + + progress_message2 "$doing $actionfile for chain $chainref->{name}..."; + + push_open $actionfile; + + my $oldparms = push_params( $param ); + + $active{$wholeaction}++; + push @actionstack, $wholeaction; + + while ( read_a_line ) { + + my ($target, $source, $dest, $proto, $ports, $sports, $origdest, $rate, $user, $mark, $connlimit, $time, $headers ); + + if ( $format == 1 ) { + ($target, $source, $dest, $proto, $ports, $sports, $rate, $user, $mark ) = split_line1 1, 9, 'action file', $rule_commands; + $origdest = $connlimit = $time = $headers = '-'; + } else { + ($target, $source, $dest, $proto, $ports, $sports, $origdest, $rate, $user, $mark, $connlimit, $time, $headers ) = split_line1 1, 13, 'action file', $rule_commands; + } + + if ( $target eq 'COMMENT' ) { + process_comment; + next; + } + + if ( $target eq 'FORMAT' ) { + fatal_error "FORMAT must be 1 or 2" unless $source =~ /^[12]$/; + $format = $source; + next; + } + + process_rule1( $chainref, + merge_levels( "$action:$level:$tag", $target ), + '', + $source, + $dest, + $proto, + $ports, + $sports, + $origdest, + $rate, + $user, + $mark, + $connlimit, + $time, + $headers, + 0 ); + } + + clear_comment; + + $active{$wholeaction}--; + pop @actionstack; + + pop_open; + + pop_params( $oldparms ); } - - my $actionfile = find_file "action.$action"; - my $format = 1; - - fatal_error "Missing Action File ($actionfile)" unless -f $actionfile; - - progress_message2 "$doing $actionfile for chain $chainref->{name}..."; - - push_open $actionfile; - - my $oldparms = push_params( $param ); - - $active{$wholeaction}++; - push @actionstack, $wholeaction; - - while ( read_a_line ) { - - my ($target, $source, $dest, $proto, $ports, $sports, $origdest, $rate, $user, $mark, $connlimit, $time, $headers ); - - if ( $format == 1 ) { - ($target, $source, $dest, $proto, $ports, $sports, $rate, $user, $mark ) = split_line1 1, 9, 'action file', $rule_commands; - $origdest = $connlimit = $time = $headers = '-'; - } else { - ($target, $source, $dest, $proto, $ports, $sports, $origdest, $rate, $user, $mark, $connlimit, $time, $headers ) = split_line1 1, 13, 'action file', $rule_commands; - } - - if ( $target eq 'COMMENT' ) { - process_comment; - next; - } - - if ( $target eq 'FORMAT' ) { - fatal_error "FORMAT must be 1 or 2" unless $source =~ /^[12]$/; - $format = $source; - next; - } - - process_rule1( $chainref, - merge_levels( "$action:$level:$tag", $target ), - '', - $source, - $dest, - $proto, - $ports, - $sports, - $origdest, - $rate, - $user, - $mark, - $connlimit, - $time, - $headers, - 0 ); - } - - clear_comment; - - $active{$wholeaction}--; - pop @actionstack; - - pop_open; - - pop_params( $oldparms ); } #