mirror of
https://github.com/hackacad/bastille.git
synced 2025-12-22 10:10:46 +01:00
rdr: fix _jail > TARGET + alphabetical option order
This commit is contained in:
@@ -47,6 +47,8 @@ EOF
|
|||||||
}
|
}
|
||||||
|
|
||||||
check_jail_validity() {
|
check_jail_validity() {
|
||||||
|
|
||||||
|
# Validate jail network type and set IP4/6
|
||||||
if [ "$( bastille config ${TARGET} get vnet )" != 'enabled' ]; then
|
if [ "$( bastille config ${TARGET} get vnet )" != 'enabled' ]; then
|
||||||
_ip4_interfaces="$(bastille config ${TARGET} get ip4.addr | sed 's/,/ /g')"
|
_ip4_interfaces="$(bastille config ${TARGET} get ip4.addr | sed 's/,/ /g')"
|
||||||
_ip6_interfaces="$(bastille config ${TARGET} get ip6.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)
|
-h|--help|help)
|
||||||
usage
|
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)
|
-i|--interface)
|
||||||
if ifconfig | grep -owq "${2}:"; then
|
if ifconfig | grep -owq "${2}:"; then
|
||||||
OPTION_IF=1
|
OPTION_IF=1
|
||||||
@@ -233,15 +244,6 @@ while [ "$#" -gt 0 ]; do
|
|||||||
RDR_SRC="${2}"
|
RDR_SRC="${2}"
|
||||||
shift 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)
|
-t|--type)
|
||||||
if [ "${2}" != "ipv4" ] && [ "${2}" != "ipv6" ]; then
|
if [ "${2}" != "ipv4" ] && [ "${2}" != "ipv6" ]; then
|
||||||
error_exit "[-t|--type] must be [ipv4|ipv6]"
|
error_exit "[-t|--type] must be [ipv4|ipv6]"
|
||||||
@@ -296,8 +298,8 @@ while [ "$#" -gt 0 ]; do
|
|||||||
usage
|
usage
|
||||||
else
|
else
|
||||||
check_jail_validity
|
check_jail_validity
|
||||||
echo "${_jail} redirects:"
|
echo "${TARGET} redirects:"
|
||||||
pfctl -a "rdr/${_jail}" -Fn
|
pfctl -a "rdr/${TARGET}" -Fn
|
||||||
fi
|
fi
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
@@ -308,10 +310,10 @@ while [ "$#" -gt 0 ]; do
|
|||||||
usage
|
usage
|
||||||
else
|
else
|
||||||
check_jail_validity
|
check_jail_validity
|
||||||
echo "${_jail} redirects:"
|
echo "${TARGET} redirects:"
|
||||||
pfctl -a "rdr/${_jail}" -Fn
|
pfctl -a "rdr/${TARGET}" -Fn
|
||||||
if rm -f "${bastille_jailsdir}/${_jail}/rdr.conf"; then
|
if rm -f "${bastille_jailsdir}/${_jail}/rdr.conf"; then
|
||||||
info "[${_jail}]: rdr.conf removed"
|
info "[${TARGET}]: rdr.conf removed"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
shift
|
shift
|
||||||
|
|||||||
Reference in New Issue
Block a user