mirror of
https://gitlab.com/shorewall/code.git
synced 2024-12-16 03:10:39 +01:00
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
|
||||
push_open
|
||||
pop_open
|
||||
add_params
|
||||
del_params
|
||||
read_a_line
|
||||
validate_level
|
||||
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.
|
||||
#
|
||||
@ -1857,7 +1882,7 @@ sub read_a_line(;$) {
|
||||
# Expand Shell Variables using %params and %ENV
|
||||
#
|
||||
# $1 $2 $3 - $4
|
||||
while ( $currentline =~ m( ^(.*?) \$({)? ([a-zA-Z]\w*) (?(2)}) (.*)$ )x ) {
|
||||
while ( $currentline =~ m( ^(.*?) \$({)? (\w+) (?(2)}) (.*)$ )x ) {
|
||||
|
||||
unless ( exists $params{$3} ) {
|
||||
#
|
||||
|
@ -342,8 +342,8 @@ sub process_actions1() {
|
||||
#
|
||||
# Generate chain for non-builtin action invocation
|
||||
#
|
||||
sub process_action3( $$$$$ ) {
|
||||
my ( $chainref, $wholeaction, $action, $level, $tag ) = @_;
|
||||
sub process_action3( $$$$$$ ) {
|
||||
my ( $chainref, $wholeaction, $action, $level, $tag, $param ) = @_;
|
||||
my $actionfile = find_file "action.$action";
|
||||
my $format = 1;
|
||||
|
||||
@ -353,6 +353,8 @@ sub process_action3( $$$$$ ) {
|
||||
|
||||
open_file $actionfile;
|
||||
|
||||
add_params( $param );
|
||||
|
||||
while ( read_a_line ) {
|
||||
|
||||
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!?/;
|
||||
$builtinops{$action}->($chainref, $level, $tag, $param );
|
||||
} else {
|
||||
process_action3 $chainref, $wholeaction, $action, $level, $tag;
|
||||
process_action3 $chainref, $wholeaction, $action, $level, $tag, $param;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user