forked from extern/shorewall_code
Simplify detection of action self-invocation
This commit is contained in:
parent
6240d41754
commit
1285b73d52
@ -297,6 +297,8 @@ sub process_actions1() {
|
|||||||
|
|
||||||
new_action $action;
|
new_action $action;
|
||||||
|
|
||||||
|
$targets{$action} = ACTION;
|
||||||
|
|
||||||
my $actionfile = find_file "action.$action";
|
my $actionfile = find_file "action.$action";
|
||||||
|
|
||||||
fatal_error "Missing Action File ($actionfile)" unless -f $actionfile;
|
fatal_error "Missing Action File ($actionfile)" unless -f $actionfile;
|
||||||
@ -304,11 +306,6 @@ sub process_actions1() {
|
|||||||
progress_message2 " Pre-processing $actionfile...";
|
progress_message2 " Pre-processing $actionfile...";
|
||||||
|
|
||||||
push_open( $actionfile );
|
push_open( $actionfile );
|
||||||
#
|
|
||||||
# We defer assigning a type to the action until we've processed it's action file.
|
|
||||||
# This allows us to easily catch the case where an action invokes itself.
|
|
||||||
#
|
|
||||||
my $actiontype = 0;
|
|
||||||
|
|
||||||
while ( read_a_line ) {
|
while ( read_a_line ) {
|
||||||
|
|
||||||
@ -318,11 +315,7 @@ sub process_actions1() {
|
|||||||
# deals with the target and the parameter. We pass undef for the rest so we'll
|
# deals with the target and the parameter. We pass undef for the rest so we'll
|
||||||
# know if we try to use one of them.
|
# know if we try to use one of them.
|
||||||
#
|
#
|
||||||
# process_rule_common() returns the NATONLY actiontype flag if the target
|
process_rule_common( $action ,
|
||||||
# of the rule includes NATRULE, NATONLY or NONAT. The flag is LORed into the
|
|
||||||
# action's type below.
|
|
||||||
#
|
|
||||||
$actiontype |= process_rule_common( $action ,
|
|
||||||
$wholetarget ,
|
$wholetarget ,
|
||||||
'' , # Current Param
|
'' , # Current Param
|
||||||
undef, # source
|
undef, # source
|
||||||
@ -342,8 +335,6 @@ sub process_actions1() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pop_open;
|
pop_open;
|
||||||
|
|
||||||
$targets{$action} = ACTION | $actiontype;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -839,6 +830,7 @@ sub process_rule_common ( $$$$$$$$$$$$$$$$ ) {
|
|||||||
$normalized_target = normalize_action( $basictarget, $loglevel, $param );
|
$normalized_target = normalize_action( $basictarget, $loglevel, $param );
|
||||||
|
|
||||||
if ( $inaction1 ) {
|
if ( $inaction1 ) {
|
||||||
|
fatal_error "An action may not invoke itself" if $basictarget eq $inaction1;
|
||||||
add_requiredby( $normalized_target , $inaction1 );
|
add_requiredby( $normalized_target , $inaction1 );
|
||||||
} else {
|
} else {
|
||||||
if ( my $ref = use_action( $normalized_target ) ) {
|
if ( my $ref = use_action( $normalized_target ) ) {
|
||||||
@ -847,11 +839,10 @@ sub process_rule_common ( $$$$$$$$$$$$$$$$ ) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
if ( $inaction1 ) {
|
||||||
# Return the NATRULE flag to the caller who will eventually add it
|
$targets{$inaction1} |= NATRULE if $actiontype & (NATRULE | NONAT | NATONLY );
|
||||||
# to $targets{$inaction1}
|
return 1;
|
||||||
#
|
}
|
||||||
return ( $actiontype & ( NATRULE | NONAT | NATONLY ) ) ? NATRULE : 0 if $inaction1;
|
|
||||||
#
|
#
|
||||||
# Take care of irregular syntax and targets
|
# Take care of irregular syntax and targets
|
||||||
#
|
#
|
||||||
|
Loading…
Reference in New Issue
Block a user