mirror of
https://gitlab.com/shorewall/code.git
synced 2024-12-18 04:11:22 +01:00
Improve undefined interface checking
git-svn-id: https://shorewall.svn.sourceforge.net/svnroot/shorewall/trunk@1225 fbd18981-670d-0410-9b5c-8dc0c1a9a2bb
This commit is contained in:
parent
9ddf679cf6
commit
058de7b9b1
@ -483,11 +483,27 @@ match_dest_hosts()
|
||||
# Similarly, the source or destination in a rule can be qualified by a device name. If
|
||||
# the device is defined in /etc/shorewall/interfaces then a normal interface match is
|
||||
# generated (-i or -o); otherwise, a physdev match is generated.
|
||||
#-------------------------------------------------------------------------------------
|
||||
#
|
||||
# loosely match the passed interface with those in /etc/shorewall/interfaces.
|
||||
#
|
||||
known_interface() # $1 = interface name
|
||||
{
|
||||
local iface
|
||||
|
||||
for iface in $all_interfaces ; do
|
||||
if if_match $iface $1 ; then
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
match_source_dev()
|
||||
{
|
||||
if [ -n "$BRIDGING" ]; then
|
||||
list_search $1 $all_interfaces && echo -i $1 || physdev_echo "--physdev-in $1"
|
||||
known_interface $1 && echo -i $1 || physdev_echo "--physdev-in $1"
|
||||
else
|
||||
echo -i $1
|
||||
fi
|
||||
@ -496,7 +512,7 @@ match_source_dev()
|
||||
match_dest_dev()
|
||||
{
|
||||
if [ -n "$BRIDGING" ]; then
|
||||
list_search $1 $all_interfaces && echo -o $1 || physdev_echo "--physdev-out $1"
|
||||
known_interface $1 && echo -o $1 || physdev_echo "--physdev-out $1"
|
||||
else
|
||||
echo -o $1
|
||||
fi
|
||||
@ -652,10 +668,10 @@ validate_interfaces_file() {
|
||||
wildcard=
|
||||
|
||||
case $interface in
|
||||
*:*)
|
||||
*:*|+)
|
||||
startup_error "Invalid Interface Name: $interface"
|
||||
;;
|
||||
*+*)
|
||||
*+)
|
||||
wildcard=Yes
|
||||
;;
|
||||
esac
|
||||
|
@ -502,11 +502,11 @@ ip_vlsm() {
|
||||
|
||||
#
|
||||
# Chain name base for an interface -- replace all periods with underscores in the passed name.
|
||||
# The result is echoed (less "+" and anything following).
|
||||
# The result is echoed (less trailing "+").
|
||||
#
|
||||
chain_base() #$1 = interface
|
||||
{
|
||||
local c=${1%%+*}
|
||||
local c=${1%%+}
|
||||
|
||||
while true; do
|
||||
case $c in
|
||||
@ -524,31 +524,18 @@ chain_base() #$1 = interface
|
||||
done
|
||||
}
|
||||
|
||||
#
|
||||
# Remove trailing digits from a name
|
||||
#
|
||||
strip_trailing_digits() {
|
||||
echo $1 | sed s'/[0-9].*$//'
|
||||
}
|
||||
|
||||
#
|
||||
# Loosly Match the name of an interface
|
||||
#
|
||||
|
||||
if_match() # $1 = Name in interfaces file - may end in "+"
|
||||
# $2 = Name from routing table
|
||||
# $2 = Full interface name - may also end in "+"
|
||||
{
|
||||
local if_file=$1
|
||||
local rt_table=$2
|
||||
local pattern=${1%+}
|
||||
local interface=${2%+}
|
||||
|
||||
case $if_file in
|
||||
*+)
|
||||
test "$(strip_trailing_digits $rt_table)" = "${if_file%+}"
|
||||
;;
|
||||
*)
|
||||
test "$rt_table" = "$if_file"
|
||||
;;
|
||||
esac
|
||||
test "x${interface:0:${#pattern}}" = "x${pattern}"
|
||||
|
||||
}
|
||||
|
||||
#
|
||||
|
Loading…
Reference in New Issue
Block a user