diff --git a/usr/local/share/bastille/start.sh b/usr/local/share/bastille/start.sh index 8116b318..c3fead95 100644 --- a/usr/local/share/bastille/start.sh +++ b/usr/local/share/bastille/start.sh @@ -89,8 +89,10 @@ for _jail in ${JAILS}; do fi ## add ip4.addr to firewall table:jails - if grep "interface = ${bastille_network_loopback}" "${bastille_jailsdir}/${_jail}/jail.conf"; then - pfctl -q -t jails -T add "$(jls -j "${_jail}" ip4.addr)" + if [ -n "${bastille_network_loopback}" ]; then + if grep -qw "interface.*=.*${bastille_network_loopback}" "${bastille_jailsdir}/${_jail}/jail.conf"; then + pfctl -q -t jails -T add "$(jls -j ${_jail} ip4.addr)" + fi fi fi echo diff --git a/usr/local/share/bastille/stop.sh b/usr/local/share/bastille/stop.sh index 15d79a0b..2c42104f 100644 --- a/usr/local/share/bastille/stop.sh +++ b/usr/local/share/bastille/stop.sh @@ -67,8 +67,10 @@ for _jail in ${JAILS}; do ## test if running if [ "$(jls name | awk "/^${_jail}$/")" ]; then ## remove ip4.addr from firewall table:jails - if grep "interface = ${bastille_network_loopback}" "${bastille_jailsdir}/${_jail}/jail.conf"; then - pfctl -q -t jails -T delete "$(jls -j "${_jail}" ip4.addr)" + if [ -n "${bastille_network_loopback}" ]; then + if grep -qw "interface.*=.*${bastille_network_loopback}" "${bastille_jailsdir}/${_jail}/jail.conf"; then + pfctl -q -t jails -T delete "$(jls -j ${_jail} ip4.addr)" + fi fi ## remove rctl limits