From a56c37983cd698e0d22f909621006207d0738390 Mon Sep 17 00:00:00 2001 From: Chris Wells Date: Sun, 13 Dec 2020 20:22:59 -0500 Subject: [PATCH] Verify interface exists when starting non-vnet jail. Closes #128. --- usr/local/share/bastille/start.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/usr/local/share/bastille/start.sh b/usr/local/share/bastille/start.sh index 145c7be5..66c1fe83 100644 --- a/usr/local/share/bastille/start.sh +++ b/usr/local/share/bastille/start.sh @@ -67,11 +67,21 @@ for _jail in ${JAILS}; do ## test if not running elif [ ! "$(jls name | awk "/^${_jail}$/")" ]; then + # Verify that the configured interface exists. -- cwells + if [ "$(bastille config $_jail get vnet)" != 'enabled' ]; then + _interface=$(bastille config $_jail get interface) + if ! ifconfig | grep "^${_interface}:" >/dev/null; then + error_notify "Error: ${_interface} interface does not exist." + continue + fi + fi + ## warn if matching configured (but not online) ip4.addr, ignore if there's no ip4.addr entry ip=$(grep 'ip4.addr' "${bastille_jailsdir}/${_jail}/jail.conf" | awk '{print $3}' | sed 's/\;//g') if [ -n "${ip}" ]; then if ifconfig | grep -w "${ip}" >/dev/null; then - error_exit "Error: IP address (${ip}) already in use." + error_notify "Error: IP address (${ip}) already in use." + continue fi fi