mirror of
https://gitlab.com/shorewall/code.git
synced 2025-01-11 16:18:13 +01:00
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);
|
set_global_variables(1);
|
||||||
|
|
||||||
|
handle_optional_interfaces;
|
||||||
|
|
||||||
emit ';;';
|
emit ';;';
|
||||||
|
|
||||||
if ( $global_variables == ( ALL_COMMANDS | NOT_RESTORE ) ) {
|
if ( $global_variables == ( ALL_COMMANDS | NOT_RESTORE ) ) {
|
||||||
@ -253,6 +255,8 @@ sub generate_script_2() {
|
|||||||
|
|
||||||
set_global_variables(0);
|
set_global_variables(0);
|
||||||
|
|
||||||
|
handle_optional_interfaces;
|
||||||
|
|
||||||
emit ';;';
|
emit ';;';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -262,8 +266,6 @@ sub generate_script_2() {
|
|||||||
emit ( 'esac' ) ,
|
emit ( 'esac' ) ,
|
||||||
}
|
}
|
||||||
|
|
||||||
handle_optional_interfaces;
|
|
||||||
|
|
||||||
pop_indent;
|
pop_indent;
|
||||||
|
|
||||||
emit "\n}\n"; # End of initialize()
|
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"',
|
' [ -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"' ,
|
' [ -n "$IPSET" ] || fatal_error "The ipset utility cannot be located"' ,
|
||||||
' ;;',
|
' ;;',
|
||||||
'esac',
|
'esac',
|
||||||
|
@ -785,31 +785,32 @@ sub lookup_provider( $ ) {
|
|||||||
|
|
||||||
#
|
#
|
||||||
# This function is called by the compiler when it is generating the initialize() function.
|
# 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() {
|
sub handle_optional_interfaces() {
|
||||||
|
|
||||||
my $interfaces = find_interfaces_by_option 'optional';
|
my $interfaces = find_interfaces_by_option 'optional';
|
||||||
|
|
||||||
if ( $interfaces ) {
|
if ( @$interfaces ) {
|
||||||
my $variable;
|
my $variable;
|
||||||
|
|
||||||
for my $interface ( @$interfaces ) {
|
for my $interface ( @$interfaces ) {
|
||||||
my $base = uc chain_base( $interface );
|
my $base = uc chain_base( $interface );
|
||||||
my $table = $provider_interfaces{$interface};
|
my $provider = $provider_interfaces{$interface};
|
||||||
|
|
||||||
emit '';
|
emit '';
|
||||||
|
|
||||||
if ( $table ) {
|
if ( $provider ) {
|
||||||
#
|
#
|
||||||
# This is a provider -- get the provider table entry
|
# This is a provider -- get the provider table entry
|
||||||
#
|
#
|
||||||
my $tableref = $providers{$table};
|
my $providerref = $providers{$provider};
|
||||||
|
|
||||||
if ( $tableref->{shared} ) {
|
if ( $providerref->{shared} ) {
|
||||||
$variable = $tableref->{mac};
|
$variable = $providerref->{mac};
|
||||||
} elsif ( $tableref->{gatewaycase} eq 'detect' ) {
|
} elsif ( $providerref->{gatewaycase} eq 'detect' ) {
|
||||||
$variable = $tableref->{gateway};
|
$variable = $providerref->{gateway};
|
||||||
} else {
|
} else {
|
||||||
$variable = '';
|
$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
|
# The Tc module has collected the 'sticky' rules in the 'tcpre' and 'tcout' chains. In this function, we apply them
|
||||||
# to the 'tracked' providers
|
# to the 'tracked' providers
|
||||||
|
@ -1030,7 +1030,7 @@ find_echo() {
|
|||||||
result=$(echo -e "a\tb")
|
result=$(echo -e "a\tb")
|
||||||
[ ${#result} -eq 3 ] && { echo "echo -e"; return; }
|
[ ${#result} -eq 3 ] && { echo "echo -e"; return; }
|
||||||
|
|
||||||
result=$(which echo)
|
result=$(mywhich echo)
|
||||||
[ -n "$result" ] && { echo "$result -e"; return; }
|
[ -n "$result" ] && { echo "$result -e"; return; }
|
||||||
|
|
||||||
echo echo
|
echo echo
|
||||||
@ -1063,7 +1063,7 @@ find_mac() # $1 = IP address, $2 = interface
|
|||||||
conditionally_flush_conntrack() {
|
conditionally_flush_conntrack() {
|
||||||
|
|
||||||
if [ -n "$PURGE" ]; then
|
if [ -n "$PURGE" ]; then
|
||||||
if [ -n $(which conntrack) ]; then
|
if [ -n $(mywhich conntrack) ]; then
|
||||||
conntrack -F
|
conntrack -F
|
||||||
else
|
else
|
||||||
error_message "WARNING: The '-p' option requires the conntrack utility which does not appear to be installed on this system"
|
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