forked from extern/shorewall_code
Revert non-fatal error implementation
- In the end, I didn't like the way this worked. Signed-off-by: Tom Eastep <teastep@shorewall.net>
This commit is contained in:
parent
303dc65d13
commit
09a6f8bc16
@ -811,10 +811,6 @@ sub compiler {
|
|||||||
# Accounting.
|
# Accounting.
|
||||||
#
|
#
|
||||||
setup_accounting if $config{ACCOUNTING};
|
setup_accounting if $config{ACCOUNTING};
|
||||||
#
|
|
||||||
# Bail out now if errors
|
|
||||||
#
|
|
||||||
exit_if_errors;
|
|
||||||
|
|
||||||
if ( $scriptfilename ) {
|
if ( $scriptfilename ) {
|
||||||
#
|
#
|
||||||
|
@ -35,18 +35,17 @@ use warnings;
|
|||||||
use File::Basename;
|
use File::Basename;
|
||||||
use File::Temp qw/ tempfile tempdir /;
|
use File::Temp qw/ tempfile tempdir /;
|
||||||
use Cwd qw(abs_path getcwd);
|
use Cwd qw(abs_path getcwd);
|
||||||
use autouse 'Carp' => qw(longmess confess cluck);
|
use autouse 'Carp' => qw(longmess confess);
|
||||||
use Scalar::Util 'reftype';
|
use Scalar::Util 'reftype';
|
||||||
use FindBin;
|
use FindBin;
|
||||||
|
|
||||||
our @ISA = qw(Exporter);
|
our @ISA = qw(Exporter);
|
||||||
#
|
#
|
||||||
# Imported variables should be treated as read-only by
|
# Imported variables should be treated as read-only by importers
|
||||||
|
#
|
||||||
our @EXPORT = qw(
|
our @EXPORT = qw(
|
||||||
warning_message
|
warning_message
|
||||||
fatal_error
|
fatal_error
|
||||||
nonfatal_error
|
|
||||||
exit_if_errors
|
|
||||||
assert
|
assert
|
||||||
|
|
||||||
progress_message
|
progress_message
|
||||||
@ -558,8 +557,6 @@ use constant { PLAIN_READ => 0, # No read_a_line options
|
|||||||
NORMAL_READ => -1 # All options
|
NORMAL_READ => -1 # All options
|
||||||
};
|
};
|
||||||
|
|
||||||
my $errors;
|
|
||||||
|
|
||||||
sub process_shorewallrc($);
|
sub process_shorewallrc($);
|
||||||
#
|
#
|
||||||
# Rather than initializing globals in an INIT block or during declaration,
|
# Rather than initializing globals in an INIT block or during declaration,
|
||||||
@ -598,7 +595,6 @@ sub initialize( $;$ ) {
|
|||||||
$ifstack = 0;
|
$ifstack = 0;
|
||||||
@ifstack = ();
|
@ifstack = ();
|
||||||
$embedded = 0;
|
$embedded = 0;
|
||||||
$errors = 0;
|
|
||||||
#
|
#
|
||||||
# Misc Globals
|
# Misc Globals
|
||||||
#
|
#
|
||||||
@ -1111,9 +1107,9 @@ sub fatal_error {
|
|||||||
printf $log '%s %2d %02d:%02d:%02d ', $abbr[$localtime[4]], @localtime[3,2,1,0];
|
printf $log '%s %2d %02d:%02d:%02d ', $abbr[$localtime[4]], @localtime[3,2,1,0];
|
||||||
|
|
||||||
if ( $confess ) {
|
if ( $confess ) {
|
||||||
print $log longmess( " FATAL ERROR: @_$currentlineinfo\n" );
|
print $log longmess( " ERROR: @_$currentlineinfo\n" );
|
||||||
} else {
|
} else {
|
||||||
print $log " FATAL ERROR: @_$currentlineinfo\n";
|
print $log " ERROR: @_$currentlineinfo\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
close $log;
|
close $log;
|
||||||
@ -1126,8 +1122,8 @@ sub fatal_error {
|
|||||||
confess "@_$currentlineinfo" if $confess;
|
confess "@_$currentlineinfo" if $confess;
|
||||||
die "@_$currentlineinfo\n";
|
die "@_$currentlineinfo\n";
|
||||||
} else {
|
} else {
|
||||||
confess " FATAL ERROR: @_$currentlineinfo" if $confess;
|
confess " ERROR: @_$currentlineinfo" if $confess;
|
||||||
die " FATAL ERROR: @_$currentlineinfo\n";
|
die " ERROR: @_$currentlineinfo\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1139,9 +1135,9 @@ sub fatal_error1 {
|
|||||||
printf $log '%s %2d %02d:%02d:%02d ', $abbr[$localtime[4]], @localtime[3,2,1,0];
|
printf $log '%s %2d %02d:%02d:%02d ', $abbr[$localtime[4]], @localtime[3,2,1,0];
|
||||||
|
|
||||||
if ( $debug ) {
|
if ( $debug ) {
|
||||||
print $log longmess( " FATAL ERROR: @_\n" );
|
print $log longmess( " ERROR: @_\n" );
|
||||||
} else {
|
} else {
|
||||||
print $log " FATAL ERROR: @_\n";
|
print $log " ERROR: @_\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
close $log;
|
close $log;
|
||||||
@ -1149,65 +1145,8 @@ sub fatal_error1 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cleanup;
|
cleanup;
|
||||||
confess " FATAL ERROR: @_" if $debug;
|
confess " ERROR: @_" if $debug;
|
||||||
die " FATAL ERROR: @_\n";
|
die " ERROR: @_\n";
|
||||||
}
|
|
||||||
|
|
||||||
#
|
|
||||||
# Issue non-fatal error message and die
|
|
||||||
#
|
|
||||||
sub nonfatal_error {
|
|
||||||
|
|
||||||
fatal_error @_ unless $command eq 'check';
|
|
||||||
|
|
||||||
my $currentlineinfo = currentlineinfo;
|
|
||||||
|
|
||||||
$| = 1; #Reset output buffering (flush any partially filled buffers).
|
|
||||||
|
|
||||||
if ( $log ) {
|
|
||||||
our @localtime = localtime;
|
|
||||||
printf $log '%s %2d %02d:%02d:%02d ', $abbr[$localtime[4]], @localtime[3,2,1,0];
|
|
||||||
|
|
||||||
if ( $confess ) {
|
|
||||||
print $log longmess( " ERROR: @_$currentlineinfo\n" );
|
|
||||||
} else {
|
|
||||||
print $log " ERROR: @_$currentlineinfo\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( $confess ) {
|
|
||||||
cluck " ERROR: @_$currentlineinfo";
|
|
||||||
} else {
|
|
||||||
print STDERR " ERROR: @_$currentlineinfo\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
$errors++;
|
|
||||||
|
|
||||||
$| = 0;
|
|
||||||
|
|
||||||
0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#
|
|
||||||
# Check for errors
|
|
||||||
#
|
|
||||||
sub exit_if_errors() {
|
|
||||||
if ( $errors ) {
|
|
||||||
$| = 1; #Reset output buffering (flush any partially filled buffers).
|
|
||||||
|
|
||||||
if ( $log ) {
|
|
||||||
our @localtime = localtime;
|
|
||||||
printf $log '%s %2d %02d:%02d:%02d ', $abbr[$localtime[4]], @localtime[3,2,1,0];
|
|
||||||
print $log "Check aborted -- $errors errors detected\n";
|
|
||||||
|
|
||||||
close $log;
|
|
||||||
$log = undef;
|
|
||||||
}
|
|
||||||
|
|
||||||
cleanup;
|
|
||||||
|
|
||||||
die "Check aborted -- $errors errors detected\n";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -3778,10 +3717,7 @@ sub determine_capabilities() {
|
|||||||
sub require_capability( $$$ ) {
|
sub require_capability( $$$ ) {
|
||||||
my ( $capability, $description, $singular ) = @_;
|
my ( $capability, $description, $singular ) = @_;
|
||||||
|
|
||||||
unless ( have_capability $capability ) {
|
fatal_error "$description require${singular} $capdesc{$capability} in your kernel and iptables" unless have_capability $capability;
|
||||||
nonfatal_error "$description require${singular} $capdesc{$capability} in your kernel and iptables";
|
|
||||||
$capabilities{$capability} = 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
|
Loading…
Reference in New Issue
Block a user