Make IP[6]TABLES transparent

Signed-off-by: Tom Eastep <teastep@shorewall.net>
This commit is contained in:
Tom Eastep
2016-01-04 13:10:03 -08:00
parent 89d91d37a1
commit 70a9240de6
7 changed files with 47 additions and 22 deletions

View File

@ -291,7 +291,8 @@ sub process_accounting_rule1( $$$$$$$$$$$ ) {
'' , '' ,
$target , $target ,
'' , '' ,
$disposition , $disposition ,
'' ,
'' ); '' );
} }
} }
@ -386,6 +387,7 @@ sub process_accounting_rule1( $$$$$$$$$$$ ) {
$target , $target ,
'' , '' ,
$disposition , $disposition ,
'' ,
'' ; '' ;
if ( $rule2 || $jump ) { if ( $rule2 || $jump ) {
@ -414,7 +416,8 @@ sub process_accounting_rule1( $$$$$$$$$$$ ) {
'' , '' ,
'' , '' ,
'' , '' ,
'' , '' ,
'' ,
'' ); '' );
} }

View File

@ -7428,7 +7428,7 @@ sub handle_exclusion( $$$$$$$$$$$$$$$$$$$$$ ) {
# #
# Returns the destination interface specified in the rule, if any. # Returns the destination interface specified in the rule, if any.
# #
sub expand_rule( $$$$$$$$$$$;$ ) sub expand_rule( $$$$$$$$$$$$;$ )
{ {
my ($chainref , # Chain my ($chainref , # Chain
$restriction, # Determines what to do with interface names in the SOURCE or DEST $restriction, # Determines what to do with interface names in the SOURCE or DEST
@ -7441,6 +7441,7 @@ sub expand_rule( $$$$$$$$$$$;$ )
$loglevel , # Log level (and tag) $loglevel , # Log level (and tag)
$disposition, # Primtive part of the target (RETURN, ACCEPT, ...) $disposition, # Primtive part of the target (RETURN, ACCEPT, ...)
$exceptionrule,# Caller's matches used in exclusion case $exceptionrule,# Caller's matches used in exclusion case
$usergenerated,# Rule came from the IP[6]TABLES target
$logname, # Name of chain to name in log messages $logname, # Name of chain to name in log messages
) = @_; ) = @_;
@ -7605,9 +7606,9 @@ sub expand_rule( $$$$$$$$$$$;$ )
my $cond3 = conditional_rule( $chainref, $dnet ); my $cond3 = conditional_rule( $chainref, $dnet );
if ( $loglevel eq '' ) { if ( $loglevel eq '' || $usergenerated ) {
# #
# No logging -- add the target rule with matches to the rule chain # No logging or user-specified logging -- add the target rule with matches to the rule chain
# #
if ( $targetref ) { if ( $targetref ) {
add_expanded_jump( $chainref, $targetref , 0, $matches ); add_expanded_jump( $chainref, $targetref , 0, $matches );

View File

@ -614,7 +614,8 @@ sub process_stoppedrules() {
$target, $target,
'', '',
$disposition, $disposition,
do_proto( $proto, '-', '-' ) ); do_proto( $proto, '-', '-' ),
'');
} }
} else { } else {
warning_message "Redundant OUTPUT rule ignored because ADMINISABSENTMINDED=Yes"; warning_message "Redundant OUTPUT rule ignored because ADMINISABSENTMINDED=Yes";

View File

@ -345,7 +345,8 @@ sub process_one_masq1( $$$$$$$$$$$ )
$target , $target ,
'' , '' ,
'' , '' ,
$exceptionrule ) $exceptionrule ,
'' )
unless unreachable_warning( 0, $chainref ); unless unreachable_warning( 0, $chainref );
conditional_rule_end( $chainref ) if $detectaddress || $conditional; conditional_rule_end( $chainref ) if $detectaddress || $conditional;
@ -795,7 +796,8 @@ sub handle_nat_rule( $$$$$$$$$$$$$ ) {
$target , $target ,
$loglevel , $loglevel ,
$log_action , $log_action ,
$serverport ? do_proto( $proto, '', '' ) : '', $serverport ? do_proto( $proto, '', '' ) : '' ,
'' ,
) )
unless unreachable_warning( $wildcard, $chainref ); unless unreachable_warning( $wildcard, $chainref );
@ -867,6 +869,7 @@ sub handle_nonat_rule( $$$$$$$$$$$ ) {
$loglevel, $loglevel,
$log_action, $log_action,
'', '',
'',
dnat_chain( $sourcezone ) ) dnat_chain( $sourcezone ) )
unless unreachable_warning( $wildcard, $chn ); unless unreachable_warning( $wildcard, $chn );
@ -888,6 +891,7 @@ sub handle_nonat_rule( $$$$$$$$$$$ ) {
$loglevel , $loglevel ,
$log_action , $log_action ,
'', '',
'',
) )
unless unreachable_warning( $wildcard, $nonat_chain ); unless unreachable_warning( $wildcard, $nonat_chain );
} }

View File

@ -98,6 +98,8 @@ sub process_conntrack_rule( $$$$$$$$$$ ) {
$action = join( ":" , 'LOG', $action ); $action = join( ":" , 'LOG', $action );
} }
my $usergenerated;
if ( $action eq 'NOTRACK' ) { if ( $action eq 'NOTRACK' ) {
# #
# A patch that deimplements the NOTRACK target has been posted on the # A patch that deimplements the NOTRACK target has been posted on the
@ -204,7 +206,8 @@ sub process_conntrack_rule( $$$$$$$$$$ ) {
$action , $action ,
$level || '' , $level || '' ,
$disposition , $disposition ,
$exception_rule ); $exception_rule ,
$usergenerated && ! $level );
progress_message " Conntrack rule \"$currentline\" $done"; progress_message " Conntrack rule \"$currentline\" $done";
} }
@ -247,6 +250,7 @@ sub handle_helper_rule( $$$$$$$$$$$ ) {
$action_target , $action_target ,
'', '',
'CT' , 'CT' ,
'' ,
'' ); '' );
} else { } else {
expand_rule( ensure_raw_chain( notrack_chain( $sourceref->{name} ) ) , expand_rule( ensure_raw_chain( notrack_chain( $sourceref->{name} ) ) ,
@ -261,6 +265,7 @@ sub handle_helper_rule( $$$$$$$$$$$ ) {
$action_target , $action_target ,
'' , '' ,
'CT' , 'CT' ,
'' ,
'' ); '' );
} }
} }

View File

@ -2264,6 +2264,7 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$$ ) {
my $matches = $rule; my $matches = $rule;
my $raw_matches = ''; my $raw_matches = '';
my $exceptionrule = ''; my $exceptionrule = '';
my $usergenerated;
if ( $inchain = defined $chainref ) { if ( $inchain = defined $chainref ) {
( $inaction, undef, undef, undef ) = split /:/, $normalized_action = $chainref->{action}, 4 if $chainref->{action}; ( $inaction, undef, undef, undef ) = split /:/, $normalized_action = $chainref->{action}, 4 if $chainref->{action};
@ -2287,6 +2288,8 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$$ ) {
fatal_error "Unknown ACTION ($action)" unless $actiontype; fatal_error "Unknown ACTION ($action)" unless $actiontype;
$usergenerated = $actiontype & IPTABLES;
if ( $actiontype == MACRO ) { if ( $actiontype == MACRO ) {
# #
# process_macro() will call process_rule() recursively for each rule in the macro body # process_macro() will call process_rule() recursively for each rule in the macro body
@ -2333,15 +2336,16 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$$ ) {
$param = $param eq '' ? 'drop' : $param; $param = $param eq '' ? 'drop' : $param;
fatal_error "Invalid AUDIT type ($param) -- must be 'accept', 'drop' or 'reject'" unless $param =~ /^(?:accept|drop|reject)$/; fatal_error "Invalid AUDIT type ($param) -- must be 'accept', 'drop' or 'reject'" unless $param =~ /^(?:accept|drop|reject)$/;
$actiontype = STANDARD; $actiontype = STANDARD;
} elsif ( $actiontype & NFLOG ) { } elsif ( ! $usergenerated ) {
validate_level( $action ); if ( $actiontype & NFLOG ) {
$loglevel = supplied $loglevel ? join( ':', $action, $loglevel ) : $action; validate_level( $action );
$action = 'LOG'; $loglevel = supplied $loglevel ? join( ':', $action, $loglevel ) : $action;
} elsif ( ! ( $actiontype & (ACTION | INLINE | IPTABLES | TARPIT ) ) ) { $action = 'LOG';
fatal_error "'builtin' actions may only be used in INLINE rules" if $actiontype == USERBUILTIN; } elsif ( ! ( $actiontype & (ACTION | INLINE | IPTABLES | TARPIT ) ) ) {
fatal_error "The $basictarget TARGET does not accept a parameter" unless $param eq ''; fatal_error "'builtin' actions may only be used in INLINE rules" if $actiontype == USERBUILTIN;
fatal_error "The $basictarget TARGET does not accept a parameter" unless $param eq '';
}
} }
# #
# We can now dispense with the postfix character # We can now dispense with the postfix character
# #
@ -2909,7 +2913,8 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$$ ) {
$action , $action ,
$loglevel , $loglevel ,
$log_action , $log_action ,
$exceptionrule ) $exceptionrule ,
$usergenerated && ! $loglevel )
unless unreachable_warning( $wildcard || $section == DEFAULTACTION_SECTION, $chainref ); unless unreachable_warning( $wildcard || $section == DEFAULTACTION_SECTION, $chainref );
} }

View File

@ -227,6 +227,7 @@ sub process_mangle_rule1( $$$$$$$$$$$$$$$$$ ) {
our $designator; our $designator;
our $ttl = 0; our $ttl = 0;
my $fw = firewall_zone; my $fw = firewall_zone;
my $usergenerated;
sub handle_mark_param( $$ ) { sub handle_mark_param( $$ ) {
my ( $option, $marktype ) = @_; my ( $option, $marktype ) = @_;
@ -290,7 +291,8 @@ sub process_mangle_rule1( $$$$$$$$$$$$$$$$$ ) {
"$target $option " . join( '/', in_hex( $markval ) , $mask ) , "$target $option " . join( '/', in_hex( $markval ) , $mask ) ,
'', '',
$target , $target ,
$exceptionrule ); $exceptionrule ,
'' );
} }
$done = 1; $done = 1;
@ -524,7 +526,8 @@ sub process_mangle_rule1( $$$$$$$$$$$$$$$$$ ) {
my $target_type = $builtin_target{$tgt}; my $target_type = $builtin_target{$tgt};
fatal_error "Unknown target ($tgt)" unless $target_type; fatal_error "Unknown target ($tgt)" unless $target_type;
fatal_error "The $tgt TARGET is not allowed in the mangle table" unless $target_type & MANGLE_TABLE; fatal_error "The $tgt TARGET is not allowed in the mangle table" unless $target_type & MANGLE_TABLE;
$target = $params; $target = $params;
$usergenerated = 1;
}, },
}, },
@ -539,7 +542,8 @@ sub process_mangle_rule1( $$$$$$$$$$$$$$$$$ ) {
my $target_type = $builtin_target{$tgt}; my $target_type = $builtin_target{$tgt};
fatal_error "Unknown target ($tgt)" unless $target_type; fatal_error "Unknown target ($tgt)" unless $target_type;
fatal_error "The $tgt TARGET is not allowed in the mangle table" unless $target_type & MANGLE_TABLE; fatal_error "The $tgt TARGET is not allowed in the mangle table" unless $target_type & MANGLE_TABLE;
$target = $params; $target = $params;
$usergenerated = 1;
}, },
}, },
@ -850,7 +854,8 @@ sub process_mangle_rule1( $$$$$$$$$$$$$$$$$ ) {
$target, $target,
'' , '' ,
$target , $target ,
$exceptionrule ) ) $exceptionrule ,
$usergenerated ) )
&& $device ) { && $device ) {
# #
# expand_rule() returns destination device if any # expand_rule() returns destination device if any
@ -3118,6 +3123,7 @@ sub process_secmark_rule1( $$$$$$$$$ ) {
$target , $target ,
'' , '' ,
$disposition, $disposition,
'' ,
'' ); '' );
progress_message "Secmarks rule \"$currentline\" $done"; progress_message "Secmarks rule \"$currentline\" $done";