From 792901b42dbc93af981a0f34de86714d6d2cdfd4 Mon Sep 17 00:00:00 2001 From: teastep Date: Tue, 20 Mar 2007 16:11:06 +0000 Subject: [PATCH] Remove tempfile on error; change 'use lib' to final form git-svn-id: https://shorewall.svn.sourceforge.net/svnroot/shorewall/trunk@5596 fbd18981-670d-0410-9b5c-8dc0c1a9a2bb --- New/Shorewall/Common.pm | 7 ++++++- New/Shorewall/Zones.pm | 3 +-- New/compiler.pl | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/New/Shorewall/Common.pm b/New/Shorewall/Common.pm index 99548ac04..6b04792b6 100644 --- a/New/Shorewall/Common.pm +++ b/New/Shorewall/Common.pm @@ -94,7 +94,12 @@ sub warning_message sub fatal_error { print STDERR " ERROR: @_\n"; - close $object, if $object; + + if ( $object ) { + close $object; + unlink $tempfile; + } + system "rm -rf $ENV{TMP_DIR}" if $ENV{TMP_DIR}; die; } diff --git a/New/Shorewall/Zones.pm b/New/Shorewall/Zones.pm index 4f75745c7..a354957c9 100644 --- a/New/Shorewall/Zones.pm +++ b/New/Shorewall/Zones.pm @@ -192,8 +192,6 @@ sub determine_zones() fatal_error("Invalid zone file entry: $line") if $extra; - fatal_error( "Duplicate zone name: $zone\n" ) if $zones{$zone}; - if ( $zone =~ /(\w+):([\w,]+)/ ) { $zone = $1; @parents = split ',', $2; @@ -208,6 +206,7 @@ sub determine_zones() fatal_error "Invalid zone name: $zone" unless "\L$zone" =~ /^[a-z]\w*$/ && length $zone <= $env{MAXZONENAMELENGTH}; fatal_error "Invalid zone name: $zone" if $zone =~ /^all2|2all$/; + fatal_error( "Duplicate zone name: $zone\n" ) if $zones{$zone}; my $zoneref = $zones{$zone} = {}; $zoneref->{parents} = \@parents; diff --git a/New/compiler.pl b/New/compiler.pl index a9f817cd4..3bf62d23c 100755 --- a/New/compiler.pl +++ b/New/compiler.pl @@ -41,7 +41,7 @@ # This program performs rudimentary shell variable expansion on action and macro files. use strict; -use lib '/usr/share/shorewall/Shorewall'; +use lib '/usr/share/shorewall'; use Shorewall::Common; use Shorewall::Config; use Shorewall::Chains;