forked from extern/shorewall_code
A more uniform way of handling $max_format
Signed-off-by: Tom Eastep <teastep@shorewall.net>
This commit is contained in:
parent
6c1369a5a8
commit
e4e61c4193
@ -1918,7 +1918,7 @@ sub do_open_file( $ ) {
|
||||
$currentfilename = $fname;
|
||||
}
|
||||
|
||||
sub open_file( $ ) {
|
||||
sub open_file( $;$ ) {
|
||||
my $fname = find_file $_[0];
|
||||
|
||||
assert( ! defined $currentfile );
|
||||
@ -1926,6 +1926,7 @@ sub open_file( $ ) {
|
||||
if ( -f $fname && -s _ ) {
|
||||
$first_entry = 0;
|
||||
$file_format = 1;
|
||||
$max_format = supplied $_[1] ? $_[1] : 1;
|
||||
do_open_file $fname;;
|
||||
} else {
|
||||
$ifstack = @ifstack;
|
||||
@ -2463,9 +2464,7 @@ sub push_open( $;$ ) {
|
||||
push @openstack, \@a;
|
||||
@includestack = ();
|
||||
$currentfile = undef;
|
||||
open_file( $file );
|
||||
$max_format = supplied $max ? $max : 1;
|
||||
|
||||
open_file( $file , $max );
|
||||
}
|
||||
|
||||
sub pop_open() {
|
||||
@ -2509,11 +2508,10 @@ sub shorewall {
|
||||
# until we get back to the caller of read_a_line(), we could issue error messages about parsing and
|
||||
# running scripts in the file before we'd even indicated that we are processing it.
|
||||
#
|
||||
sub first_entry( $;$ ) {
|
||||
( $first_entry, my $max ) = @_;
|
||||
sub first_entry( $ ) {
|
||||
$first_entry = shift;
|
||||
my $reftype = reftype $first_entry;
|
||||
assert( $reftype eq 'CODE' ) if $reftype;
|
||||
$max_format = supplied $max ? $max : 1;
|
||||
}
|
||||
|
||||
sub read_a_line($);
|
||||
|
@ -213,7 +213,7 @@ sub setup_conntrack() {
|
||||
|
||||
for my $name ( qw/notrack conntrack/ ) {
|
||||
|
||||
my $fn = open_file( $name );
|
||||
my $fn = open_file( $name, 3 );
|
||||
|
||||
if ( $fn ) {
|
||||
|
||||
@ -221,7 +221,7 @@ sub setup_conntrack() {
|
||||
|
||||
my $empty = 1;
|
||||
|
||||
first_entry( "$doing $fn..." , 3 );
|
||||
first_entry( "$doing $fn..." );
|
||||
|
||||
while ( read_a_line( NORMAL_READ ) ) {
|
||||
my ( $source, $dest, $proto, $ports, $sports, $user, $switch );
|
||||
|
@ -2412,9 +2412,9 @@ sub setup_tc() {
|
||||
}
|
||||
);
|
||||
|
||||
if ( my $fn = open_file 'tcrules' ) {
|
||||
if ( my $fn = open_file( 'tcrules' , 2 ) ) {
|
||||
|
||||
first_entry "$doing $fn...", 2;
|
||||
first_entry "$doing $fn...";
|
||||
|
||||
process_tc_rule while read_a_line( NORMAL_READ );
|
||||
|
||||
|
@ -1311,8 +1311,8 @@ sub validate_interfaces_file( $ ) {
|
||||
my @ifaces;
|
||||
my $nextinum = 1;
|
||||
|
||||
if ( my $fn = open_file 'interfaces' ) {
|
||||
first_entry "$doing $fn..." , 2;
|
||||
if ( my $fn = open_file 'interfaces', 2 ) {
|
||||
first_entry "$doing $fn...";
|
||||
push @ifaces, process_interface( $nextinum++, $export ) while read_a_line( NORMAL_READ );
|
||||
} else {
|
||||
fatal_error q(The 'interfaces' file does not exist or has zero size);
|
||||
|
Loading…
Reference in New Issue
Block a user