Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow ip4/ip6 inherit #535

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 26 additions & 7 deletions usr/local/share/bastille/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,21 @@ usage() {
error_exit "Usage: bastille start TARGET"
}

# indicate if an IP configurtaion value (e.g. a value given for ip4 or ip6)
# requires extra configuration external to the jail
#
# success if it does, failure if it does not
ip_require_config() {

case "${1}" in
disable|inherit|"not set")
return 1
;;
esac

return 0
}

# Handle special-case commands first.
case "$1" in
help|-h|--help)
Expand Down Expand Up @@ -69,14 +84,18 @@ for _jail in ${JAILS}; do

## test if not running
elif [ ! "$(/usr/sbin/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
## if networking is entirely inherited we can skip any setup
_ip4=$(bastille config $_jail get ip4)
_ip6=$(bastille config $_jail get ip6)
if ip_require_config "${_ip4}" || ip_require_config "${_ip6}"; 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
fi

## warn if matching configured (but not online) ip4.addr, ignore if there's no ip4.addr entry
ip=$(bastille config "${_jail}" get ip4.addr)
Expand Down