diff --git a/Shorewall/Perl/Shorewall/Compiler.pm b/Shorewall/Perl/Shorewall/Compiler.pm index 2666cded1..f23ddae02 100644 --- a/Shorewall/Perl/Shorewall/Compiler.pm +++ b/Shorewall/Perl/Shorewall/Compiler.pm @@ -523,8 +523,8 @@ EOF # sub compiler { - my ( $scriptfilename, $directory, $verbosity, $timestamp , $debug, $chains , $log , $log_verbosity, $preview ) = - ( '', '', -1, '', 0, '', '', -1, 0 ); + my ( $scriptfilename, $directory, $verbosity, $timestamp , $debug, $chains , $log , $log_verbosity, $preview, $confess ) = + ( '', '', -1, '', 0, '', '', -1, 0, 0 ); $export = 0; $test = 0; @@ -557,6 +557,7 @@ sub compiler { log_verbosity => { store => \$log_verbosity, validate => \&validate_verbosity } , test => { store => \$test }, preview => { store => \$preview }, + confess => { store => \$confess }, ); # # P A R A M E T E R P R O C E S S I N G @@ -586,7 +587,7 @@ sub compiler { set_verbosity( $verbosity ); set_log($log, $log_verbosity) if $log; set_timestamp( $timestamp ); - set_debug( $debug ); + set_debug( $debug , $confess ); # # S H O R E W A L L . C O N F A N D C A P A B I L I T I E S # diff --git a/Shorewall/Perl/Shorewall/Config.pm b/Shorewall/Perl/Shorewall/Config.pm index 4839b7cd3..26eba7d68 100644 --- a/Shorewall/Perl/Shorewall/Config.pm +++ b/Shorewall/Perl/Shorewall/Config.pm @@ -352,7 +352,8 @@ my $first_entry; # Message to output or function to call on first no my $shorewall_dir; # Shorewall Directory; if non-empty, search here first for files. -our $debug; # If true, use Carp to report errors with stack trace. +our $debug; # Global debugging flag +my $confess; # If true, use Carp to report errors with stack trace. our $family; # Protocol family (4 or 6) our $toolname; # Name of the tool to use (iptables or iptables6) @@ -655,6 +656,7 @@ sub initialize( $ ) { $shorewall_dir = ''; #Shorewall Directory $debug = 0; + $confess = 0; %params = ( root => '', system => '', @@ -700,7 +702,7 @@ sub warning_message printf $log '%s %2d %02d:%02d:%02d ', $abbr[$localtime[4]], @localtime[3,2,1,0]; } - if ( $debug ) { + if ( $confess ) { print STDERR longmess( " WARNING: @_$currentlineinfo" ); print $log longmess( " WARNING: @_$currentlineinfo\n" ) if $log; } else { @@ -754,7 +756,7 @@ sub fatal_error { our @localtime = localtime; printf $log '%s %2d %02d:%02d:%02d ', $abbr[$localtime[4]], @localtime[3,2,1,0]; - if ( $debug ) { + if ( $confess ) { print $log longmess( " ERROR: @_$currentlineinfo\n" ); } else { print $log " ERROR: @_$currentlineinfo\n"; @@ -765,7 +767,7 @@ sub fatal_error { } cleanup; - confess " ERROR: @_$currentlineinfo" if $debug; + confess " ERROR: @_$currentlineinfo" if $confess; die " ERROR: @_$currentlineinfo\n"; } @@ -1222,8 +1224,10 @@ sub set_config_path( $ ) { # # Set $debug # -sub set_debug( $ ) { - $debug = shift; +sub set_debug( $$ ) { + $debug = shift; + $confess = shift; + $confess ||= $debug; } # diff --git a/Shorewall/Perl/compiler.pl b/Shorewall/Perl/compiler.pl index 70e456658..08bba4075 100755 --- a/Shorewall/Perl/compiler.pl +++ b/Shorewall/Perl/compiler.pl @@ -54,6 +54,7 @@ sub usage( $ ) { [ --verbose={-1|0-2} ] [ --timestamp ] [ --debug ] + [ --confess ] [ --refresh= ] [ --log= ] [ --log-verbose={-1|0-2} ] @@ -73,6 +74,7 @@ my $shorewall_dir = ''; my $verbose = 0; my $timestamp = 0; my $debug = 0; +my $confess = 0; my $chains = ':none:'; my $log = ''; my $log_verbose = 0; @@ -103,6 +105,8 @@ my $result = GetOptions('h' => \$help, 'preview' => \$preview, 'f=i' => \$family, 'family=i' => \$family, + 'c' => \$confess, + 'confess' => \$confess, ); usage(1) unless $result && @ARGV < 2; @@ -119,4 +123,6 @@ compiler( script => $ARGV[0] || '', log_verbosity => $log_verbose, test => $test, preview => $preview, - family => $family ); + family => $family, + confess => $confess, + ); diff --git a/Shorewall/shorewall b/Shorewall/shorewall index 988562684..db3fe8faa 100755 --- a/Shorewall/shorewall +++ b/Shorewall/shorewall @@ -379,6 +379,7 @@ compiler() { [ -n "$g_preview" ] && options="$options --preview" [ "$g_debugging" = trace ] && options="$options --debug" [ -n "$g_refreshchains" ] && options="$options --refresh=$g_refreshchains" + [ -n "$g_confess" ] && options="$options --confess" if [ -n "$PERL" ]; then if [ ! -x "$PERL" ]; then @@ -575,6 +576,10 @@ compile_command() { g_debug=Yes; option=${option#d} ;; + T*) + g_confess=Yes + option=${option#T} + ;; -) finished=1 option= @@ -657,9 +662,13 @@ check_command() { option=${option#d} ;; r*) - g_preview=Yes; + g_preview=Yes option=${option#r} ;; + T*) + g_confess=Yes + option=${option#T} + ;; *) usage 1 ;; @@ -1504,6 +1513,7 @@ g_use_verbosity= g_debug= g_export= g_refreshchains=:none: +g_confess= # # Make sure that these variables are cleared diff --git a/Shorewall6/shorewall6 b/Shorewall6/shorewall6 index 2a580282d..ad1624bf5 100755 --- a/Shorewall6/shorewall6 +++ b/Shorewall6/shorewall6 @@ -379,6 +379,7 @@ compiler() { [ -n "$g_preview" ] && options="$options --preview" [ "$g_debugging" = trace ] && options="$options --debug" [ -n "$g_refreshchains" ] && options="$options --refresh=$g_refreshchains" + [ -n "$g_confess" ] && options="$options --confess" [ -x $pc ] || startup_error "Shorewall6 requires the shorewall package which is not installed" if [ -n "$PERL" ]; then @@ -576,6 +577,10 @@ compile_command() { g_debug=Yes; option=${option#d} ;; + T*) + g_confess=Yes + option=${option#T} + ;; -) finished=1 option= @@ -658,9 +663,13 @@ check_command() { option=${option#d} ;; r*) - g_preview=Yes; + g_preview=Yes option=${option#r} ;; + T*) + g_confess=Yes + option=${option#T} + ;; *) usage 1 ;; @@ -1499,6 +1508,7 @@ g_use_verbosity= g_debug= g_export= g_refreshchains=:none: +g_confess= # # Make sure that these variables are cleared