@@ -142,7 +142,7 @@ get_bastille_if_count() {
142
142
if [ " ${bastille_network_vnet_type} " = " if_bridge" ]; then
143
143
for _config in /usr/local/etc/bastille/* .conf; do
144
144
local bastille_jailsdir=" $( sysrc -f " ${_config} " -n bastille_jailsdir) "
145
- _bastille_if_list=" $( printf ' %s\n%s' " $( (grep -Ehos ' (epair[0-9]+|bastille[0-9]+)' ${bastille_jailsdir} /* /jail.conf; ifconfig -g epair | grep -Eos " _bastille[0-9]+$" ; ifconfig -g epair | grep -vs ' bastille ' | grep -Eos ' e[0-9]+a_ ' ) | grep -Eos ' [0-9]+' ) " " ${_bastille_if_list} " ) "
145
+ _bastille_if_list=" $( printf ' %s\n%s' " $( (grep -Ehos ' (epair[0-9]+|bastille[0-9]+|e[0-9]+a_ )' ${bastille_jailsdir} /* /jail.conf; ifconfig -g epair | grep -Eos " _bastille[0-9]+$" ) | grep -Eos ' [0-9]+' ) " " ${_bastille_if_list} " ) "
146
146
done
147
147
_bastille_if_count=$( printf ' %s' " ${_bastille_if_list} " | sort -u | wc -l | awk ' {print $1}' )
148
148
export _bastille_if_list
@@ -388,30 +388,18 @@ generate_vnet_jail_netblock() {
388
388
get_bastille_if_count
389
389
local _bastille_if_num_range=$(( _bastille_if_count + 1 ))
390
390
if [ -n " ${use_unique_bridge} " ]; then
391
- if [ " ${_bastille_if_count} " -gt 0 ]; then
392
- for _num in $( seq 0 " ${_bastille_if_num_range} " ) ; do
393
- if ! echo " ${_bastille_if_list} " | grep -oqswx " ${_num} " ; then
394
- if [ " $( echo -n " e${_num} a_${jail_name} " | awk ' {print length}' ) " -lt 16 ]; then
395
- local host_epair=e${_num} a_${jail_name}
396
- local jail_epair=e${_num} b_${jail_name}
397
- else
398
- local host_epair=epair${_num} a
399
- local jail_epair=epair${_num} b
400
- fi
401
- break
391
+ for _num in $( seq 0 " ${_bastille_if_num_range} " ) ; do
392
+ if ! echo " ${_bastille_if_list} " | grep -oqswx " ${_num} " ; then
393
+ if [ " $( echo -n " e${_num} a_${jail_name} " | awk ' {print length}' ) " -lt 16 ]; then
394
+ local host_epair=e${_num} a_${jail_name}
395
+ local jail_epair=e${_num} b_${jail_name}
396
+ else
397
+ local host_epair=e${_num} a__bastille
398
+ local jail_epair=e${_num} b__bastille
402
399
fi
403
- done
404
- else
405
- if [ " $( echo -n " e0a_${jail_name} " | awk ' {print length}' ) " -lt 16 ]; then
406
- local _num=0
407
- local host_epair=e${_num} a_${jail_name}
408
- local jail_epair=e${_num} b_${jail_name}
409
- else
410
- local _num=0
411
- local host_epair=epair${_num} a
412
- local jail_epair=epair${_num} b
400
+ break
413
401
fi
414
- fi
402
+ done
415
403
else
416
404
if [ " ${_bastille_if_count} " -gt 0 ]; then
417
405
for _num in $( seq 0 " ${_bastille_if_num_range} " ) ; do
@@ -426,36 +414,28 @@ generate_vnet_jail_netblock() {
426
414
fi
427
415
# # If BRIDGE is enabled, generate bridge config, else generate VNET config
428
416
if [ -n " ${use_unique_bridge} " ]; then
417
+ cat << -EOF
418
+ vnet;
419
+ vnet.interface = ${jail_epair} ;
420
+ exec.prestart += "epname=\\\$ (ifconfig epair create) && ifconfig \\\$ {epname} name ${host_epair} && ifconfig \\\$ {epname%a}b name ${jail_epair} ";
421
+ exec.prestart += "ifconfig ${external_interface} addm ${host_epair} ";
422
+ exec.prestart += "ifconfig ${host_epair} description \"vnet host interface for Bastille jail ${jail_name} \"";
423
+ exec.poststop += "ifconfig ${external_interface} deletem ${host_epair} ";
424
+ exec.poststop += "ifconfig ${host_epair} destroy";
425
+ EOF
429
426
if [ -n " ${static_mac} " ]; then
430
427
# # Generate bridged VNET config with static MAC address
431
428
generate_static_mac " ${jail_name} " " ${external_interface} "
432
429
cat << -EOF
433
- vnet;
434
- vnet.interface = ${jail_epair} ;
435
- exec.prestart += "ifconfig epair${_num} create";
436
- exec.prestart += "ifconfig ${external_interface} addm epair${_num} a";
437
- exec.prestart += "ifconfig epair${_num} a up name ${host_epair} ";
438
- exec.prestart += "ifconfig epair${_num} b up name ${jail_epair} ";
439
430
exec.prestart += "ifconfig ${host_epair} ether ${macaddr} a";
440
431
exec.prestart += "ifconfig ${jail_epair} ether ${macaddr} b";
441
- exec.prestart += "ifconfig ${host_epair} description \"vnet0 host interface for Bastille jail ${jail_name} \"";
442
- exec.poststop += "ifconfig ${external_interface} deletem ${host_epair} ";
443
- exec.poststop += "ifconfig ${host_epair} destroy";
444
432
EOF
445
- else
446
- # # Generate bridged VNET config without static MAC address
447
- cat << -EOF
448
- vnet;
449
- vnet.interface = ${jail_epair} ;
450
- exec.prestart += "ifconfig epair${_num} create";
451
- exec.prestart += "ifconfig ${external_interface} addm epair${_num} a";
452
- exec.prestart += "ifconfig epair${_num} a up name ${host_epair} ";
453
- exec.prestart += "ifconfig epair${_num} b up name ${jail_epair} ";
454
- exec.prestart += "ifconfig ${host_epair} description \"vnet0 host interface for Bastille jail ${jail_name} \"";
455
- exec.poststop += "ifconfig ${external_interface} deletem ${host_epair} ";
456
- exec.poststop += "ifconfig ${host_epair} destroy";
433
+ fi
434
+
435
+ cat << -EOF
436
+ exec.prestart += "ifconfig ${host_epair} up";
437
+ exec.prestart += "ifconfig ${jail_epair} up";
457
438
EOF
458
- fi
459
439
else
460
440
if [ " ${bastille_network_vnet_type} " = " if_bridge" ]; then
461
441
if [ -n " ${static_mac} " ]; then
0 commit comments