From 2a010f827b9fec5d94870d4b297ba99b784d1a8b Mon Sep 17 00:00:00 2001 From: Tom Eastep Date: Thu, 19 Jan 2017 15:58:18 -0800 Subject: [PATCH] Add 'show action' command. Signed-off-by: Tom Eastep --- Shorewall-core/lib.cli | 20 ++++++++++++++ Shorewall-core/manpages/shorewall.xml | 40 +++++++++++++++++++++++++-- 2 files changed, 58 insertions(+), 2 deletions(-) diff --git a/Shorewall-core/lib.cli b/Shorewall-core/lib.cli index 3896358f2..9a6437717 100644 --- a/Shorewall-core/lib.cli +++ b/Shorewall-core/lib.cli @@ -1150,6 +1150,11 @@ show_macros() { done } +show_an_action() { + echo "Shorewall $SHOREWALL_VERSION Action $1 at $g_hostname - $(date)" + cat ${directory}/action.$1 +} + show_a_macro() { echo "Shorewall $SHOREWALL_VERSION Macro $1 at $g_hostname - $(date)" cat ${directory}/macro.$1 @@ -1458,12 +1463,26 @@ show_command() { ;; *) case $1 in + action) + [ $# -lt 2 ] && fatal_error 'Missing ' + [ $# -gt 2 ] && too_many_arguments $2 + + for directory in $(split $CONFIG_PATH); do + if [ -f ${directory}/action.$2 ]; then + eval show_an_action $2 $g_pager + return + fi + done + echo " WARNING: Action $2 not found" >&2 + return + ;; actions) [ $# -gt 1 ] && too_many_arguments $2 eval show_actions_sorted $g_pager return ;; macro) + [ $# -lt 2 ] && fatal_error 'Missing ' [ $# -ne 2 ] && too_many_arguments $2 for directory in $(split $CONFIG_PATH); do if [ -f ${directory}/macro.$2 ]; then @@ -4291,6 +4310,7 @@ usage() # $1 = exit status echo " savesets" echo " [ show | list | ls ] [ -b ] [ -x ] [ -t {filter|mangle|nat} ] [ {chain [ [ ... ]" ecko " [ show | list | ls ] actions" + ecko " [ show | list | ls ] action " echo " [ show | list | ls ] arptables" echo " [ show | list | ls ] [ -f ] capabilities" echo " [ show | list | ls ] [ -x ] {bl|blacklists}" diff --git a/Shorewall-core/manpages/shorewall.xml b/Shorewall-core/manpages/shorewall.xml index a2fda9ff8..4a1c37c5f 100644 --- a/Shorewall-core/manpages/shorewall.xml +++ b/Shorewall-core/manpages/shorewall.xml @@ -685,6 +685,31 @@ + + shorewall[6] + + options + + + + + + + + + + shorewall[6] + + | + + options + + + + action + + shorewall[6][-lite] @@ -695,7 +720,7 @@ + choice="req"> @@ -2415,12 +2440,23 @@ arguments: + + action + action + + + Lists the named action file. Available on Shorewall and + Shorewall6 only. + + + actions Produces a report about the available actions (built-in, - standard and user-defined). + standard and user-defined). Available on Shorewall and + Shorewall6 only.