From 4559c8b5d0d5e6343ef1c2d17a35e578807f485d Mon Sep 17 00:00:00 2001 From: Tom Eastep Date: Mon, 21 Nov 2011 12:13:39 -0800 Subject: [PATCH] Tweaks to convert_blacklist() - Reword an error message to handle both missing file and zero-sized file. - Don't rename file that doesn't exist. --- Shorewall/Perl/Shorewall/Misc.pm | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Shorewall/Perl/Shorewall/Misc.pm b/Shorewall/Perl/Shorewall/Misc.pm index e43cde0bd..7aeb311a2 100644 --- a/Shorewall/Perl/Shorewall/Misc.pm +++ b/Shorewall/Perl/Shorewall/Misc.pm @@ -528,13 +528,14 @@ EOF close $blrules; } else { - warning_message q(There are interfaces or zones with the 'blacklist' option but the 'blacklist' file is empty) unless @rules; + warning_message q(There are interfaces or zones with the 'blacklist' option but the 'blacklist' file is empty or does not exist) unless @rules; + } + + if ( -f $fn ) { + rename $fn, "$fn.bak"; + progress_message2 "Blacklist file $fn saved in $fn.bak"; } - rename $fn, "$fn.bak"; - - progress_message2 "Blacklist file $fn saved in $fn.bak"; - for my $file ( qw(zones interfaces hosts) ) { remove_blacklist $file; }