Unconditionally convert masq->snat

Signed-off-by: Tom Eastep <teastep@shorewall.net>
This commit is contained in:
Tom Eastep 2018-03-27 11:38:47 -07:00
parent 011322992e
commit 5e2f1f573d
No known key found for this signature in database
GPG Key ID: 96E6B3F2423A4D10
3 changed files with 10 additions and 16 deletions

View File

@ -779,7 +779,7 @@ sub compiler {
#
# Setup Masquerade/SNAT
#
setup_snat( $update );
setup_snat;
#
# Setup Nat
#

View File

@ -37,7 +37,7 @@ use strict;
our @ISA = qw(Exporter);
our @EXPORT = qw( setup_nat setup_netmap add_addresses );
our %EXPORT_TAGS = ( rules => [ qw ( handle_nat_rule handle_nonat_rule process_one_masq convert_masq @addresses_to_add %addresses_to_add ) ] );
our %EXPORT_TAGS = ( rules => [ qw ( handle_nat_rule handle_nonat_rule convert_masq @addresses_to_add %addresses_to_add ) ] );
our @EXPORT_OK = ();
Exporter::export_ok_tags('rules');
@ -587,11 +587,11 @@ EOF
# Convert a masq file into the equivalent snat file
#
sub convert_masq() {
my $have_masq_rules;
if ( my $fn = open_file( 'masq', 1, 1 ) ) {
my ( $snat, $fn1 ) = open_snat_for_output( $fn );
my $have_masq_rules;
directive_callback(
sub ()
{
@ -647,6 +647,8 @@ sub convert_masq() {
close $snat, directive_callback( 0 );
}
$have_masq_rules;
}
#

View File

@ -5851,23 +5851,15 @@ sub process_snat( )
}
#
# Process the masq or snat file
# Process the snat file. Convert the masq file if found and non-empty
#
sub setup_snat( $ ) # Convert masq->snat if true
sub setup_snat()
{
my $fn;
my $have_masq;
if ( $_[0] ) {
convert_masq();
} elsif ( $fn = open_file( 'masq', 1, 1 ) ) {
first_entry( sub { progress_message2 "$doing $fn..."; require_capability 'NAT_ENABLED' , "a non-empty masq file" , 's'; } );
process_one_masq(0), $have_masq = 1 while read_a_line( NORMAL_READ );
}
unless ( $have_masq ) {
unless ( convert_masq ) {
#
# Masq file empty or didn't exist
# Masq file was empty or didn't exist
#
if ( $fn = open_file( 'snat', 1, 1 ) ) {
first_entry( sub { progress_message2 "$doing $fn..."; require_capability 'NAT_ENABLED' , "a non-empty snat file" , 's'; } );