From eee99a3b799a9abcce50091eb43baa86efb6969f Mon Sep 17 00:00:00 2001 From: tschettervictor <85497460+tschettervictor@users.noreply.github.com> Date: Wed, 8 Jan 2025 10:25:15 -0700 Subject: [PATCH] rdr: fix _jail > TARGET + alphabetical option order --- usr/local/share/bastille/rdr.sh | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/usr/local/share/bastille/rdr.sh b/usr/local/share/bastille/rdr.sh index 0361a2fc..2af4bf54 100644 --- a/usr/local/share/bastille/rdr.sh +++ b/usr/local/share/bastille/rdr.sh @@ -47,6 +47,8 @@ EOF } check_jail_validity() { + + # Validate jail network type and set IP4/6 if [ "$( bastille config ${TARGET} get vnet )" != 'enabled' ]; then _ip4_interfaces="$(bastille config ${TARGET} get ip4.addr | sed 's/,/ /g')" _ip6_interfaces="$(bastille config ${TARGET} get ip6.addr | sed 's/,/ /g')" @@ -218,6 +220,15 @@ while [ "$#" -gt 0 ]; do -h|--help|help) usage ;; + -d|--destination) + if ifconfig | grep -owq "inet ${2}"; then + OPTION_DST=1 + RDR_DST="${2}" + shift 2 + else + error_exit "${2} is not an IP on this system." + fi + ;; -i|--interface) if ifconfig | grep -owq "${2}:"; then OPTION_IF=1 @@ -233,15 +244,6 @@ while [ "$#" -gt 0 ]; do RDR_SRC="${2}" shift 2 ;; - -d|--destination) - if ifconfig | grep -owq "inet ${2}"; then - OPTION_DST=1 - RDR_DST="${2}" - shift 2 - else - error_exit "${2} is not an IP on this system." - fi - ;; -t|--type) if [ "${2}" != "ipv4" ] && [ "${2}" != "ipv6" ]; then error_exit "[-t|--type] must be [ipv4|ipv6]" @@ -296,8 +298,8 @@ while [ "$#" -gt 0 ]; do usage else check_jail_validity - echo "${_jail} redirects:" - pfctl -a "rdr/${_jail}" -Fn + echo "${TARGET} redirects:" + pfctl -a "rdr/${TARGET}" -Fn fi shift ;; @@ -308,10 +310,10 @@ while [ "$#" -gt 0 ]; do usage else check_jail_validity - echo "${_jail} redirects:" - pfctl -a "rdr/${_jail}" -Fn + echo "${TARGET} redirects:" + pfctl -a "rdr/${TARGET}" -Fn if rm -f "${bastille_jailsdir}/${_jail}/rdr.conf"; then - info "[${_jail}]: rdr.conf removed" + info "[${TARGET}]: rdr.conf removed" fi fi shift