Correct the 'show filter' command

- Also consolidate some awkward code

Signed-off-by: Tom Eastep <teastep@shorewall.net>
This commit is contained in:
Tom Eastep 2024-03-29 15:49:41 -07:00
parent 90444bdc44
commit 9b1ef03c49

View File

@ -1002,27 +1002,6 @@ show_table() {
$g_tool -t $table -L $g_ipt_options | $output_filter $g_tool -t $table -L $g_ipt_options | $output_filter
} }
show_nat() {
echo "$g_product $SHOREWALL_VERSION NAT Table at $g_hostname - $(date)"
echo
show_reset
$g_tool -t nat -L $g_ipt_options | $output_filter
}
show_raw() {
echo "$g_product $SHOREWALL_VERSION RAW Table at $g_hostname - $(date)"
echo
show_reset
$g_tool -t raw -L $g_ipt_options | $output_filter
}
show_mangle() {
echo "$g_product $SHOREWALL_VERSION Mangle Table at $g_hostname - $(date)"
echo
show_reset
$g_tool -t mangle -L $g_ipt_options | $output_filter
}
show_classifiers_command() { show_classifiers_command() {
echo "$g_product $SHOREWALL_VERSION Classifiers at $g_hostname - $(date)" echo "$g_product $SHOREWALL_VERSION Classifiers at $g_hostname - $(date)"
echo echo
@ -1248,7 +1227,7 @@ show_command() {
local finished local finished
finished=0 finished=0
local table local table
table=filter table=
local table_given local table_given
table_given= table_given=
local output_filter local output_filter
@ -1361,20 +1340,31 @@ show_command() {
only_root only_root
eval show_connections $@ $g_pager eval show_connections $@ $g_pager
;; ;;
nat) filter|nat|raw|mangle)
only_root only_root
[ $# -gt 1 ] && too_many_arguments $2 [ $# -gt 1 ] && too_many_arguments $2
eval show_nat $g_pager
if [ -n "$table_given" ]; then
if [ $table != $1 ] ; then
fatal_error "\"$1\" is not allowed when \"-t $table\" is given"
fi
else
table=$1
fi
eval show_table $g_pager
;; ;;
raw) tos)
only_root only_root
[ $# -gt 1 ] && too_many_arguments $2 [ $# -gt 1 ] && too_many_arguments $2
eval show_raw $g_pager
;; if [ -z "$table_given" ] ; then
tos|mangle) table=mangle
only_root else
[ $# -gt 1 ] && too_many_arguments $2 [ "$table" = mangle ] || fatal_error "\"show tos\" is only valid in the mangle table"
eval show_mangle $g_pager fi
eval show_table $g_pager
;; ;;
log) log)
[ $# -gt 2 ] && too_many_arguments $2 [ $# -gt 2 ] && too_many_arguments $2
@ -1601,15 +1591,20 @@ show_command() {
return; return;
fi fi
[ -n "$table_given" ] || for chain in $*; do if [ -z "$table_given" ]; then
if ! qt $g_tool -t $table -L $chain $g_ipt_options; then table=filter
error_message "ERROR: Chain '$chain' is not recognized by $g_tool."
exit 1 for chain in $*; do
fi if ! qt $g_tool -t $table -L $chain $g_ipt_options; then
done error_message "ERROR: Chain '$chain' is not recognized by $g_tool."
exit 1
fi
done
fi
eval show_chains $@ $g_pager eval show_chains $@ $g_pager
else else
[ -n "$table_given" ] || table=filter
eval show_table $g_pager eval show_table $g_pager
fi fi
;; ;;