Sanitize network interface names in jail_netgraph_bridge.bash script.

This commit is contained in:
Tom Alexander 2023-07-01 15:23:21 -04:00
parent db17b87cb8
commit b17a5f352d
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
3 changed files with 6 additions and 25 deletions

View File

@ -31,15 +31,6 @@ jail_list:
enabled: true enabled: true
conf: conf:
src: public_dns src: public_dns
- name: persistent_volume
enabled: true
conf:
src: persistent_volume
persist:
- name: volumes
mount: /volumes
# properties:
# recordsize: "8192"
bhyve_dataset: zdata/vm bhyve_dataset: zdata/vm
bhyve_canmount: "on" bhyve_canmount: "on"
# efi_dev: /dev/gpt/EFI # efi_dev: /dev/gpt/EFI

View File

@ -20,7 +20,7 @@ function main {
function start_jail { function start_jail {
host_interface_name="$1" host_interface_name="$1"
bridge_name="bridge_${host_interface_name}" bridge_name="bridge_${host_interface_name}"
jail_interface_name="$2" jail_interface_name=$(sanitize_interface_name "$2")
ip_range="$3" ip_range="$3"
assert_bridge "$host_interface_name" "$bridge_name" "$ip_range" assert_bridge "$host_interface_name" "$bridge_name" "$ip_range"
@ -36,7 +36,7 @@ EOF
function stop_jail { function stop_jail {
host_interface_name="$1" host_interface_name="$1"
bridge_name="bridge_${host_interface_name}" bridge_name="bridge_${host_interface_name}"
jail_interface_name="$2" jail_interface_name=$(sanitize_interface_name "$2")
if ng_exists "${jail_interface_name}:"; then if ng_exists "${jail_interface_name}:"; then
wait_for_interface_to_exist "${jail_interface_name}" 120 wait_for_interface_to_exist "${jail_interface_name}" 120
@ -117,4 +117,8 @@ function wait_for_interface_to_exist {
done done
} }
function sanitize_interface_name {
echo "${1:0:15}"
}
main "${@}" main "${@}"

View File

@ -1,14 +0,0 @@
persistent_volume {
path = "/jail/main/jails/${name}";
vnet;
exec.prestart += "/usr/local/bin/jail_netgraph_bridge start jail_nat jail${name} 10.215.1.1/24";
exec.poststop += "/usr/local/bin/jail_netgraph_bridge stop jail_nat jail${name}";
vnet.interface += "jail${name}";
devfs_ruleset = 14;
mount.devfs;
exec.start += "/bin/sh /etc/rc";
exec.stop = "/bin/sh /etc/rc.shutdown jail";
exec.consolelog = "/var/log/jail_${name}_console.log";
}