diff --git a/Shorewall-lite/shorewall-lite b/Shorewall-lite/shorewall-lite index c8862827c..0d8a09a62 100755 --- a/Shorewall-lite/shorewall-lite +++ b/Shorewall-lite/shorewall-lite @@ -501,16 +501,10 @@ g_product="Shorewall Lite" [ -d $VARDIR ] || mkdir -p $VARDIR || fatal_error "Unable to create $VARDIR" -LIBRARIES="$SHAREDIR/lib.base $SHAREDIR/lib.cli" version_file=$SHAREDIR/version -for library in $LIBRARIES; do - if [ -f $library ]; then - . $library - else - echo "Installation error: $library does not exist!" >&2 - exit 2 - fi +for library in ${SHAREDIR}/lib.*; do + . $library done ensure_config_path diff --git a/Shorewall-lite/shorewall-lite.spec b/Shorewall-lite/shorewall-lite.spec index 9633b87ad..d678b9d56 100644 --- a/Shorewall-lite/shorewall-lite.spec +++ b/Shorewall-lite/shorewall-lite.spec @@ -88,6 +88,7 @@ fi %attr(- ,root,root) /usr/share/shorewall-lite/functions %attr(0644,root,root) /usr/share/shorewall-lite/lib.base %attr(0644,root,root) /usr/share/shorewall-lite/lib.cli +%attr(0644,root,root) /usr/share/shorewall-lite/lib.run %attr(0644,root,root) /usr/share/shorewall-lite/modules %attr(0544,root,root) /usr/share/shorewall-lite/shorecap %attr(0755,root,root) /usr/share/shorewall-lite/wait4ifup diff --git a/Shorewall/Perl/Shorewall/Compiler.pm b/Shorewall/Perl/Shorewall/Compiler.pm index 0feaa8c84..78965c09c 100644 --- a/Shorewall/Perl/Shorewall/Compiler.pm +++ b/Shorewall/Perl/Shorewall/Compiler.pm @@ -91,6 +91,7 @@ sub generate_script_1() { } else { copy $globals{SHAREDIRPL} . 'prog.header6'; } + copy $globals{SHAREDIR} . 'lib.run'; } my $lib = find_file 'lib.private'; diff --git a/Shorewall/Perl/prog.header b/Shorewall/Perl/prog.header index 744d02e0f..e2c701c47 100644 --- a/Shorewall/Perl/prog.header +++ b/Shorewall/Perl/prog.header @@ -1172,86 +1172,6 @@ startup_error() # $* = Error Message exit 2 } -# -# Get the Shorewall version of the passed script -# -get_script_version() { # $1 = script - local temp - local version - local ifs - - temp=$( $SHOREWALL_SHELL $1 version | sed 's/-.*//' ) - - if [ $? -ne 0 ]; then - version=0 - else - ifs=$IFS - IFS=. - temp=$(echo $temp) - IFS=$ifs - - for temp in $temp; do - version=${version}$(printf '%02d' $temp) - done - fi - - echo $version -} - - -# -# Do required exports or create the required option string and run the passed script using -# $SHOREWALL_SHELL -# -run_it() { - local script - local options - local version - - export VARDIR - - script=$1 - shift - - version=$(get_script_version $script) - - if [ $version -lt 040408 ]; then - # - # Old script that doesn't understand 4.4.8 script options - # - export RESTOREFILE - export VERBOSITY - export NOROUTES=$g_noroutes - export PURGE=$g_purge - export TIMESTAMP=$g_timestamp - export RECOVERING=$g_recovering - - if [ "$g_product" != Shorewall ]; then - # - # Shorewall Lite - # - export LOGFORMAT - export IPTABLES - fi - else - # - # 4.4.8 or later -- no additional exports required - # - options='-' - - [ -n "$g_noroutes" ] && options=${options}n - [ -n "$g_timestamp" ] && options=${options}t - [ -n "$g_purge" ] && options=${options}p - [ -n "$g_recovering" ] && options=${options}r - - options="${options}V $VERBOSITY" - - [ -n "$RESTOREFILE" ] && options="${options} -R $RESTOREFILE" - fi - - $SHOREWALL_SHELL $script $options $@ -} - # # Run iptables and if an error occurs, stop/restore the firewall # diff --git a/Shorewall/Perl/prog.header6 b/Shorewall/Perl/prog.header6 index 6aca49738..411af581a 100644 --- a/Shorewall/Perl/prog.header6 +++ b/Shorewall/Perl/prog.header6 @@ -1023,86 +1023,6 @@ startup_error() # $* = Error Message exit 2 } -# -# Get the Shorewall version of the passed script -# -get_script_version() { # $1 = script - local temp - local version - local ifs - - temp=$( $SHOREWALL_SHELL $1 version | sed 's/-.*//' ) - - if [ $? -ne 0 ]; then - version=0 - else - ifs=$IFS - IFS=. - temp=$(echo $temp) - IFS=$ifs - - for temp in $temp; do - version=${version}$(printf '%02d' $temp) - done - fi - - echo $version -} - - -# -# Do required exports and create the required option string and run the passed script using -# $SHOREWALL_SHELL -# -run_it() { - local script - local options - local version - - export VARDIR - - script=$1 - shift - - version=$(get_script_version $script) - - if [ $version -lt 040408 ]; then - # - # Old script that doesn't understand 4.4.8 options - # - export RESTOREFILE - export VERBOSITY - export NOROUTES=$g_noroutes - export PURGE=$g_purge - export TIMESTAMP=$g_timestamp - export RECOVERING=$g_recovering - - if [ "$g_product" != Shorewall6 ]; then - # - # Shorewall Lite - # - export LOGFORMAT - export IP6TABLES - fi - else - # - # 4.4.8 or later -- no additional exports required - # - options='-' - - [ -n "$g_noroutes" ] && options=${options}n - [ -n "$g_timesamp" ] && options=${options}t - [ -n "$g_purge" ] && options=${options}p - [ -n "$g_recovering" ] && options=${options}r - - options="${options}V $VERBOSITY" - - [ -n "$RESTOREFILE" ] && options="${options} -R $RESTOREFILE" - fi - - $SHOREWALL_SHELL $script $options $@ -} - # # Run iptables and if an error occurs, stop/restore the firewall # diff --git a/Shorewall/install.sh b/Shorewall/install.sh index 1bcc91a73..ce7235105 100755 --- a/Shorewall/install.sh +++ b/Shorewall/install.sh @@ -650,6 +650,15 @@ if [ -z "$SPARSE" -a ! -f ${PREFIX}/etc/shorewall/lib.private ]; then echo "Private library file installed as ${PREFIX}/etc/shorewall/lib.private" fi # +# Install the run library file +# +run_install $OWNERSHIP -m 0644 configfiles/lib.run ${PREFIX}/usr/share/shorewall/configfiles/lib.run + +if [ -z "$SPARSE" -a ! -f ${PREFIX}/etc/shorewall/lib.run ]; then + run_install $OWNERSHIP -m 0600 configfiles/lib.run ${PREFIX}/etc/shorewall/lib.run + echo "Run library file installed as ${PREFIX}/etc/shorewall/lib.run" +fi +# # Install the Started file # run_install $OWNERSHIP -m 0644 configfiles/started ${PREFIX}/usr/share/shorewall/configfiles/started diff --git a/Shorewall/lib.cli b/Shorewall/lib.cli index c895c004e..d9e44559f 100644 --- a/Shorewall/lib.cli +++ b/Shorewall/lib.cli @@ -4,7 +4,7 @@ # # This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt] # -# (c) 1999,2000,2001,2002,2003,2004,2005,2006,2007 - Tom Eastep (teastep@shorewall.net) +# (c) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010 - Tom Eastep (teastep@shorewall.net) # # Complete documentation is available at http://shorewall.net # @@ -35,84 +35,6 @@ fatal_error() # $@ = Message } # -# Get the Shorewall version of the passed script -# -get_script_version() { # $1 = script - local temp - local version - local ifs - - temp=$( $SHOREWALL_SHELL $1 version | sed 's/-.*//' ) - - if [ $? -ne 0 ]; then - version=0 - else - ifs=$IFS - IFS=. - temp=$(echo $temp) - IFS=$ifs - - for temp in $temp; do - version=${version}$(printf '%02d' $temp) - done - fi - - echo $version -} - -# -# Do required exports or create the required option string and run the passed script using -# $SHOREWALL_SHELL -# -run_it() { - local script - local options - local version - - export VARDIR - - script=$1 - shift - - version=$(get_script_version $script) - - if [ $version -lt 040408 ]; then - # - # Old script that doesn't understand 4.4.8 script options - # - export RESTOREFILE - export VERBOSITY - export NOROUTES=$g_noroutes - export PURGE=$g_purge - export TIMESTAMP=$g_timestamp - export RECOVERING=$g_recovering - - if [ "$g_product" != Shorewall ]; then - # - # Shorewall Lite - # - export LOGFORMAT - export IPTABLES - fi - else - # - # 4.4.8 or later -- no additional exports required - # - options='-' - - [ -n "$g_noroutes" ] && options=${options}n - [ -n "$g_timestamp" ] && options=${options}t - [ -n "$g_purge" ] && options=${options}p - [ -n "$g_recovering" ] && options=${options}r - - options="${options}V $VERBOSITY" - - [ -n "$RESTOREFILE" ] && options="${options} -R $RESTOREFILE" - fi - - $SHOREWALL_SHELL $script $options $@ -} - # Display a chain if it exists # diff --git a/Shorewall/lib.run b/Shorewall/lib.run new file mode 100644 index 000000000..dea383469 --- /dev/null +++ b/Shorewall/lib.run @@ -0,0 +1,107 @@ +#!/bin/sh +# +# Shorewall 4.4 -- /usr/share/shorewall/lib.run. +# +# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt] +# +# (c) 2010 - Tom Eastep (teastep@shorewall.net) +# +# Complete documentation is available at http://shorewall.net +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of Version 2 of the GNU General Public License +# as published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# +# This library contains the wrapper code for running a generated script. +# + +# +# Get the Shorewall version of the passed script +# +get_script_version() { # $1 = script + local temp + local version + local ifs + + temp=$( $SHOREWALL_SHELL $1 version | sed 's/-.*//' ) + + if [ $? -ne 0 ]; then + version=0 + else + ifs=$IFS + IFS=. + temp=$(echo $temp) + IFS=$ifs + + for temp in $temp; do + version=${version}$(printf '%02d' $temp) + done + fi + + echo $version +} + +# +# Do required exports or create the required option string and run the passed script using +# $SHOREWALL_SHELL +# +run_it() { + local script + local options + local version + + export VARDIR + + script=$1 + shift + + version=$(get_script_version $script) + + if [ $version -lt 040408 ]; then + # + # Old script that doesn't understand 4.4.8 script options + # + export RESTOREFILE + export VERBOSITY + export NOROUTES=$g_noroutes + export PURGE=$g_purge + export TIMESTAMP=$g_timestamp + export RECOVERING=$g_recovering + + if [ "$g_product" != Shorewall ]; then + # + # Shorewall Lite + # + export LOGFORMAT + export IPTABLES + fi + else + # + # 4.4.8 or later -- no additional exports required + # + options='-' + + [ -n "$g_noroutes" ] && options=${options}n + [ -n "$g_timestamp" ] && options=${options}t + [ -n "$g_purge" ] && options=${options}p + [ -n "$g_recovering" ] && options=${options}r + + options="${options}V $VERBOSITY" + + [ -n "$RESTOREFILE" ] && options="${options} -R $RESTOREFILE" + fi + + $SHOREWALL_SHELL $script $options $@ +} +################################################################################# +# End of lib.run +################################################################################# diff --git a/Shorewall/shorewall b/Shorewall/shorewall index 5291449d2..0eb3858f2 100755 --- a/Shorewall/shorewall +++ b/Shorewall/shorewall @@ -1562,14 +1562,8 @@ fi g_firewall=${VARDIR}/firewall -libraries="$SHAREDIR/lib.base $SHAREDIR/lib.cli" -for library in $libraries; do - if [ -f $library ]; then - . $library - else - echo "$library does not exist!" >&2 - exit 2 - fi +for library in ${SHAREDIR}/lib.*; do + . $library done version_file=$SHAREDIR/version diff --git a/Shorewall/shorewall.spec b/Shorewall/shorewall.spec index aaeb55629..cda86607d 100644 --- a/Shorewall/shorewall.spec +++ b/Shorewall/shorewall.spec @@ -89,6 +89,7 @@ fi %attr(- ,root,root) /usr/share/shorewall/functions %attr(0644,root,root) /usr/share/shorewall/lib.base %attr(0644,root,root) /usr/share/shorewall/lib.cli +%attr(0644,root,root) /usr/share/shorewall/lib.run %attr(0644,root,root) /usr/share/shorewall/macro.* %attr(0644,root,root) /usr/share/shorewall/modules %attr(0644,root,root) /usr/share/shorewall/helpers diff --git a/Shorewall6-lite/shorewall6-lite b/Shorewall6-lite/shorewall6-lite index a292f3401..ae4efea1f 100755 --- a/Shorewall6-lite/shorewall6-lite +++ b/Shorewall6-lite/shorewall6-lite @@ -486,16 +486,10 @@ g_product="Shorewall6 Lite" [ -d $VARDIR ] || mkdir -p $VARDIR || fatal_error "Unable to create $VARDIR" -libraries="$SHAREDIR/lib.base $SHAREDIR/lib.cli" version_file=$SHAREDIR/version -for library in $libraries; do - if [ -f $library ]; then - . $library - else - echo "Installation error: $library does not exist!" >&2 - exit 2 - fi +for library in ${SHAREDIR}/lib.*; do + . $library done ensure_config_path diff --git a/Shorewall6-lite/shorewall6-lite.spec b/Shorewall6-lite/shorewall6-lite.spec index f52dae679..f598c6de0 100644 --- a/Shorewall6-lite/shorewall6-lite.spec +++ b/Shorewall6-lite/shorewall6-lite.spec @@ -79,6 +79,7 @@ fi %attr(- ,root,root) /usr/share/shorewall6-lite/functions %attr(0644,root,root) /usr/share/shorewall6-lite/lib.base %attr(0644,root,root) /usr/share/shorewall6-lite/lib.cli +%attr(0644,root,root) /usr/share/shorewall6-lite/lib.run %attr(0644,root,root) /usr/share/shorewall6-lite/modules %attr(0544,root,root) /usr/share/shorewall6-lite/shorecap %attr(0755,root,root) /usr/share/shorewall6-lite/wait4ifup diff --git a/Shorewall6/lib.cli b/Shorewall6/lib.cli index 0a2cfdeb2..5440c8574 100644 --- a/Shorewall6/lib.cli +++ b/Shorewall6/lib.cli @@ -35,84 +35,6 @@ fatal_error() # $@ = Message } # -# Get the Shorewall version of the passed script -# -get_script_version() { # $1 = script - local temp - local version - local ifs - - temp=$( $SHOREWALL_SHELL $1 version | sed 's/-.*//' ) - - if [ $? -ne 0 ]; then - version=0 - else - ifs=$IFS - IFS=. - temp=$(echo $temp) - IFS=$ifs - - for temp in $temp; do - version=${version}$(printf '%02d' $temp) - done - fi - - echo $version -} - -# -# Do required exports and create the required option string and run the passed script using -# $SHOREWALL_SHELL -# -run_it() { - local script - local options - local version - - export VARDIR - - script=$1 - shift - - version=$(get_script_version $script) - - if [ $version -lt 040408 ]; then - # - # Old script that doesn't understand 4.4.8 script options - # - export RESTOREFILE= - export VERBOSITY - export NOROUTES=$g_noroutes - export PURGE=$g_purge - export TIMESTAMP=$g_timestamp - export RECOVERING=$g_recovering - - if [ "$g_product" != Shorewall6 ]; then - # - # Shorewall6 Lite - # - export LOGFORMAT - export IP6TABLES - fi - else - # - # 4.4.8 or later -- no additional exports required - # - options='-' - - [ -n "$g_noroutes" ] && options=${options}n - [ -n "$g_timestamp" ] && options=${options}t - [ -n "$g_purge" ] && options=${options}p - [ -n "$g_recovering" ] && options=${options}r - - options="${options}V $VERBOSITY" - - [ -n "$RESTOREFILE" ] && options="${options} -R $RESTOREFILE" - fi - - $SHOREWALL_SHELL $script $options $@ -} - # Display a chain if it exists # diff --git a/Shorewall6/lib.run b/Shorewall6/lib.run new file mode 100644 index 000000000..ad906041e --- /dev/null +++ b/Shorewall6/lib.run @@ -0,0 +1,106 @@ +#!/bin/sh +# +# Shorewall 4.4 -- /usr/share/shorewall6/lib.run. +# +# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt] +# +# (c) 2010 - Tom Eastep (teastep@shorewall.net) +# +# Complete documentation is available at http://shorewall.net +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of Version 2 of the GNU General Public License +# as published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# +# This library contains the wrapper code for running a generated script. +# +# +# Get the Shorewall version of the passed script +# +get_script_version() { # $1 = script + local temp + local version + local ifs + + temp=$( $SHOREWALL_SHELL $1 version | sed 's/-.*//' ) + + if [ $? -ne 0 ]; then + version=0 + else + ifs=$IFS + IFS=. + temp=$(echo $temp) + IFS=$ifs + + for temp in $temp; do + version=${version}$(printf '%02d' $temp) + done + fi + + echo $version +} + +# +# Do required exports and create the required option string and run the passed script using +# $SHOREWALL_SHELL +# +run_it() { + local script + local options + local version + + export VARDIR + + script=$1 + shift + + version=$(get_script_version $script) + + if [ $version -lt 040408 ]; then + # + # Old script that doesn't understand 4.4.8 script options + # + export RESTOREFILE= + export VERBOSITY + export NOROUTES=$g_noroutes + export PURGE=$g_purge + export TIMESTAMP=$g_timestamp + export RECOVERING=$g_recovering + + if [ "$g_product" != Shorewall6 ]; then + # + # Shorewall6 Lite + # + export LOGFORMAT + export IP6TABLES + fi + else + # + # 4.4.8 or later -- no additional exports required + # + options='-' + + [ -n "$g_noroutes" ] && options=${options}n + [ -n "$g_timestamp" ] && options=${options}t + [ -n "$g_purge" ] && options=${options}p + [ -n "$g_recovering" ] && options=${options}r + + options="${options}V $VERBOSITY" + + [ -n "$RESTOREFILE" ] && options="${options} -R $RESTOREFILE" + fi + + $SHOREWALL_SHELL $script $options $@ +} +################################################################################# +# End of lib.run +################################################################################# diff --git a/Shorewall6/shorewall6 b/Shorewall6/shorewall6 index f0082dcac..9f96127b8 100755 --- a/Shorewall6/shorewall6 +++ b/Shorewall6/shorewall6 @@ -1482,14 +1482,8 @@ fi g_firewall=${VARDIR}/firewall -libraries="$SHAREDIR/lib.base $SHAREDIR/lib.cli" -for library in $libraries; do - if [ -f $library ]; then - . $library - else - echo "$library does not exist!" >&2 - exit 2 - fi +for library in ${SHAREDIR}/lib.*; do + . $library done version_file=$SHAREDIR/version diff --git a/Shorewall6/shorewall6.spec b/Shorewall6/shorewall6.spec index f0bfc2048..b903b7e91 100644 --- a/Shorewall6/shorewall6.spec +++ b/Shorewall6/shorewall6.spec @@ -82,6 +82,7 @@ fi %attr(- ,root,root) /usr/share/shorewall6/functions %attr(0644,root,root) /usr/share/shorewall6/lib.base %attr(0644,root,root) /usr/share/shorewall6/lib.cli +%attr(0644,root,root) /usr/share/shorewall6/lib.run %attr(0644,root,root) /usr/share/shorewall6/macro.* %attr(0644,root,root) /usr/share/shorewall6/modules %attr(0644,root,root) /usr/share/shorewall6/helpers