From 54a5a111a65f219532fafa14fe435e172c7f057f Mon Sep 17 00:00:00 2001 From: teastep Date: Sun, 31 Jul 2005 17:12:04 +0000 Subject: [PATCH] Make separate_list handle enclosures in a more general way git-svn-id: https://shorewall.svn.sourceforge.net/svnroot/shorewall/trunk@2437 fbd18981-670d-0410-9b5c-8dc0c1a9a2bb --- Shorewall/functions | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/Shorewall/functions b/Shorewall/functions index 3d543fb9f..e3744722a 100755 --- a/Shorewall/functions +++ b/Shorewall/functions @@ -165,16 +165,17 @@ separate_list() { local firstpart local lastpart local enclosure - # - # There's been whining about us not catching embedded white space in - # comma-separated lists. This is an attempt to snag some of the cases. - # - # The 'terminator' function will be set by the 'firewall' script to - # either 'startup_error' or 'fatal_error' depending on the command and - # command phase - # + case "$list" in *,|,*|*,,*|*[[:space:]]*) + # + # There's been whining about us not catching embedded white space in + # comma-separated lists. This is an attempt to snag some of the cases. + # + # The 'terminator' function will be set by the 'firewall' script to + # either 'startup_error' or 'fatal_error' depending on the command and + # command phase + # [ -n "$terminator" ] && \ $terminator "Invalid comma-separated list \"$@\"" echo "Warning -- invalid comma-separated list \"$@\"" >&2 @@ -186,15 +187,29 @@ separate_list() { # firstpart=${list%%\[*} lastpart=${list#*\[} - enclosure=${lastpart%\]*} + enclosure=${lastpart%%\]*} lastpart=${lastpart#*\]} case $lastpart in \,*) - echo "$(separate_list $firstpart)[$enclosure] $(separate_list ${lastpart#,})" + case $firstpart in + *\,) + echo "$(separate_list ${firstpart%,}) [$enclosure] $(separate_list ${lastpart#,})" + ;; + *) + echo "$(separate_list $firstpart)[$enclosure] $(separate_list ${lastpart#,})" + ;; + esac ;; *) - echo "$(separate_list $firstpart)[$enclosure]$(separate_list $lastpart)" - ;; + case $firstpart in + *\,) + echo "$(separate_list ${firstpart%,}) [$enclosure]$(separate_list $lastpart)" + ;; + *) + echo "$(separate_list $firstpart)[$enclosure]$(separate_list $lastpart)" + ;; + esac + ;; esac return ;;