forked from extern/shorewall_code
replace a couple of instances of 'which' with 'mywhich'; relocate some global variable code
This commit is contained in:
parent
defbbb418b
commit
64fd1167d1
@ -242,6 +242,8 @@ sub generate_script_2() {
|
||||
|
||||
set_global_variables(1);
|
||||
|
||||
handle_optional_interfaces;
|
||||
|
||||
emit ';;';
|
||||
|
||||
if ( $global_variables == ( ALL_COMMANDS | NOT_RESTORE ) ) {
|
||||
@ -253,6 +255,8 @@ sub generate_script_2() {
|
||||
|
||||
set_global_variables(0);
|
||||
|
||||
handle_optional_interfaces;
|
||||
|
||||
emit ';;';
|
||||
}
|
||||
|
||||
@ -262,8 +266,6 @@ sub generate_script_2() {
|
||||
emit ( 'esac' ) ,
|
||||
}
|
||||
|
||||
handle_optional_interfaces;
|
||||
|
||||
pop_indent;
|
||||
|
||||
emit "\n}\n"; # End of initialize()
|
||||
@ -339,7 +341,7 @@ sub generate_script_3($) {
|
||||
' [ -x "$IPSET" ] || fatal_error "IPSET=$IPSET does not exist or is not executable"',
|
||||
' ;;',
|
||||
' *)',
|
||||
' IPSET="$(which $IPSET)"',
|
||||
' IPSET="$(mywhich $IPSET)"',
|
||||
' [ -n "$IPSET" ] || fatal_error "The ipset utility cannot be located"' ,
|
||||
' ;;',
|
||||
'esac',
|
||||
|
@ -785,31 +785,32 @@ sub lookup_provider( $ ) {
|
||||
|
||||
#
|
||||
# This function is called by the compiler when it is generating the initialize() function.
|
||||
# It sets the ..._IS_USABLE interface variables appropriately for the optional interfaces
|
||||
# The function emits code to set the ..._IS_USABLE interface variables appropriately for the
|
||||
# optional interfaces
|
||||
#
|
||||
sub handle_optional_interfaces() {
|
||||
|
||||
my $interfaces = find_interfaces_by_option 'optional';
|
||||
|
||||
if ( $interfaces ) {
|
||||
if ( @$interfaces ) {
|
||||
my $variable;
|
||||
|
||||
for my $interface ( @$interfaces ) {
|
||||
my $base = uc chain_base( $interface );
|
||||
my $table = $provider_interfaces{$interface};
|
||||
my $provider = $provider_interfaces{$interface};
|
||||
|
||||
emit '';
|
||||
|
||||
if ( $table ) {
|
||||
if ( $provider ) {
|
||||
#
|
||||
# This is a provider -- get the provider table entry
|
||||
#
|
||||
my $tableref = $providers{$table};
|
||||
my $providerref = $providers{$provider};
|
||||
|
||||
if ( $tableref->{shared} ) {
|
||||
$variable = $tableref->{mac};
|
||||
} elsif ( $tableref->{gatewaycase} eq 'detect' ) {
|
||||
$variable = $tableref->{gateway};
|
||||
if ( $providerref->{shared} ) {
|
||||
$variable = $providerref->{mac};
|
||||
} elsif ( $providerref->{gatewaycase} eq 'detect' ) {
|
||||
$variable = $providerref->{gateway};
|
||||
} else {
|
||||
$variable = '';
|
||||
}
|
||||
@ -834,10 +835,6 @@ sub handle_optional_interfaces() {
|
||||
}
|
||||
}
|
||||
|
||||
sub is_provider_interface( $ ) {
|
||||
return $provider_interfaces{$_[0]} || 0;
|
||||
}
|
||||
|
||||
#
|
||||
# The Tc module has collected the 'sticky' rules in the 'tcpre' and 'tcout' chains. In this function, we apply them
|
||||
# to the 'tracked' providers
|
||||
|
@ -1030,7 +1030,7 @@ find_echo() {
|
||||
result=$(echo -e "a\tb")
|
||||
[ ${#result} -eq 3 ] && { echo "echo -e"; return; }
|
||||
|
||||
result=$(which echo)
|
||||
result=$(mywhich echo)
|
||||
[ -n "$result" ] && { echo "$result -e"; return; }
|
||||
|
||||
echo echo
|
||||
@ -1063,7 +1063,7 @@ find_mac() # $1 = IP address, $2 = interface
|
||||
conditionally_flush_conntrack() {
|
||||
|
||||
if [ -n "$PURGE" ]; then
|
||||
if [ -n $(which conntrack) ]; then
|
||||
if [ -n $(mywhich conntrack) ]; then
|
||||
conntrack -F
|
||||
else
|
||||
error_message "WARNING: The '-p' option requires the conntrack utility which does not appear to be installed on this system"
|
||||
|
Loading…
Reference in New Issue
Block a user