From 265170ff66ea735a0f7d80daa9dbb4a66b890512 Mon Sep 17 00:00:00 2001 From: teastep Date: Sat, 30 Jun 2007 16:11:56 +0000 Subject: [PATCH] Correct CONFIG_PATH search when filename contains '/'; avoid confusing failure messages from buildports.pm git-svn-id: https://shorewall.svn.sourceforge.net/svnroot/shorewall/trunk@6729 fbd18981-670d-0410-9b5c-8dc0c1a9a2bb --- Shorewall-perl/Shorewall/Config.pm | 2 +- Shorewall-perl/buildports.pl | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Shorewall-perl/Shorewall/Config.pm b/Shorewall-perl/Shorewall/Config.pm index 6ae09479f..b40b31f0f 100644 --- a/Shorewall-perl/Shorewall/Config.pm +++ b/Shorewall-perl/Shorewall/Config.pm @@ -361,7 +361,7 @@ sub find_file($) { my $filename=$_[0]; - return $filename if substr( $filename, 0, 1 ) eq '/'; + return $filename if $filename =~ '/'; my $directory; diff --git a/Shorewall-perl/buildports.pl b/Shorewall-perl/buildports.pl index 4f03b8acf..180e89a97 100755 --- a/Shorewall-perl/buildports.pl +++ b/Shorewall-perl/buildports.pl @@ -65,10 +65,14 @@ sub print_service( $$ ) { $service_hash{$service} = $number; } } +# +# E x e c u t i o n B e g i n s H e r e +# +set_config_path( '/etc' ); -set_config_path( '/etc/shorewall:/usr/share/shorewall' ); +our $dir = $ARGV[0] || '/etc'; -set_shorewall_dir($ARGV[0] || '/etc'); +$dir =~ s|/+$|| unless $dir eq '/'; our $date = localtime; @@ -116,7 +120,7 @@ our $VERSION = '1.00'; our %protocols = ( EOF -open_file 'protocols' or fatal_error "Cannot open protocols: $!"; +open_file "$dir/protocols" or fatal_error "Cannot open $dir/protocols: $!"; while ( read_a_line1 ) { my ( $proto1, $number, @aliases ) = split_line( 2, 10, '/etc/protocols entry'); @@ -133,7 +137,7 @@ print "\t\t );\n\n"; print "our %services = (\n"; -open_file 'services' or fatal_error "Cannot open services: $!"; +open_file "$dir/services" or fatal_error "Cannot open $dir/services: $!"; while ( read_a_line1 ) { my ( $name1, $proto_number, @names ) = split_line( 2, 10, '/etc/services entry');