mirror of
https://gitlab.com/shorewall/code.git
synced 2024-12-24 07:08:53 +01:00
Revise notrack/conntrack handling:
- Purge empty notrack files. - Process both files.
This commit is contained in:
parent
75b830b10e
commit
45288f5927
@ -204,21 +204,19 @@ sub setup_conntrack() {
|
||||
my $format = 1;
|
||||
my $action = 'NOTRACK';
|
||||
|
||||
my $fn = open_file( 'notrack' );
|
||||
for my $name ( qw/notrack conntrack/ ) {
|
||||
|
||||
if ( $fn ) {
|
||||
if ( -f ( my $fn1 = find_file 'conntrack' ) ) {
|
||||
warning_message "Both $fn and $fn1 exist: $fn1 will be ignored";
|
||||
}
|
||||
} else {
|
||||
$fn = open_file( 'conntrack' );
|
||||
}
|
||||
my $fn = open_file( $name );
|
||||
|
||||
if ( $fn ) {
|
||||
|
||||
first_entry "$doing $fn...";
|
||||
my $empty = 1;
|
||||
|
||||
my $nonEmpty = 0;
|
||||
first_entry( sub () { progress_message2 "$doing $fn...";
|
||||
$empty = 0;
|
||||
warning_message( "Non-empty notrack file ($fn); please move its contents to the conntrack file" ) if $name eq 'notrack';
|
||||
}
|
||||
);
|
||||
|
||||
while ( read_a_line( NORMAL_READ ) ) {
|
||||
my ( $source, $dest, $proto, $ports, $sports, $user );
|
||||
@ -260,6 +258,15 @@ sub setup_conntrack() {
|
||||
}
|
||||
|
||||
clear_comment;
|
||||
|
||||
if ( $empty && $name eq 'notrack') {
|
||||
if ( unlink( $fn ) ) {
|
||||
warning_message "Empty notrack file ($fn) removed";
|
||||
} else {
|
||||
warning_message "Unable to remove empty notrack file ($fn): $!";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user