From 660cc1d5cef14fb087940804b7f457502a0ab00c Mon Sep 17 00:00:00 2001 From: tschettervictor Date: Sat, 13 Dec 2025 17:24:19 -0700 Subject: [PATCH] networking: cosmetic fixes --- usr/local/share/bastille/clone.sh | 18 +++++++++--------- usr/local/share/bastille/create.sh | 28 ++++++++++++++-------------- usr/local/share/bastille/network.sh | 20 ++++++++++---------- 3 files changed, 33 insertions(+), 33 deletions(-) diff --git a/usr/local/share/bastille/clone.sh b/usr/local/share/bastille/clone.sh index c14a3ce6..b2e6c45a 100644 --- a/usr/local/share/bastille/clone.sh +++ b/usr/local/share/bastille/clone.sh @@ -131,22 +131,22 @@ validate_ip() { error_exit "[ERROR]: Invalid subnet: /${subnet}" fi fi - info "\nValid: (${ip6})." + info "\nValid IP: ${ip6}" IP6_ADDR="${ip6}" elif [ "${ip}" = "inherit" ] || [ "${ip}" = "ip_hostname" ]; then if [ "$(bastille config ${TARGET} get vnet)" = "enabled" ]; then - error_exit "[ERROR]: Unsupported IP option for VNET jail: (${ip})." + error_exit "[ERROR]: Unsupported IP option for VNET jail: ${ip}" else - info "\nValid: (${ip})." + info "\nValid IP: ${ip}" IP4_ADDR="${ip}" IP6_ADDR="${ip}" fi elif [ "${ip}" = "0.0.0.0" ] || [ "${ip}" = "DHCP" ] || [ "${ip}" = "SYNCDHCP" ]; then if [ "$(bastille config ${TARGET} get vnet)" = "enabled" ]; then - info "\nValid: (${ip})." + info "\nValid IP: ${ip}" IP4_ADDR="${ip}" else - error_exit "[ERROR]: Unsupported IP option for standard jail: (${ip})." + error_exit "[ERROR]: Unsupported IP option for standard jail: ${ip}" fi else if [ "${VNET_JAIL}" -eq 1 ]; then @@ -166,20 +166,20 @@ validate_ip() { set ${TEST_IP} for quad in 1 2 3 4; do if eval [ \$$quad -gt 255 ]; then - error_exit "Invalid: (${TEST_IP})" + error_exit "[ERROR]: Invalid IP: ${TEST_IP}" fi done if ifconfig | grep -qwF "${TEST_IP}"; then - warn "\nWarning: IP address already in use (${TEST_IP})." + warn "\n[WARNING]: IP address already in use: ${TEST_IP}" IP4_ADDR="${ip4}" else - info "\nValid: (${ip4})." + info "\nValid IP: ${ip4}" IP4_ADDR="${ip4}" fi else - error_exit "Invalid: (${ip4})." + error_exit "[ERROR]: Invalid IP: ${ip4}" fi fi } diff --git a/usr/local/share/bastille/create.sh b/usr/local/share/bastille/create.sh index a786d9f4..fb6dca49 100644 --- a/usr/local/share/bastille/create.sh +++ b/usr/local/share/bastille/create.sh @@ -129,20 +129,20 @@ validate_ip() { error_exit "[ERROR]: Invalid subnet: /${subnet}" fi fi - info "\nValid: (${ip6})." + info "\nValid IP: ${ip6}" local ipx_addr="ip6.addr" else if [ "${ip4}" = "inherit" ] || [ "${ip4}" = "ip_hostname" ]; then if [ "${VNET_JAIL}" -eq 1 ]; then - error_exit "[ERROR]: Unsupported IP option for VNET jail: (${ip4})." + error_exit "[ERROR]: Unsupported IP option for VNET jail: ${ip4}" else - info "\nValid: (${ip4})." + info "\nValid IP: ${ip4}" fi elif [ "${ip4}" = "DHCP" ] || [ "${ip4}" = "SYNCDHCP" ] || [ "${ip4}" = "0.0.0.0" ]; then if [ "${VNET_JAIL}" -eq 0 ]; then - error_exit "[ERROR]: Unsupported IP option for non-VNET jail: (${ip4})." + error_exit "[ERROR]: Unsupported IP option for non-VNET jail: ${ip4}" else - info "\nValid: (${ip4})." + info "\nValid IP: ${ip4}" fi else if [ "${VNET_JAIL}" -eq 1 ]; then @@ -162,20 +162,20 @@ validate_ip() { set ${TEST_IP} for quad in 1 2 3 4; do if eval [ \$$quad -gt 255 ]; then - error_exit "Invalid: (${TEST_IP})" + error_exit "Invalid IP: ${TEST_IP}" fi done ipx_addr="ip4.addr" - info "\nValid: (${ip4})." + info "\nValid IP: ${ip4}" else - error_exit "Invalid: (${ip4})." + error_exit "Invalid IP: ${ip4}" fi fi fi # Warn if IP is in use if ifconfig | grep -qwF "${TEST_IP}"; then - warn "[WARNING]: IP address in use (${TEST_IP})." + warn "[WARNING]: IP address in use: ${TEST_IP}" fi # Set interface value @@ -222,7 +222,7 @@ validate_ip() { IP6_ADDR="${ip}" fi else - error_exit "[ERROR]: Unsupported IP option for standard jail: (${ip})." + error_exit "[ERROR]: Unsupported IP option for standard jail: ${ip}" fi else if [ "${VNET_JAIL}" -eq 1 ]; then @@ -261,21 +261,21 @@ validate_netif() { local LIST_INTERFACES="$(ifconfig -l)" if ! echo "${LIST_INTERFACES} VNET" | grep -qwo "${INTERFACE}"; then - error_exit "[ERROR]: Invalid: (${INTERFACE})." + error_exit "[ERROR]: Invalid interface: ${INTERFACE}" elif [ "${VNET_JAIL_STANDARD}" -eq 1 ]; 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}" + error_exit "[ERROR]: Interface '${INTERFACE}' is already a member of bridge: ${_bridge}" fi done else - info "\nValid: (${INTERFACE})." + info "\nValid interface: ${INTERFACE}" fi # Don't allow dots in INTERFACE for -V|--vnet jails if [ "${VNET_JAIL_STANDARD}" -eq 1 ]; then if echo "${INTERFACE}" | grep -q "\."; then - error_exit "[ERROR]: [-V|--vnet] does not support dots (.) in interface names." + error_exit "[ERROR]: [-V|--vnet] does not support dots (.) in interface names." fi fi } diff --git a/usr/local/share/bastille/network.sh b/usr/local/share/bastille/network.sh index 7949d33e..ba4c7e35 100644 --- a/usr/local/share/bastille/network.sh +++ b/usr/local/share/bastille/network.sh @@ -179,7 +179,7 @@ validate_ip() { local ip="${1}" local ip4="$(echo ${ip} | awk -F"/" '{print $1}')" - local ip6="$( echo "${ip}" 2>/dev/null | grep -E '^(([a-fA-F0-9:]+$)|([a-fA-F0-9:]+\/[0-9]{1,3}$)|SLAAC)' )" + local ip6="$( echo "${ip}" | grep -E '^(([a-fA-F0-9:]+$)|([a-fA-F0-9:]+\/[0-9]{1,3}$)|SLAAC)' )" local subnet="$(echo ${ip} | awk -F"/" '{print $2}')" if [ -n "${ip6}" ]; then @@ -193,10 +193,10 @@ validate_ip() { error_exit "[ERROR]: Invalid subnet: /${subnet}" fi fi - info "\nValid: (${ip6})." + info "\nValid IP: ${ip6}" IP6_ADDR="${ip6}" elif [ "${ip}" = "0.0.0.0" ] || [ "${ip}" = "DHCP" ] || [ "${ip}" = "SYNCDHCP" ]; then - info "\nValid: (${ip})." + info "\nValid IP: ${ip}" IP4_ADDR="${ip}" else if [ "${STANDARD}" -eq 0 ]; then @@ -210,19 +210,19 @@ validate_ip() { fi fi local IFS - if echo "${ip}" 2>/dev/null | grep -Eq '^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/([0-9]|[1-2][0-9]|3[0-2]))?$'; then - TEST_IP=$(echo "${ip}" | cut -d / -f1) + if echo "${ip4}" | grep -Eq '^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/([0-9]|[1-2][0-9]|3[0-2]))?$'; then + TEST_IP=$(echo "${ip4}" | cut -d / -f1) IFS=. set ${TEST_IP} for quad in 1 2 3 4; do if eval [ \$$quad -gt 255 ]; then - error_exit "Invalid: (${TEST_IP})" + error_exit "[ERROR]: Invalid IP: ${TEST_IP}" fi done - info "\nValid: (${ip})." - IP4_ADDR="${ip}" + info "\nValid IP: ${ip4}" + IP4_ADDR="${ip4}" else - error_exit "Invalid: (${ip})." + error_exit "[ERROR]: Invalid IP: ${ip4}" fi fi } @@ -234,7 +234,7 @@ validate_netif() { if ifconfig -l | grep -qwo ${interface}; then info "\nValid: (${interface})." else - error_exit "Invalid: (${interface})." + error_exit "[ERROR]: Invalid interface: ${interface}" fi # Don't allow dots in INTERFACE if -V