@@ -35,6 +35,21 @@ usage() {
35
35
error_exit " Usage: bastille start TARGET"
36
36
}
37
37
38
+ # indicate if an IP configurtaion value (e.g. a value given for ip4 or ip6)
39
+ # requires extra configuration external to the jail
40
+ #
41
+ # success if it does, failure if it does not
42
+ ip_require_config () {
43
+
44
+ case " ${1} " in
45
+ disable|inherit|" not set" )
46
+ return 1
47
+ ;;
48
+ esac
49
+
50
+ return 0
51
+ }
52
+
38
53
# Handle special-case commands first.
39
54
case " $1 " in
40
55
help|-h|--help)
@@ -67,24 +82,29 @@ for _jail in ${JAILS}; do
67
82
68
83
# # test if not running
69
84
elif [ ! " $( /usr/sbin/jls name | awk " /^${_jail} $/" ) " ]; then
70
- # Verify that the configured interface exists. -- cwells
71
- if [ " $( bastille config $_jail get vnet) " != ' enabled' ]; then
72
- _interface=$( bastille config $_jail get interface)
73
- if ! ifconfig | grep " ^${_interface} :" > /dev/null; then
74
- error_notify " Error: ${_interface} interface does not exist."
75
- continue
85
+ # # if networking is entirely inherited we can skip any setup
86
+ _ip4=$( bastille config $_jail get ip4)
87
+ _ip6=$( bastille config $_jail get ip6)
88
+ if ip_require_config " ${_ip4} " || ip_require_config " ${_ip6} " ; then
89
+ # Verify that the configured interface exists. -- cwells
90
+ if [ " $( bastille config $_jail get vnet) " != ' enabled' ]; then
91
+ _interface=$( bastille config $_jail get interface)
92
+ if ! ifconfig | grep " ^${_interface} :" > /dev/null; then
93
+ error_notify " Error: ${_interface} interface does not exist."
94
+ continue
95
+ fi
76
96
fi
77
- fi
78
97
79
- # # warn if matching configured (but not online) ip4.addr, ignore if there's no ip4.addr entry
80
- ip=$( grep ' ip4.addr' " ${bastille_jailsdir} /${_jail} /jail.conf" | awk ' {print $3}' | sed ' s/\;//g' )
81
- if [ -n " ${ip} " ]; then
82
- if ifconfig | grep -w " ${ip} " > /dev/null; then
83
- error_notify " Error: IP address (${ip} ) already in use."
84
- continue
98
+ # # warn if matching configured (but not online) ip4.addr, ignore if there's no ip4.addr entry
99
+ ip=$( grep ' ip4.addr' " ${bastille_jailsdir} /${_jail} /jail.conf" | awk ' {print $3}' | sed ' s/\;//g' )
100
+ if [ -n " ${ip} " ]; then
101
+ if ifconfig | grep -w " ${ip} " > /dev/null; then
102
+ error_notify " Error: IP address (${ip} ) already in use."
103
+ continue
104
+ fi
105
+ # # add ip4.addr to firewall table:jails
106
+ pfctl -q -t jails -T add " ${ip} "
85
107
fi
86
- # # add ip4.addr to firewall table:jails
87
- pfctl -q -t jails -T add " ${ip} "
88
108
fi
89
109
90
110
# # start the container
0 commit comments