From f54151cf94602620247e1a751e13822974d59c47 Mon Sep 17 00:00:00 2001 From: Jose Date: Thu, 16 Apr 2020 07:53:53 -0400 Subject: [PATCH] Fix for pfctl on start/stop commands, clean up excess double quotes --- usr/local/share/bastille/start.sh | 6 ++++-- usr/local/share/bastille/stop.sh | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) 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