diff --git a/Shorewall/Perl/Shorewall/Config.pm b/Shorewall/Perl/Shorewall/Config.pm index 8433159cf..8858fbeb0 100644 --- a/Shorewall/Perl/Shorewall/Config.pm +++ b/Shorewall/Perl/Shorewall/Config.pm @@ -3437,6 +3437,17 @@ sub generate_aux_config() { emit '}'; } + my $fn = find_file 'dumpfilter'; + + if ( -f $fn ) { + emit( '', + 'dump_filter() {' ); + push_indent; + append_file( $fn,1 ) or emit 'cat -'; + pop_indent; + emit '}'; + } + finalize_aux_config; } diff --git a/Shorewall/lib.cli b/Shorewall/lib.cli index 6cfcefcb5..bf1012997 100644 --- a/Shorewall/lib.cli +++ b/Shorewall/lib.cli @@ -811,10 +811,40 @@ show_command() { esac } +# +# Dump Filter - For Shorewall-lite, if there was a dumpfilter file at compile-time, +# then the compiler generated another version of this function and +# embedded it in the firewall.conf file. That version supersedes this +# one. +# +dump_filter() { + local filter + local command + local first + + command=${SHOREWALL_SHELL} + + filter=$(find_file dumpfilter) + + if [ -f $filter ]; then + first=$(head -n1 $filter) + + case $first in + \#!*) + command=${first#\#!} + ;; + esac + + $command $filter + else + cat - + fi +} + # # Dump Command Executor # -dump_command() { +do_dump_command() { local finished finished=0 @@ -1068,6 +1098,10 @@ read_yesno_with_timeout() { fi } +dump_command() { + do_dump_command | dump_filter +} + # # Print a heading with leading and trailing black lines # diff --git a/Shorewall6/lib.cli b/Shorewall6/lib.cli index 9294f9c5e..1da8b49bf 100644 --- a/Shorewall6/lib.cli +++ b/Shorewall6/lib.cli @@ -686,10 +686,40 @@ show_command() { esac } +# +# Dump Filter - For Shorewall-lite, if there was a dumpfilter file at compile-time, +# then the compiler generated another version of this function and +# embedded it in the firewall.conf file. That version supersedes this +# one. +# +dump_filter() { + local filter + local command + local first + + command=${SHOREWALL_SHELL} + + filter=$(find_file dumpfilter) + + if [ -f $filter ]; then + first=$(head -n1 $filter) + + case $first in + \#!*) + command=${first#\#!} + ;; + esac + + $command $filter + else + cat - + fi +} + # # Dump Command Executor # -dump_command() { +do_dump_command() { local finished finished=0 @@ -833,6 +863,10 @@ dump_command() { fi } +dump_command() { + do_dump_command | dump_filter +} + # # Restore Comand Executor #