diff --git a/STABLE2/changelog.txt b/STABLE2/changelog.txt index e16074461..02bee8add 100644 --- a/STABLE2/changelog.txt +++ b/STABLE2/changelog.txt @@ -89,3 +89,5 @@ Changes in 2.0.12 1) Correct typo in shorewall.conf. 2) Fix "shorewall add" and "shorewall delete" with bridging. + +3) Implement variable expansion in INCLUDE directives diff --git a/STABLE2/functions b/STABLE2/functions index e3bbb5023..5b4ff3322 100755 --- a/STABLE2/functions +++ b/STABLE2/functions @@ -52,9 +52,9 @@ qt() # # Perform variable substitution on the passed argument and echo the result # -expand() # $1 = contents of variable which may be the name of another variable +expand() # $@ = contents of variable which may be the name of another variable { - eval echo \"$1\" + eval echo \"$@\" } # @@ -104,7 +104,8 @@ ensure_config_path() { # # Find a File -- For relative file name, look first in $SHOREWALL_DIR then in /etc/shorewall # -find_file() +find_file +() { local saveifs= directory @@ -434,7 +435,7 @@ read_file() # $1 = file name, $2 = nest count while read first rest; do if [ "x$first" = "xINCLUDE" ]; then if [ $2 -lt 4 ]; then - read_file $(find_file ${rest%#*}) $(($2 + 1)) + read_file $(find_file $(expand ${rest%#*})) $(($2 + 1)) else echo " WARNING: INCLUDE in $1 ignored (nested too deeply)" >&2 fi @@ -452,7 +453,7 @@ read_file() # $1 = file name, $2 = nest count # Function for including one file into another # INCLUDE() { - . $(find_file $@) + . $(find_file $(expand $@)) } # diff --git a/STABLE2/releasenotes.txt b/STABLE2/releasenotes.txt index 513430141..c8bc61107 100644 --- a/STABLE2/releasenotes.txt +++ b/STABLE2/releasenotes.txt @@ -204,3 +204,17 @@ Problems corrected in 2.0.12 shorewall add br0:eth2:192.168.1.3 OK shorewall delete br0:eth2:192.168.1.3 OK +----------------------------------------------------------------------- +New Features in 2.0.12 + +1) Variable expansion may now be used with the INCLUDE directive. + + Example: + + /etc/shorewall/params + + FILE=/etc/foo/bar + + Any other config file: + + INCLUDE $FILE diff --git a/Shorewall2/changelog.txt b/Shorewall2/changelog.txt index 7559fa0c5..e60d1df09 100644 --- a/Shorewall2/changelog.txt +++ b/Shorewall2/changelog.txt @@ -158,3 +158,6 @@ Changes since 2.0.3 76) Add "shorewall show zones" 77) Remove dependency of "show zones" on dynamic zones. + +78) Implement variable expansion in INCLUDE directives + diff --git a/Shorewall2/functions b/Shorewall2/functions index 628fbdd7b..80c5ef2d5 100755 --- a/Shorewall2/functions +++ b/Shorewall2/functions @@ -73,9 +73,9 @@ qt() # # Perform variable substitution on the passed argument and echo the result # -expand() # $1 = contents of variable which may be the name of another variable +expand() # $@ = contents of variable which may be the name of another variable { - eval echo \"$1\" + eval echo \"$@\" } # @@ -459,7 +459,7 @@ read_file() # $1 = file name, $2 = nest count while read first rest; do if [ "x$first" = "xINCLUDE" ]; then if [ $2 -lt 4 ]; then - read_file $(find_file ${rest%#*}) $(($2 + 1)) + read_file $(find_file $(expand ${rest%#*})) $(($2 + 1)) else echo " WARNING: INCLUDE in $1 ignored (nested too deeply)" >&2 fi @@ -477,7 +477,7 @@ read_file() # $1 = file name, $2 = nest count # Function for including one file into another # INCLUDE() { - . $(find_file $@) + . $(find_file $(expand $@)) } # diff --git a/Shorewall2/releasenotes.txt b/Shorewall2/releasenotes.txt index 2edb27001..53ec86e9b 100755 --- a/Shorewall2/releasenotes.txt +++ b/Shorewall2/releasenotes.txt @@ -734,4 +734,14 @@ New Features: ursa:/etc/shorewall # +32) Variable expansion may now be used with the INCLUDE directive. + Example: + + /etc/shorewall/params + + FILE=/etc/foo/bar + + Any other config file: + + INCLUDE $FILE