Fix for issue #403
This commit is contained in:
@@ -47,8 +47,12 @@ if [ $# -lt 2 ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
TARGET="${1}"
|
TARGET="${1}"
|
||||||
|
JAIL_NAME=""
|
||||||
|
JAIL_IP=""
|
||||||
|
EXT_IF=""
|
||||||
shift
|
shift
|
||||||
|
|
||||||
|
check_jail_validity() {
|
||||||
# Can only redirect to single jail
|
# Can only redirect to single jail
|
||||||
if [ "${TARGET}" = 'ALL' ]; then
|
if [ "${TARGET}" = 'ALL' ]; then
|
||||||
error_exit "Can only redirect to a single jail."
|
error_exit "Can only redirect to a single jail."
|
||||||
@@ -78,6 +82,7 @@ EXT_IF=$(grep '^[[:space:]]*ext_if[[:space:]]*=' /etc/pf.conf)
|
|||||||
if [ -z "${EXT_IF}" ]; then
|
if [ -z "${EXT_IF}" ]; then
|
||||||
error_exit "ext_if not defined in pf.conf"
|
error_exit "ext_if not defined in pf.conf"
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# function: write rule to rdr.conf
|
# function: write rule to rdr.conf
|
||||||
persist_rdr_rule() {
|
persist_rdr_rule() {
|
||||||
@@ -96,17 +101,34 @@ load_rdr_rule() {
|
|||||||
while [ $# -gt 0 ]; do
|
while [ $# -gt 0 ]; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
list)
|
list)
|
||||||
|
if [ "${TARGET}" = 'ALL' ]; then
|
||||||
|
for JAIL_NAME in $(ls "${bastille_jailsdir}" | sed "s/\n//g"); do
|
||||||
|
echo "${JAIL_NAME} redirects:"
|
||||||
pfctl -a "rdr/${JAIL_NAME}" -Psn 2>/dev/null
|
pfctl -a "rdr/${JAIL_NAME}" -Psn 2>/dev/null
|
||||||
|
done
|
||||||
|
else
|
||||||
|
check_jail_validity
|
||||||
|
pfctl -a "rdr/${JAIL_NAME}" -Psn 2>/dev/null
|
||||||
|
fi
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
clear)
|
clear)
|
||||||
|
if [ "${TARGET}" = 'ALL' ]; then
|
||||||
|
for JAIL_NAME in $(ls "${bastille_jailsdir}" | sed "s/\n//g"); do
|
||||||
|
echo "${JAIL_NAME} redirects:"
|
||||||
pfctl -a "rdr/${JAIL_NAME}" -Fn
|
pfctl -a "rdr/${JAIL_NAME}" -Fn
|
||||||
|
done
|
||||||
|
else
|
||||||
|
check_jail_validity
|
||||||
|
pfctl -a "rdr/${JAIL_NAME}" -Fn
|
||||||
|
fi
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
tcp|udp)
|
tcp|udp)
|
||||||
if [ $# -lt 3 ]; then
|
if [ $# -lt 3 ]; then
|
||||||
usage
|
usage
|
||||||
fi
|
fi
|
||||||
|
check_jail_validity
|
||||||
persist_rdr_rule $1 $2 $3
|
persist_rdr_rule $1 $2 $3
|
||||||
load_rdr_rule $1 $2 $3
|
load_rdr_rule $1 $2 $3
|
||||||
shift 3
|
shift 3
|
||||||
|
|||||||
Reference in New Issue
Block a user