mirror of
https://github.com/hackacad/bastille.git
synced 2025-12-21 01:30:52 +01:00
Merge pull request #1096 from BastilleBSD/tschettervictor-patch-2
create: Exit if -V and interface already used as member
This commit is contained in:
@@ -38,6 +38,10 @@ different types of jail network configurations.
|
|||||||
bastille will simply set ``ip4`` to ``ip_hostname`` inside the jail config.
|
bastille will simply set ``ip4`` to ``ip_hostname`` inside the jail config.
|
||||||
The jail will then function according the jail(8) documentation.
|
The jail will then function according the jail(8) documentation.
|
||||||
|
|
||||||
|
You cannot use ``-V|--vnet`` with any interface that is already a member of another
|
||||||
|
bridge. For example, if you create a bridge, and assign ``vtnet0`` as a member, you
|
||||||
|
will not be able to use ``vtnet0`` with ``-V|--vnet``.
|
||||||
|
|
||||||
IP Address Options
|
IP Address Options
|
||||||
------------------
|
------------------
|
||||||
|
|
||||||
|
|||||||
@@ -179,10 +179,16 @@ validate_netif() {
|
|||||||
|
|
||||||
local LIST_INTERFACES="$(ifconfig -l)"
|
local LIST_INTERFACES="$(ifconfig -l)"
|
||||||
|
|
||||||
if echo "${LIST_INTERFACES} VNET" | grep -qwo "${INTERFACE}"; then
|
if ! echo "${LIST_INTERFACES} VNET" | grep -qwo "${INTERFACE}"; then
|
||||||
info "\nValid: (${INTERFACE})."
|
|
||||||
else
|
|
||||||
error_exit "[ERROR]: Invalid: (${INTERFACE})."
|
error_exit "[ERROR]: Invalid: (${INTERFACE})."
|
||||||
|
elif [ -n "${VNET_JAIL}" ] && [ -z "${VNET_JAIL_BRIDGE}" ]; then
|
||||||
|
for _bridge in $(ifconfig -g bridge | grep -vw "${INTERFACE}bridge"); do
|
||||||
|
if ifconfig ${_bridge} | grep "member" | grep -owq "${INTERFACE}"; then
|
||||||
|
error_exit "[ERROR]: Interface (${INTERFACE}) is already a member of bridge: ${_bridge}"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
else
|
||||||
|
info "\nValid: (${INTERFACE})."
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -182,7 +182,6 @@ configure_shared_interface() {
|
|||||||
configure_bridge() {
|
configure_bridge() {
|
||||||
|
|
||||||
_auto_if="${1}"
|
_auto_if="${1}"
|
||||||
_bridge_name="bastillebridge"
|
|
||||||
_interface_list="$(ifconfig -l)"
|
_interface_list="$(ifconfig -l)"
|
||||||
_interface_count=0
|
_interface_count=0
|
||||||
|
|
||||||
@@ -214,12 +213,13 @@ configure_bridge() {
|
|||||||
_interface_select="${_auto_if}"
|
_interface_select="${_auto_if}"
|
||||||
fi
|
fi
|
||||||
# Create bridge and persist on reboot
|
# Create bridge and persist on reboot
|
||||||
|
_bridge_name="${_interface_select}bridge"
|
||||||
ifconfig bridge0 create
|
ifconfig bridge0 create
|
||||||
ifconfig bridge0 name bastillebridge
|
ifconfig bridge0 name ${_bridge_name}
|
||||||
ifconfig bastillebridge addm ${_interface_select} up
|
ifconfig ${_bridge_name} addm ${_interface_select} up
|
||||||
sysrc cloned_interfaces+="bridge0"
|
sysrc cloned_interfaces+="bridge0"
|
||||||
sysrc ifconfig_bridge0_name="bastillebridge"
|
sysrc ifconfig_bridge0_name="${_bridge_name}"
|
||||||
sysrc ifconfig_bastillebridge="addm ${_interface_select} up"
|
sysrc ifconfig_${_bridge_name}="addm ${_interface_select} up"
|
||||||
|
|
||||||
info "\nBridge interface successfully configured: [${_bridge_name}]"
|
info "\nBridge interface successfully configured: [${_bridge_name}]"
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user