Remove CONFIG_PATH scaffolding; fix 'isolate_action'

git-svn-id: https://shorewall.svn.sourceforge.net/svnroot/shorewall/trunk@5484 fbd18981-670d-0410-9b5c-8dc0c1a9a2bb
This commit is contained in:
teastep 2007-03-10 17:07:43 +00:00
parent b235c3b53d
commit 859c41abbf
2 changed files with 7 additions and 18 deletions

View File

@ -48,6 +48,7 @@ my %config = ( STARTUP_ENABLED => undef,
SUBSYSLOCK => undef, SUBSYSLOCK => undef,
MODULESDIR => undef, MODULESDIR => undef,
#CONFIG_PATH is inherited #CONFIG_PATH is inherited
CONFIG_PATH => undef,
RESTOREFILE => undef, RESTOREFILE => undef,
IPSECFILE => undef, IPSECFILE => undef,
# #
@ -331,15 +332,6 @@ my %default_actions = ( DROP => 'none' ,
ACCEPT => 'none' , ACCEPT => 'none' ,
QUEUE => 'none' ); QUEUE => 'none' );
sub ensure_config_path() {
$config{CONFIG_PATH} = $env{CONFDIR} . $env{SHAREDIR} unless $config{CONFIG_PATH};
if ( $ENV{SHOREWALL_DIR} ) {
( my ( $firstdir ) = $config{CONFIG_PATH} ) =~ s/:.*//;
$config{CONFIG_PATH} = "$ENV{SHOREWALL_DIR}:" . $config{CONFIG_PATH} if $ENV{SHOREWALL_DIR} ne $firstdir;
}
}
# #
# Search the CONFIG_PATH for the passed file # Search the CONFIG_PATH for the passed file
# #
@ -353,7 +345,7 @@ sub find_file($)
my $directory; my $directory;
for $directory ( split ':', $config{CONFIG_PATH} ) { for $directory ( split ':', $ENV{CONFIG_PATH} ) {
my $file = "$directory/$filename"; my $file = "$directory/$filename";
return $file if -f $file; return $file if -f $file;
} }
@ -1188,11 +1180,10 @@ sub split_action ( $ ) {
} }
# #
# Get Action Type # Get Macro Name
# #
sub isolate_action( $ ) { sub isolate_action( $ ) {
my ( $action , $undef ) = split '/', $_[0]; ( split '/' , $_[0] )[0];
$targets{$action} || '';
} }
# This function substitutes the second argument for the first part of the first argument up to the first colon (":") # This function substitutes the second argument for the first part of the first argument up to the first colon (":")
@ -4227,7 +4218,7 @@ sub process_action3( $$$$$ ) {
my ( $action2 , $level2 ) = split_action $target2; my ( $action2 , $level2 ) = split_action $target2;
my $action2type = isolate_action $action2; my $action2type = $targets{isolate_action $action2};
unless ( $action2type == STANDARD ) { unless ( $action2type == STANDARD ) {
if ( $target eq 'COMMENT' ) { if ( $target eq 'COMMENT' ) {
@ -5076,8 +5067,6 @@ sub create_iptables_restore_file() {
# Read the shorewall.conf file and establish global hashes %config and %env. # Read the shorewall.conf file and establish global hashes %config and %env.
# #
sub do_initialize() { sub do_initialize() {
ensure_config_path;
my $file = find_file 'shorewall.conf'; my $file = find_file 'shorewall.conf';
if ( -f $file ) { if ( -f $file ) {
@ -5110,8 +5099,6 @@ sub do_initialize() {
fatal_error "$file does not exist!"; fatal_error "$file does not exist!";
} }
ensure_config_path;
$file = find_file 'capabilities'; $file = find_file 'capabilities';
if ( -f $file ) { if ( -f $file ) {

View File

@ -2075,6 +2075,7 @@ do_initialize() {
fi fi
[ "x${SHOREWALL_DIR}" = "x." ] && SHOREWALL_DIR="$PWD" [ "x${SHOREWALL_DIR}" = "x." ] && SHOREWALL_DIR="$PWD"
[ -n "${RESTOREFILE:=restore}" ] [ -n "${RESTOREFILE:=restore}" ]
case "${DROP_DEFAULT:=Drop}" in case "${DROP_DEFAULT:=Drop}" in
@ -2179,6 +2180,7 @@ do_initialize() {
strip_file_and_lib_load tunnels tunnels strip_file_and_lib_load tunnels tunnels
report_capabilities1 > $TMP_DIR/capabilities report_capabilities1 > $TMP_DIR/capabilities
export TMP_DIR export TMP_DIR
export CONFIG_PATH
fi fi
# #
# Clear $FW # Clear $FW