forked from extern/shorewall_code
Finish (unpublished) parameterized actions
This commit is contained in:
parent
6263689c3e
commit
ac42fddbce
@ -96,6 +96,8 @@ our %EXPORT_TAGS = ( internal => [ qw( create_temp_script
|
|||||||
close_file
|
close_file
|
||||||
push_open
|
push_open
|
||||||
pop_open
|
pop_open
|
||||||
|
add_params
|
||||||
|
del_params
|
||||||
read_a_line
|
read_a_line
|
||||||
validate_level
|
validate_level
|
||||||
which
|
which
|
||||||
@ -1781,6 +1783,29 @@ sub embedded_perl( $ ) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# Add parameters
|
||||||
|
#
|
||||||
|
sub add_params( $ ) {
|
||||||
|
my $params = shift;
|
||||||
|
|
||||||
|
my @params = split /,/, $params;
|
||||||
|
|
||||||
|
for ( my $i = 1; $i <= @params; $i++ ) {
|
||||||
|
$params{$i} = $params[$i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sub del_params( $ ) {
|
||||||
|
my $params = shift;
|
||||||
|
|
||||||
|
my @params = split /,/, $params;
|
||||||
|
|
||||||
|
for ( my $i = 1; $i <= @params; $i++ ) {
|
||||||
|
delete $params{$i};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
# Read a line from the current include stack.
|
# Read a line from the current include stack.
|
||||||
#
|
#
|
||||||
@ -1857,7 +1882,7 @@ sub read_a_line(;$) {
|
|||||||
# Expand Shell Variables using %params and %ENV
|
# Expand Shell Variables using %params and %ENV
|
||||||
#
|
#
|
||||||
# $1 $2 $3 - $4
|
# $1 $2 $3 - $4
|
||||||
while ( $currentline =~ m( ^(.*?) \$({)? ([a-zA-Z]\w*) (?(2)}) (.*)$ )x ) {
|
while ( $currentline =~ m( ^(.*?) \$({)? (\w+) (?(2)}) (.*)$ )x ) {
|
||||||
|
|
||||||
unless ( exists $params{$3} ) {
|
unless ( exists $params{$3} ) {
|
||||||
#
|
#
|
||||||
|
@ -342,8 +342,8 @@ sub process_actions1() {
|
|||||||
#
|
#
|
||||||
# Generate chain for non-builtin action invocation
|
# Generate chain for non-builtin action invocation
|
||||||
#
|
#
|
||||||
sub process_action3( $$$$$ ) {
|
sub process_action3( $$$$$$ ) {
|
||||||
my ( $chainref, $wholeaction, $action, $level, $tag ) = @_;
|
my ( $chainref, $wholeaction, $action, $level, $tag, $param ) = @_;
|
||||||
my $actionfile = find_file "action.$action";
|
my $actionfile = find_file "action.$action";
|
||||||
my $format = 1;
|
my $format = 1;
|
||||||
|
|
||||||
@ -353,6 +353,8 @@ sub process_action3( $$$$$ ) {
|
|||||||
|
|
||||||
open_file $actionfile;
|
open_file $actionfile;
|
||||||
|
|
||||||
|
add_params( $param );
|
||||||
|
|
||||||
while ( read_a_line ) {
|
while ( read_a_line ) {
|
||||||
|
|
||||||
my ($target, $source, $dest, $proto, $ports, $sports, $origdest, $rate, $user, $mark, $connlimit, $time, $headers );
|
my ($target, $source, $dest, $proto, $ports, $sports, $origdest, $rate, $user, $mark, $connlimit, $time, $headers );
|
||||||
@ -550,7 +552,7 @@ sub process_actions3 () {
|
|||||||
$level = '' if $level =~ /none!?/;
|
$level = '' if $level =~ /none!?/;
|
||||||
$builtinops{$action}->($chainref, $level, $tag, $param );
|
$builtinops{$action}->($chainref, $level, $tag, $param );
|
||||||
} else {
|
} else {
|
||||||
process_action3 $chainref, $wholeaction, $action, $level, $tag;
|
process_action3 $chainref, $wholeaction, $action, $level, $tag, $param;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user