Validate first argument to the default actions

Signed-off-by: Tom Eastep <teastep@shorewall.net>
This commit is contained in:
Tom Eastep 2011-06-25 10:51:17 -07:00
parent 713af61380
commit 024c1fbd08
2 changed files with 20 additions and 12 deletions

View File

@ -43,12 +43,16 @@ my ( $p1, $p2, $p3 , $p4, $p5, $p6 ) = get_action_params( 6 );
fatal_error "Too many parameters to Drop" if defined $p6;
if ( defined $p1 && $p1 eq 'audit' ) {
set_action_param( 2, 'A_REJECT') unless defined( $p2 ) && $p2 ne '-';
set_action_param( 3, 'A_DROP') unless defined( $p3 ) && $p3 ne '-';
set_action_param( 4, 'A_ACCEPT' ) unless defined( $p4 ) && $p4 ne '-';
set_action_param( 5, 'A_DROP' ) unless defined( $p5 ) && $p5 ne '-';
};
if ( defined $p1 ) {
if ( $p1 eq 'audit' ) {
set_action_param( 2, 'A_REJECT') unless defined( $p2 ) && $p2 ne '-';
set_action_param( 3, 'A_DROP') unless defined( $p3 ) && $p3 ne '-';
set_action_param( 4, 'A_ACCEPT' ) unless defined( $p4 ) && $p4 ne '-';
set_action_param( 5, 'A_DROP' ) unless defined( $p5 ) && $p5 ne '-';
} else {
fatal_error "Invalid value ($p1) for first Drop parameter" unless $p1 eq '-';
}
}
1;

View File

@ -39,12 +39,16 @@ my ( $p1, $p2, $p3 , $p4, $p5, $p6 ) = get_action_params( 6 );
fatal_error "Too many parameters to Reject" if defined $p6;
if ( defined $p1 && $p1 eq 'audit' ) {
set_action_param( 2, 'A_REJECT') unless defined( $p2 ) && $p2 ne '-';
set_action_param( 3, 'A_REJECT') unless defined( $p3 ) && $p3 ne '-';
set_action_param( 4, 'A_ACCEPT' ) unless defined( $p5 ) && $p4 ne '-';
set_action_param( 5, 'A_DROP' ) unless defined( $p5 ) && $p5 ne '-';
};
if ( defined $p1 ) {
if ( $p1 eq 'audit' ) {
set_action_param( 2, 'A_REJECT') unless defined( $p2 ) && $p2 ne '-';
set_action_param( 3, 'A_REJECT') unless defined( $p3 ) && $p3 ne '-';
set_action_param( 4, 'A_ACCEPT' ) unless defined( $p5 ) && $p4 ne '-';
set_action_param( 5, 'A_DROP' ) unless defined( $p5 ) && $p5 ne '-';
} else {
fatal_error "Invalid value ($p1) for first Reject parameter" unless $p1 eq '-';
}
}
1;