Compare commits

..

5 Commits

Author SHA1 Message Date
Tom Eastep
ef3a33e3f4 Merge branch '5.1.6'
# Conflicts:
#	Shorewall-core/lib.common

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-30 15:02:23 -07:00
Tom Eastep
b54a691110 Improve dynamic gateway detection
- Use provider's routing table, if any

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-23 15:04:47 -07:00
Tom Eastep
90f33dd436 Eliminate MODULE_SUFFIX
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-23 12:48:14 -07:00
Tom Eastep
6f475cde3f Eliminate MODULE_SUFFIX
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-23 10:19:25 -07:00
Tom Eastep
6053a40af0 Apply Tuomo Soini's loadmodule patch
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-23 09:20:50 -07:00
20 changed files with 58 additions and 101 deletions

View File

@@ -269,53 +269,48 @@ loadmodule() # $1 = module name, $2 - * arguments
{ {
local modulename local modulename
modulename=$1 modulename=$1
shift
local moduleoptions
moduleoptions=$*
local modulefile local modulefile
local suffix local suffix
if [ -d /sys/module/ ]; then if [ -d /sys/module/ ]; then
if ! list_search $modulename $DONT_LOAD; then if ! list_search $modulename $DONT_LOAD; then
if [ ! -d /sys/module/$modulename ]; then if [ ! -d /sys/module/$modulename ]; then
shift case $moduleloader in
insmod)
for suffix in $MODULE_SUFFIX ; do for directory in $moduledirectories; do
for directory in $moduledirectories; do for modulefile in $directory/${modulename}.*; do
modulefile=$directory/${modulename}.${suffix} if [ -f $modulefile ]; then
insmod $modulefile $moduleoptions
if [ -f $modulefile ]; then return
case $moduleloader in fi
insmod) done
insmod $modulefile $* done
;; ;;
*) *)
modprobe $modulename $* modprobe -q $modulename $moduleoptions
;; ;;
esac esac
break 2
fi
done
done
fi fi
fi fi
elif ! list_search $modulename $DONT_LOAD $MODULES; then elif ! list_search $modulename $DONT_LOAD $MODULES; then
shift case $moduleloader in
insmod)
for suffix in $MODULE_SUFFIX ; do for directory in $moduledirectories; do
for directory in $moduledirectories; do for modulefile in $directory/${modulename}.*; do
modulefile=$directory/${modulename}.${suffix} if [ -f $modulefile ]; then
insmod $modulefile $moduleoptions
if [ -f $modulefile ]; then return
case $moduleloader in fi
insmod) done
insmod $modulefile $* done
;; ;;
*) *)
modprobe $modulename $* modprobe -q $modulename $moduleoptions
;; ;;
esac esac
break 2
fi
done
done
fi fi
} }
@@ -338,8 +333,6 @@ reload_kernel_modules() {
moduleloader=insmod moduleloader=insmod
fi fi
[ -n "${MODULE_SUFFIX:=ko ko.gz ko.xz o o.gz o.xz gz xz}" ]
if [ -n "$MODULESDIR" ]; then if [ -n "$MODULESDIR" ]; then
case "$MODULESDIR" in case "$MODULESDIR" in
+*) +*)
@@ -394,8 +387,6 @@ load_kernel_modules() # $1 = Yes, if we are to save moduleinfo in $VARDIR
moduleloader=insmod moduleloader=insmod
fi fi
[ -n "${MODULE_SUFFIX:=o gz xz ko o.gz o.xz ko.gz ko.xz}" ]
if [ -n "$MODULESDIR" ]; then if [ -n "$MODULESDIR" ]; then
case "$MODULESDIR" in case "$MODULESDIR" in
+*) +*)

View File

@@ -28,7 +28,7 @@
# #
# On the target system (the system where the firewall program is to run): # On the target system (the system where the firewall program is to run):
# #
# [ IPTABLES=<iptables binary> ] [ MODULESDIR=<kernel modules directory> ] [ MODULE_SUFFIX="<module suffix list>" ] shorecap > capabilities # [ IPTABLES=<iptables binary> ] [ MODULESDIR=<kernel modules directory> ] shorecap > capabilities
# #
# Now move the capabilities file to the compilation system. The file must # Now move the capabilities file to the compilation system. The file must
# be placed in a directory on the CONFIG_PATH to be used when compiling firewalls # be placed in a directory on the CONFIG_PATH to be used when compiling firewalls
@@ -38,7 +38,6 @@
# #
# IPTABLES - iptables # IPTABLES - iptables
# MODULESDIR - /lib/modules/$(uname -r)/kernel/net/ipv4/netfilter # MODULESDIR - /lib/modules/$(uname -r)/kernel/net/ipv4/netfilter
# MODULE_SUFFIX - "o gz xz ko o.gz o.xz ko.gz ko.xz"
# #
# Shorewall need not be installed on the target system to run shorecap. If the '-e' flag is # Shorewall need not be installed on the target system to run shorecap. If the '-e' flag is
# used during firewall compilation, then the generated firewall program will likewise not # used during firewall compilation, then the generated firewall program will likewise not

View File

@@ -7065,6 +7065,8 @@ sub interface_gateway( $ ) {
sub get_interface_gateway ( $;$$ ) { sub get_interface_gateway ( $;$$ ) {
my ( $logical, $protect, $provider ) = @_; my ( $logical, $protect, $provider ) = @_;
$provider = '' unless defined $provider;
my $interface = get_physical $logical; my $interface = get_physical $logical;
my $variable = interface_gateway( $interface ); my $variable = interface_gateway( $interface );
my $gateway = get_interface_option( $interface, 'gateway' ); my $gateway = get_interface_option( $interface, 'gateway' );
@@ -7078,9 +7080,9 @@ sub get_interface_gateway ( $;$$ ) {
} }
if ( interface_is_optional $logical ) { if ( interface_is_optional $logical ) {
$interfacegateways{$interface} = qq([ -n "\$$variable" ] || $variable=\$(detect_gateway $interface)); $interfacegateways{$interface} = qq([ -n "\$$variable" ] || $variable=\$(detect_gateway $interface $provider));
} else { } else {
$interfacegateways{$interface} = qq([ -n "\$$variable" ] || $variable=\$(detect_gateway $interface) $interfacegateways{$interface} = qq([ -n "\$$variable" ] || $variable=\$(detect_gateway $interface $provider)
[ -n "\$$variable" ] || startup_error "Unable to detect the gateway through interface $interface"); [ -n "\$$variable" ] || startup_error "Unable to detect the gateway through interface $interface");
} }

View File

@@ -36,6 +36,7 @@ use strict;
use warnings; use warnings;
use File::Basename; use File::Basename;
use File::Temp qw/ tempfile tempdir /; use File::Temp qw/ tempfile tempdir /;
use File::Glob ':globally';
use Cwd qw(abs_path getcwd); use Cwd qw(abs_path getcwd);
use autouse 'Carp' => qw(longmess confess); use autouse 'Carp' => qw(longmess confess);
use Scalar::Util 'reftype'; use Scalar::Util 'reftype';
@@ -315,7 +316,7 @@ our %renamed = ( AUTO_COMMENT => 'AUTOCOMMENT', BLACKLIST_LOGLEVEL => 'BLACKLIST
# #
# Config options and global settings that are to be copied to output script # Config options and global settings that are to be copied to output script
# #
our @propagateconfig = qw/ DISABLE_IPV6 MODULESDIR MODULE_SUFFIX LOAD_HELPERS_ONLY LOCKFILE SUBSYSLOCK LOG_VERBOSITY RESTART/; our @propagateconfig = qw/ DISABLE_IPV6 MODULESDIR LOAD_HELPERS_ONLY LOCKFILE SUBSYSLOCK LOG_VERBOSITY RESTART/;
# #
# From parsing the capabilities file or detecting capabilities # From parsing the capabilities file or detecting capabilities
# #
@@ -648,6 +649,7 @@ our %eliminated = ( LOGRATE => 1,
HIGH_ROUTE_MARKS => 1, HIGH_ROUTE_MARKS => 1,
BLACKLISTNEWONLY => 1, BLACKLISTNEWONLY => 1,
CHAIN_SCRIPTS => 1, CHAIN_SCRIPTS => 1,
MODULE_SUFFIX => 1,
); );
# #
# Variables involved in ?IF, ?ELSE ?ENDIF processing # Variables involved in ?IF, ?ELSE ?ENDIF processing
@@ -848,7 +850,6 @@ sub initialize( $;$$) {
BLACKLIST => undef, BLACKLIST => undef,
BLACKLISTNEWONLY => undef, BLACKLISTNEWONLY => undef,
DELAYBLACKLISTLOAD => undef, DELAYBLACKLISTLOAD => undef,
MODULE_SUFFIX => undef,
DISABLE_IPV6 => undef, DISABLE_IPV6 => undef,
DYNAMIC_ZONES => undef, DYNAMIC_ZONES => undef,
PKTTYPE=> undef, PKTTYPE=> undef,
@@ -4320,25 +4321,20 @@ sub load_kernel_modules( ) {
close LSMOD; close LSMOD;
$config{MODULE_SUFFIX} = 'ko ko.gz ko.xz o o.gz o.xz gz xz' unless $config{MODULE_SUFFIX}; MODULE:
my @suffixes = split /\s+/ , $config{MODULE_SUFFIX};
while ( read_a_line( NORMAL_READ ) ) { while ( read_a_line( NORMAL_READ ) ) {
fatal_error "Invalid modules file entry" unless ( $currentline =~ /^loadmodule\s+([a-zA-Z]\w*)\s*(.*)$/ ); fatal_error "Invalid modules file entry" unless ( $currentline =~ /^loadmodule\s+([a-zA-Z]\w*)\s*(.*)$/ );
my ( $module, $arguments ) = ( $1, $2 ); my ( $module, $arguments ) = ( $1, $2 );
unless ( $loadedmodules{ $module } ) { unless ( $loadedmodules{ $module } ) {
for my $directory ( @moduledirectories ) { if ( $moduleloader eq 'modprobe' ) {
for my $suffix ( @suffixes ) { system( "modprobe -q $module $arguments" );
my $modulefile = "$directory/$module.$suffix"; $loadedmodules{ $module } = 1;
if ( -f $modulefile ) { } else {
if ( $moduleloader eq 'insmod' ) { for my $directory ( @moduledirectories ) {
system ("insmod $modulefile $arguments" ); for my $modulefile ( <$directory/$module.*> ) {
} else { system ("insmod $modulefile $arguments" );
system( "modprobe $module $arguments" );
}
$loadedmodules{ $module } = 1; $loadedmodules{ $module } = 1;
next MODULE;
} }
} }
} }

View File

@@ -502,7 +502,7 @@ sub process_a_provider( $ ) {
if ( ( $gw = lc $gateway ) eq 'detect' ) { if ( ( $gw = lc $gateway ) eq 'detect' ) {
fatal_error "Configuring multiple providers through one interface requires an explicit gateway" if $shared; fatal_error "Configuring multiple providers through one interface requires an explicit gateway" if $shared;
$gateway = get_interface_gateway( $interface, undef, 1 ); $gateway = get_interface_gateway( $interface, undef, $number );
$gatewaycase = 'detect'; $gatewaycase = 'detect';
set_interface_option( $interface, 'gateway', 'detect' ); set_interface_option( $interface, 'gateway', 'detect' );
} elsif ( $gw eq 'none' ) { } elsif ( $gw eq 'none' ) {

View File

@@ -899,7 +899,7 @@ detect_dynamic_gateway() { # $1 = interface
# #
# Detect the gateway through an interface # Detect the gateway through an interface
# #
detect_gateway() # $1 = interface detect_gateway() # $1 = interface $2 = table number
{ {
local interface local interface
interface=$1 interface=$1
@@ -912,6 +912,8 @@ detect_gateway() # $1 = interface
# Maybe there's a default route through this gateway already # Maybe there's a default route through this gateway already
# #
[ -n "$gateway" ] || gateway=$(find_gateway $($IP -4 route list dev $interface | grep ^default)) [ -n "$gateway" ] || gateway=$(find_gateway $($IP -4 route list dev $interface | grep ^default))
[ -z "$gateway" -a -n "$2" ] && gateway=$(find_gateway $($IP -4 route list dev $interface table $2 | grep ^default))
# #
# Last hope -- is there a load-balancing route through the interface? # Last hope -- is there a load-balancing route through the interface?
# #

View File

@@ -205,8 +205,6 @@ MINIUPNPD=No
MARK_IN_FORWARD_CHAIN=No MARK_IN_FORWARD_CHAIN=No
MODULE_SUFFIX="ko ko.xz"
MULTICAST=No MULTICAST=No
MUTEX_TIMEOUT=60 MUTEX_TIMEOUT=60

View File

@@ -216,8 +216,6 @@ MINIUPNPD=No
MARK_IN_FORWARD_CHAIN=No MARK_IN_FORWARD_CHAIN=No
MODULE_SUFFIX="ko ko.xz"
MULTICAST=No MULTICAST=No
MUTEX_TIMEOUT=60 MUTEX_TIMEOUT=60

View File

@@ -213,8 +213,6 @@ MINIUPNPD=No
MARK_IN_FORWARD_CHAIN=No MARK_IN_FORWARD_CHAIN=No
MODULE_SUFFIX="ko ko.xz"
MULTICAST=No MULTICAST=No
MUTEX_TIMEOUT=60 MUTEX_TIMEOUT=60

View File

@@ -216,8 +216,6 @@ MINIUPNPD=No
MARK_IN_FORWARD_CHAIN=No MARK_IN_FORWARD_CHAIN=No
MODULE_SUFFIX="ko ko.xz"
MULTICAST=No MULTICAST=No
MUTEX_TIMEOUT=60 MUTEX_TIMEOUT=60

View File

@@ -205,8 +205,6 @@ MARK_IN_FORWARD_CHAIN=No
MINIUPNPD=No MINIUPNPD=No
MODULE_SUFFIX="ko ko.xz"
MULTICAST=No MULTICAST=No
MUTEX_TIMEOUT=60 MUTEX_TIMEOUT=60

View File

@@ -1556,10 +1556,10 @@ remote_reload_command() # $* = original arguments less the command.
progress_message "Getting Capabilities on system $system..." progress_message "Getting Capabilities on system $system..."
if [ $g_family -eq 4 ]; then if [ $g_family -eq 4 ]; then
if ! rsh_command "MODULESDIR=$MODULESDIR MODULE_SUFFIX=\"$MODULE_SUFFIX\" IPTABLES=$IPTABLES DONT_LOAD=\"$DONT_LOAD\" $libexec/shorewall-lite/shorecap" > $g_shorewalldir/capabilities; then if ! rsh_command "MODULESDIR=$MODULESDIR IPTABLES=$IPTABLES DONT_LOAD=\"$DONT_LOAD\" $libexec/shorewall-lite/shorecap" > $g_shorewalldir/capabilities; then
fatal_error "Capturing capabilities on system $system failed" fatal_error "Capturing capabilities on system $system failed"
fi fi
elif ! rsh_command "MODULESDIR=$MODULESDIR MODULE_SUFFIX=\"$MODULE_SUFFIX\" IP6TABLES=$IP6TABLES DONT_LOAD=\"$DONT_LOAD\" $libexec/shorewall6-lite/shorecap" > $g_shorewalldir/capabilities; then elif ! rsh_command "MODULESDIR=$MODULESDIR IP6TABLES=$IP6TABLES DONT_LOAD=\"$DONT_LOAD\" $libexec/shorewall6-lite/shorecap" > $g_shorewalldir/capabilities; then
fatal_error "Capturing capabilities on system $system failed" fatal_error "Capturing capabilities on system $system failed"
fi fi
fi fi

View File

@@ -51,7 +51,7 @@
<para>The <replaceable>modulename</replaceable> names a kernel module <para>The <replaceable>modulename</replaceable> names a kernel module
(without suffix). Shorewall will search for modules based on your (without suffix). Shorewall will search for modules based on your
MODULESDIR and MODULE_SUFFIX settings in <ulink MODULESDIR setting in <ulink
url="/manpages/shorewall.conf.html">shorewall.conf</ulink>(8). The url="/manpages/shorewall.conf.html">shorewall.conf</ulink>(8). The
<replaceable>moduleoption</replaceable>s are passed to modprobe (if <replaceable>moduleoption</replaceable>s are passed to modprobe (if
installed) or to insmod.</para> installed) or to insmod.</para>

View File

@@ -1892,18 +1892,6 @@ LOG:info:,bar net fw</programlisting>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term><emphasis role="bold">MODULE_SUFFIX=</emphasis>[<emphasis
role="bold">"</emphasis><emphasis>extension</emphasis> ...<emphasis
role="bold">"</emphasis>]</term>
<listitem>
<para>The value of this option determines the possible file
extensions of kernel modules. The default value is "ko ko.gz ko.xz o
o.gz o.xz gz xz".</para>
</listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term><emphasis <term><emphasis
role="bold">MODULESDIR=</emphasis>[[+]<emphasis>pathname</emphasis>[<emphasis role="bold">MODULESDIR=</emphasis>[[+]<emphasis>pathname</emphasis>[<emphasis

View File

@@ -28,7 +28,7 @@
# #
# On the target system (the system where the firewall program is to run): # On the target system (the system where the firewall program is to run):
# #
# [ IPTABLES=<iptables binary> ] [ MODULESDIR=<kernel modules directory> ] [ MODULE_SUFFIX="<module suffix list>" ] shorecap > capabilities # [ IPTABLES=<iptables binary> ] [ MODULESDIR=<kernel modules directory> ] shorecap > capabilities
# #
# Now move the capabilities file to the compilation system. The file must # Now move the capabilities file to the compilation system. The file must
# be placed in a directory on the CONFIG_PATH to be used when compiling firewalls # be placed in a directory on the CONFIG_PATH to be used when compiling firewalls
@@ -38,7 +38,6 @@
# #
# IPTABLES - iptables # IPTABLES - iptables
# MODULESDIR - /lib/modules/$(uname -r)/kernel/net/ipv4/netfilter # MODULESDIR - /lib/modules/$(uname -r)/kernel/net/ipv4/netfilter
# MODULE_SUFFIX - "o gz xz ko o.gz o.xz ko.gz ko.xz"
# #
# Shorewall need not be installed on the target system to run shorecap. If the '-e' flag is # Shorewall need not be installed on the target system to run shorecap. If the '-e' flag is
# used during firewall compilation, then the generated firewall program will likewise not # used during firewall compilation, then the generated firewall program will likewise not

View File

@@ -190,8 +190,6 @@ MARK_IN_FORWARD_CHAIN=No
MINIUPNPD=No MINIUPNPD=No
MODULE_SUFFIX="ko ko.xz"
MUTEX_TIMEOUT=60 MUTEX_TIMEOUT=60
OPTIMIZE=All OPTIMIZE=All

View File

@@ -191,8 +191,6 @@ MARK_IN_FORWARD_CHAIN=No
MINIUPNPD=No MINIUPNPD=No
MODULE_SUFFIX="ko ko.xz"
MUTEX_TIMEOUT=60 MUTEX_TIMEOUT=60
OPTIMIZE=All OPTIMIZE=All

View File

@@ -190,8 +190,6 @@ MARK_IN_FORWARD_CHAIN=No
MINIUPNPD=No MINIUPNPD=No
MODULE_SUFFIX="ko ko.xz"
MUTEX_TIMEOUT=60 MUTEX_TIMEOUT=60
OPTIMIZE=All OPTIMIZE=All

View File

@@ -190,8 +190,6 @@ MARK_IN_FORWARD_CHAIN=No
MINIUPNPD=No MINIUPNPD=No
MODULE_SUFFIX="ko ko.xz"
MUTEX_TIMEOUT=60 MUTEX_TIMEOUT=60
OPTIMIZE=All OPTIMIZE=All

View File

@@ -190,8 +190,6 @@ MARK_IN_FORWARD_CHAIN=No
MINIUPNPD=No MINIUPNPD=No
MODULE_SUFFIX="ko ko.xz"
MUTEX_TIMEOUT=60 MUTEX_TIMEOUT=60
OPTIMIZE=All OPTIMIZE=All