Rationalize error message WRT $line

git-svn-id: https://shorewall.svn.sourceforge.net/svnroot/shorewall/trunk@5753 fbd18981-670d-0410-9b5c-8dc0c1a9a2bb
This commit is contained in:
teastep 2007-03-30 02:05:11 +00:00
parent ab3d55514e
commit 7b0b1e092c
13 changed files with 41 additions and 41 deletions

View File

@ -45,7 +45,7 @@ sub process_accounting_rule( $$$$$$$$ ) {
my ($action, $chain, $source, $dest, $proto, $ports, $sports, $user ) = @_; my ($action, $chain, $source, $dest, $proto, $ports, $sports, $user ) = @_;
sub accounting_error() { sub accounting_error() {
warning_message "Invalid Accounting rule \"$line\""; warning_message "Invalid Accounting rule";
} }
sub jump_to_chain( $ ) { sub jump_to_chain( $ ) {

View File

@ -289,7 +289,7 @@ sub process_actions1() {
if ( defined $targettype ) { if ( defined $targettype ) {
next if ( $targettype == STANDARD ) || ( $targettype == MACRO ) || ( $target eq 'LOG' ); next if ( $targettype == STANDARD ) || ( $targettype == MACRO ) || ( $target eq 'LOG' );
fatal_error "Invalid TARGET ($target) in action rule \"$line\"" if $targettype & STANDARD; fatal_error "Invalid TARGET ($target)" if $targettype & STANDARD;
add_requiredby $wholetarget, $action if $targettype & ACTION; add_requiredby $wholetarget, $action if $targettype & ACTION;
} else { } else {
@ -311,7 +311,7 @@ sub process_actions1() {
$targettype = 0 unless defined $targettype; $targettype = 0 unless defined $targettype;
fatal_error "Invalid target ($mtarget) in rule \"$line\"" fatal_error "Invalid target ($mtarget)"
unless ( $targettype == STANDARD ) || ( $mtarget eq 'PARAM' ) || ( $mtarget eq 'LOG' ); unless ( $targettype == STANDARD ) || ( $mtarget eq 'PARAM' ) || ( $mtarget eq 'LOG' );
} }
@ -319,7 +319,7 @@ sub process_actions1() {
pop_open; pop_open;
} else { } else {
fatal_error "Invalid TARGET ($target) in rule \"$line\""; fatal_error "Invalid TARGET ($target)";
} }
} }
} }

View File

@ -305,7 +305,7 @@ END {
unlink $tempfile; unlink $tempfile;
} }
my $exitstatus = $?; #Get's changed by system() my $exitstatus = $?; #Changed by system()
system "rm -rf $ENV{TMP_DIR}" if $ENV{TMP_DIR}; system "rm -rf $ENV{TMP_DIR}" if $ENV{TMP_DIR};

View File

@ -509,7 +509,7 @@ sub get_configuration() {
$capabilities{$var} = $val =~ /^\"([^\"]*)\"$/ ? $1 : $val; $capabilities{$var} = $val =~ /^\"([^\"]*)\"$/ ? $1 : $val;
} else { } else {
fatal_error "Unrecognized entry in $file: $line"; fatal_error "Unrecognized entry";
} }
} }

View File

@ -66,7 +66,7 @@ sub find_macro( $ )
sub split_action ( $ ) { sub split_action ( $ ) {
my $action = $_[0]; my $action = $_[0];
my @a = split /:/ , $action; my @a = split /:/ , $action;
fatal_error "Invalid ACTION $action in rule \"$line\"" if ( $action =~ /::/ ) || ( @a > 3 ); fatal_error "Invalid ACTION ($action)" if ( $action =~ /::/ ) || ( @a > 3 );
( shift @a, join ":", @a ); ( shift @a, join ":", @a );
} }

View File

@ -150,7 +150,7 @@ sub setup_one_masq($$$$$$)
# #
( my $interface = $fullinterface ) =~ s/:.*//; ( my $interface = $fullinterface ) =~ s/:.*//;
fatal_error "Unknown interface $interface, rule \"$line\"" unless $interfaces{$interface}{root}; fatal_error "Unknown interface ($interface)" unless $interfaces{$interface}{root};
my $chainref = ensure_chain('nat', $pre_nat ? snat_chain $interface : masq_chain $interface); my $chainref = ensure_chain('nat', $pre_nat ? snat_chain $interface : masq_chain $interface);
# #
@ -280,7 +280,7 @@ sub validate_nat_column( $$ ) {
if ( ( $val eq 'no' ) || ( $val eq '-' ) ) { if ( ( $val eq 'no' ) || ( $val eq '-' ) ) {
$$ref = ''; $$ref = '';
} else { } else {
fatal_error "Invalid value ($val) for $_[0] in NAT entry \"$line\""; fatal_error "Invalid value ($val) for $_[0]";
} }
} }
} else { } else {
@ -311,7 +311,7 @@ sub do_one_nat( $$$$$ )
$policyout = '-m policy --pol none --dir out'; $policyout = '-m policy --pol none --dir out';
} }
fatal_error "Invalid nat file entry \"$line\"" unless defined $interface && defined $internal; fatal_error "Invalid nat file entry" unless defined $interface && defined $internal;
if ( $add_ip_aliases ) { if ( $add_ip_aliases ) {
if ( $interface =~ s/:$// ) { if ( $interface =~ s/:$// ) {
@ -406,7 +406,7 @@ sub setup_netmap() {
} elsif ( $type eq 'SNAT' ) { } elsif ( $type eq 'SNAT' ) {
add_rule ensure_chain( 'nat' , output_chain $interface ) , "-s $net1 -j NETMAP --to $net2"; add_rule ensure_chain( 'nat' , output_chain $interface ) , "-s $net1 -j NETMAP --to $net2";
} else { } else {
fatal_error "Invalid type $type in netmap entry \"$line\""; fatal_error "Invalid type ($type)";
} }
progress_message " Network $net1 on $interface mapped to $net2 ($type)"; progress_message " Network $net1 on $interface mapped to $net2 ($type)";

View File

@ -160,7 +160,7 @@ sub validate_policy()
createactionchain $default; createactionchain $default;
} }
} else { } else {
fatal_error "Unknown Default Action ($default) in policy \"$line\""; fatal_error "Unknown Default Action ($default)";
} }
} else { } else {
$default = $default_actions{$policy} || ''; $default = $default_actions{$policy} || '';

View File

@ -241,7 +241,7 @@ sub setup_providers() {
for my $option ( split /,/, $options ) { for my $option ( split /,/, $options ) {
if ( $option eq 'track' ) { if ( $option eq 'track' ) {
fatal_error "Interface $interface is tracked through an earlier provider" if $routemarked_interfaces{$interface}; fatal_error "Interface $interface is tracked through an earlier provider" if $routemarked_interfaces{$interface};
fatal_error "The 'track' option requires a numeric value in the MARK column - Provider \"$line\"" if $mark eq '-'; fatal_error "The 'track' option requires a numeric value in the MARK column" if $mark eq '-';
$routemarked_interfaces{$interface} = $mark; $routemarked_interfaces{$interface} = $mark;
push @routemarked_interfaces, $interface; push @routemarked_interfaces, $interface;
} elsif ( $option =~ /^balance=(\d+)/ ) { } elsif ( $option =~ /^balance=(\d+)/ ) {
@ -253,7 +253,7 @@ sub setup_providers() {
} elsif ( $option eq 'optional' ) { } elsif ( $option eq 'optional' ) {
$optional = 1; $optional = 1;
} else { } else {
fatal_error "Invalid option ($option) in provider \"$line\""; fatal_error "Invalid option ($option)";
} }
} }
} }
@ -310,13 +310,13 @@ sub setup_providers() {
} }
} }
fatal_error "Unknown provider $provider in route rule \"$line\"" unless $found; fatal_error "Unknown provider ($provider)" unless $found;
} }
$source = '-' unless $source; $source = '-' unless $source;
$dest = '-' unless $dest; $dest = '-' unless $dest;
fatal_error "You must specify either the source or destination in an rt rule: \"$line\"" if $source eq '-' && $dest eq '-'; fatal_error "You must specify either the source or destination in a route_rules entry" if $source eq '-' && $dest eq '-';
$dest = $dest eq '-' ? '' : "to $dest"; $dest = $dest eq '-' ? '' : "to $dest";
@ -331,7 +331,7 @@ sub setup_providers() {
$source = "iif $source"; $source = "iif $source";
} }
fatal_error "Invalid priority ($priority) in rule \"$line\"" unless $priority && $priority =~ /^\d{1,5}$/; fatal_error "Invalid priority ($priority)" unless $priority && $priority =~ /^\d{1,5}$/;
$priority = "priority $priority"; $priority = "priority $priority";

View File

@ -48,7 +48,7 @@ sub setup_one_proxy_arp( $$$$$ ) {
} elsif ( "\L$haveroute" eq 'yes' ) { } elsif ( "\L$haveroute" eq 'yes' ) {
$haveroute = 'yes'; $haveroute = 'yes';
} else { } else {
fatal_error "Invalid value ($haveroute) for HAVEROUTE in Proxy Arp Entry \"$line\""; fatal_error "Invalid value ($haveroute) for HAVEROUTE";
} }
if ( "\L$persistent" eq 'no' || $persistent eq '-' ) { if ( "\L$persistent" eq 'no' || $persistent eq '-' ) {
@ -56,7 +56,7 @@ sub setup_one_proxy_arp( $$$$$ ) {
} elsif ( "\L$persistent" eq 'yes' ) { } elsif ( "\L$persistent" eq 'yes' ) {
$persistent = 'yes'; $persistent = 'yes';
} else { } else {
fatal_error "Invalid value ($persistent) for PERSISTENT in Proxy Arp Entry \"$line\""; fatal_error "Invalid value ($persistent) for PERSISTENT";
} }
unless ( $haveroute ) { unless ( $haveroute ) {

View File

@ -80,7 +80,7 @@ sub process_tos() {
$first_entry = 0; $first_entry = 0;
} }
fatal_error "TOS field required: $line" unless $tos ne '-'; fatal_error "TOS field required" unless $tos ne '-';
my $chainref; my $chainref;
@ -135,7 +135,7 @@ sub setup_ecn()
my ($interface, $hosts ) = split_line 2, 'ecn file'; my ($interface, $hosts ) = split_line 2, 'ecn file';
fatal_error "Unknown interface ( $interface ) in ECN entry \"$line\"" unless known_interface $interface; fatal_error "Unknown interface ( $interface )" unless known_interface $interface;
$interfaces{$interface} = 1; $interfaces{$interface} = 1;
@ -336,7 +336,7 @@ sub process_criticalhosts() {
if ( $option eq 'critical' ) { if ( $option eq 'critical' ) {
push @critical, @hosts; push @critical, @hosts;
} else { } else {
warning_message "Unknown routestopped option ( $option ) ignored in routestopped entry \"$line\""; warning_message "Unknown routestopped option ( $option ) ignored";
} }
} }
} }
@ -373,7 +373,7 @@ sub process_routestopped() {
for my $option (split /,/, $options ) { for my $option (split /,/, $options ) {
if ( $option eq 'routeback' ) { if ( $option eq 'routeback' ) {
if ( $routeback ) { if ( $routeback ) {
warning_message "Duplicate 'routeback' option ignored in routestopped entry \"$line\""; warning_message "Duplicate 'routeback' option ignored";
} else { } else {
$routeback = 1; $routeback = 1;
@ -393,7 +393,7 @@ sub process_routestopped() {
$dest{"$interface:$host"} = 1; $dest{"$interface:$host"} = 1;
} }
} else { } else {
warning_message "Unknown routestopped option ( $option ) ignored in routestopped entry \"$line\"" unless $option eq 'critical'; warning_message "Unknown routestopped option ( $option ) ignored" unless $option eq 'critical';
} }
} }
} }
@ -657,9 +657,9 @@ sub setup_mac_lists( $ ) {
my $targetref = $maclist_targets{$disposition}; my $targetref = $maclist_targets{$disposition};
fatal_error "Invalid DISPOSITION ( $disposition) in rule \"$line\"" if ( $table eq 'mangle' ) && ! $targetref->{mangle}; fatal_error "Invalid DISPOSITION ( $disposition)" if ( $table eq 'mangle' ) && ! $targetref->{mangle};
fatal_error "No hosts on $interface have the maclist option specified: \"$line\"" unless $maclist_interfaces{$interface}; fatal_error "No hosts on $interface have the maclist option specified" unless $maclist_interfaces{$interface};
my $chainref = $chain_table{$table}{( $config{MACLIST_TTL} ? macrecent_target $interface : mac_chain $interface )}; my $chainref = $chain_table{$table}{( $config{MACLIST_TTL} ? macrecent_target $interface : mac_chain $interface )};
@ -770,7 +770,7 @@ sub process_macro ( $$$$$$$$$$$ ) {
$mtarget = find_logactionchain $mtarget; $mtarget = find_logactionchain $mtarget;
} else { } else {
fatal_error "Invalid Action ($mtarget) in rule \"$line\"" unless $actiontype & STANDARD; fatal_error "Invalid Action ($mtarget)" unless $actiontype & STANDARD;
} }
if ( $msource ) { if ( $msource ) {
@ -831,7 +831,7 @@ sub process_rule1 ( $$$$$$$$$ ) {
# #
my $actiontype = $targets{$basictarget} || find_macro( $basictarget ); my $actiontype = $targets{$basictarget} || find_macro( $basictarget );
fatal_error "Unknown action ($action) in rule \"$line\"" unless $actiontype; fatal_error "Unknown action ($action)" unless $actiontype;
if ( $actiontype == MACRO ) { if ( $actiontype == MACRO ) {
# #
@ -900,8 +900,8 @@ sub process_rule1 ( $$$$$$$$$ ) {
$dest = ALLIPv4; $dest = ALLIPv4;
} }
fatal_error "Unknown source zone ($sourcezone) in rule \"$line\"" unless $zones{$sourcezone}; fatal_error "Unknown source zone ($sourcezone)" unless $zones{$sourcezone};
fatal_error "Unknown destination zone ($destzone) in rule \"$line\"" unless $zones{$destzone}; fatal_error "Unknown destination zone ($destzone)" unless $zones{$destzone};
my $restriction = NO_RESTRICT; my $restriction = NO_RESTRICT;
@ -920,7 +920,7 @@ sub process_rule1 ( $$$$$$$$$ ) {
# #
my $policy = $chainref->{policy}; my $policy = $chainref->{policy};
fatal_error "No policy defined from zone $sourcezone to zone $destzone" unless $policy; fatal_error "No policy defined from zone $sourcezone to zone $destzone" unless $policy;
fatal_error "Rules may not override a NONE policy: rule \"$line\"" if $policy eq 'NONE'; fatal_error "Rules may not override a NONE policy" if $policy eq 'NONE';
# #
# Generate Fixed part of the rule # Generate Fixed part of the rule
# #
@ -948,8 +948,8 @@ sub process_rule1 ( $$$$$$$$$ ) {
# #
$ports = $serverport if $serverport; $ports = $serverport if $serverport;
fatal_error "A server must be specified in the DEST column in $action rules: \"$line\"" unless ( $actiontype & REDIRECT ) || $server; fatal_error "A server must be specified in the DEST column in $action rules" unless ( $actiontype & REDIRECT ) || $server;
fatal_error "Invalid server ($server), rule: \"$line\"" if $server =~ /:/; fatal_error "Invalid server ($server)" if $server =~ /:/;
# #
# Generate the target # Generate the target
# #
@ -1015,7 +1015,7 @@ sub process_rule1 ( $$$$$$$$$ ) {
# #
# NONAT or ACCEPT+ -- May not specify a destination interface # NONAT or ACCEPT+ -- May not specify a destination interface
# #
fatal_error "Invalid DEST ($dest) in $action rule \"$line\"" if $dest =~ /:/; fatal_error "Invalid DEST ($dest) in $action rule" if $dest =~ /:/;
$origdest = '' unless $origdest and $origdest ne '-'; $origdest = '' unless $origdest and $origdest ne '-';

View File

@ -145,7 +145,7 @@ sub process_tc_rule( $$$$$$$$$$ ) {
if ( $tcsref ) { if ( $tcsref ) {
if ( $chain eq 'tcout' ) { if ( $chain eq 'tcout' ) {
fatal_error "Invalid chain designator for source $firewall_zone; rule \"$line\"" unless $tcsref->{fw}; fatal_error "Invalid chain designator for source $firewall_zone" unless $tcsref->{fw};
} }
$chain = $tcsref->{chain} if $tcsref->{chain}; $chain = $tcsref->{chain} if $tcsref->{chain};

View File

@ -45,7 +45,7 @@ sub setup_tunnels() {
( $kind, my $qualifier ) = split /:/, $kind; ( $kind, my $qualifier ) = split /:/, $kind;
fatal_error "Invalid IPSEC modifier ($qualifier) in tunnel \"$line\"" if $qualifier && ( $qualifier ne 'noah' ); fatal_error "Invalid IPSEC modifier ($qualifier)" if $qualifier && ( $qualifier ne 'noah' );
my $noah = $qualifier || ($kind ne 'ipsec' ); my $noah = $qualifier || ($kind ne 'ipsec' );
@ -69,7 +69,7 @@ sub setup_tunnels() {
} }
for my $zone ( split /,/, $gatewayzones ) { for my $zone ( split /,/, $gatewayzones ) {
fatal_error "Invalid zone ($zone) in tunnel \"$line\"" unless $zones{$zone}{type} eq 'ipv4'; fatal_error "Invalid zone ($zone)" unless $zones{$zone}{type} eq 'ipv4';
$inchainref = ensure_filter_chain "${zone}2${firewall_zone}", 1; $inchainref = ensure_filter_chain "${zone}2${firewall_zone}", 1;
$outchainref = ensure_filter_chain "${firewall_zone}2${zone}", 1; $outchainref = ensure_filter_chain "${firewall_zone}2${zone}", 1;
@ -194,7 +194,7 @@ sub setup_tunnels() {
sub setup_one_tunnel($$$$) { sub setup_one_tunnel($$$$) {
my ( $kind , $zone, $gateway, $gatewayzones ) = @_; my ( $kind , $zone, $gateway, $gatewayzones ) = @_;
fatal_error "Invalid zone ($zone) in tunnel \"$line\"" unless $zones{$zone}{type} eq 'ipv4'; fatal_error "Invalid zone ($zone)" unless $zones{$zone}{type} eq 'ipv4';
my $inchainref = ensure_filter_chain "${zone}2${firewall_zone}", 1; my $inchainref = ensure_filter_chain "${zone}2${firewall_zone}", 1;
my $outchainref = ensure_filter_chain "${firewall_zone}2${zone}", 1; my $outchainref = ensure_filter_chain "${firewall_zone}2${zone}", 1;
@ -221,7 +221,7 @@ sub setup_tunnels() {
my $tunnelref = $tunneltypes{ $type }; my $tunnelref = $tunneltypes{ $type };
fatal_error "Tunnels of type $type are not supported: Tunnel \"$line\"" unless $tunnelref; fatal_error "Tunnels of type $type are not supported" unless $tunnelref;
$tunnelref->{function}->( $inchainref, $outchainref, @{$tunnelref->{params}} ); $tunnelref->{function}->( $inchainref, $outchainref, @{$tunnelref->{params}} );

View File

@ -153,9 +153,9 @@ sub parse_zone_option_list($)
fatal_error "Invalid Option ($e)" unless $fmt; fatal_error "Invalid Option ($e)" unless $fmt;
if ( $fmt eq NOTHING ) { if ( $fmt eq NOTHING ) {
fatal_error "Option $e does not take a value: Zone \"$line\"" if defined $val; fatal_error "Option $e does not take a value" if defined $val;
} else { } else {
fatal_error "Invalid value ($val) for option \"$e\" in Zone \"$line\"" unless $val =~ /^($fmt)$/; fatal_error "Invalid value ($val) for option \"$e\"" unless $val =~ /^($fmt)$/;
} }
if ( $key{$e} ) { if ( $key{$e} ) {