On 02/08/2013 08:23 PM, Tom Eastep wrote:
> On 02/08/2013 08:08 PM, Tom Eastep wrote:
> 
>>> One suggestion on your todo list if/when you have the time:
>>>
>>> Suppose I have this: action1 with, say, 2 parameters which in turn calls 
>>> action2 with the same number of parameters. In other words:
>>>
>>> action1
>>> ~~~~~
>>> action2($1,$2)
>>>
>>> As things stand, if I execute action1(-,something), the first parameter 
>>> doesn't have a value (and rightly so), but that in effect screws up the 
>>> action2 call. So, what I currently have to do is this:
>>>
>>> action1
>>> ~~~~~
>>> IF $1
>>>   ?SET p1 $1
>>> ?ELSE
>>>   ?SET p1 "-"
>>> ?ENDIF
>>> IF $2
>>>   ?SET p2 $2
>>> ?ELSE
>>>   ?SET p2 "-"
>>> ?ENDIF
>>> action2($p1,$p2)
>>>
>>> The above isn't very nice. Perhaps you may thing of allowing a call like 
>>> "action2(,something) (first parameter is not specified) to avoid this - 
>>> just a suggestion.
>>
>> Why don't you simply use the 'DEFAULTS' feature in action2?
> 
> Don't mind that.
> 
> Rather:
> 
> ?set $p1 $1 ? $1 : '-'
> ?set $p2 $2 ? $2 : '-'
> action2( $p1, $p2 )
> 
> Still not perfect but simpler than what you suggested.

Patch attached -- it allows parameters to be omitted in action invocations.

-Tom

-- 
Tom Eastep        \ When I die, I want to go like my Grandfather who
Shoreline,         \ died peacefully in his sleep. Not screaming like
Washington, USA     \ all of the passengers in his car
http://shorewall.net \________________________________________________
diff --git a/Shorewall/Perl/Shorewall/Config.pm b/Shorewall/Perl/Shorewall/Config.pm
index f455f88..62ec964 100644
--- a/Shorewall/Perl/Shorewall/Config.pm
+++ b/Shorewall/Perl/Shorewall/Config.pm
@@ -1812,8 +1812,12 @@ sub split_list2( $$ ) {
 
 sub split_list3( $$ ) {
     my ($list, $type ) = @_;
-
-    fatal_error "Invalid $type ($list)" if $list =~ /^,|,,/;
+    #
+    # We allow omitted arguments in action invocations.
+    #
+    $list =~ s/^,/-,/;
+    $list =~ s/,$/,-/;
+    $list =~ s/,,/,-,/g;
 
     my @list1 = split /,/, $list;
     my @list2;
diff --git a/Shorewall/Perl/Shorewall/Rules.pm b/Shorewall/Perl/Shorewall/Rules.pm
index 4a4a11e..798ca3e 100644
--- a/Shorewall/Perl/Shorewall/Rules.pm
+++ b/Shorewall/Perl/Shorewall/Rules.pm
@@ -2121,8 +2121,6 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$ ) {
 
 	return $generated;
 
-    } elsif ( $actiontype & ( ACTION | INLINE ) ) {
-	split_list1 $param, 'Action parameter';
     } elsif ( $actiontype & NFQ ) {
 	require_capability( 'NFQUEUE_TARGET', 'NFQUEUE Rules', '' );
 	my $paramval = $param eq '' ? 0 : numeric_value( $param );
@@ -2140,7 +2138,7 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$ ) {
 	validate_level( $action );
 	$loglevel = supplied $loglevel ? join( ':', $action, $loglevel ) : $action;
 	$action   = 'LOG';
-    } else {
+    } elsif ( ! ( $actiontype & (ACTION | INLINE) ) ) {
 	fatal_error "The $basictarget TARGET does not accept a parameter" unless $param eq '';
     }
 

Attachment: signature.asc
Description: OpenPGP digital signature

------------------------------------------------------------------------------
Free Next-Gen Firewall Hardware Offer
Buy your Sophos next-gen firewall before the end March 2013 
and get the hardware for free! Learn more.
http://p.sf.net/sfu/sophos-d2d-feb
_______________________________________________
Shorewall-devel mailing list
Shorewall-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/shorewall-devel

Reply via email to