[Bug 291143] jib script should allow adding with (.) in interface names

From: <bugzilla-noreply_at_freebsd.org>
Date: Sat, 22 Nov 2025 00:43:39 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=291143

            Bug ID: 291143
           Summary: jib script should allow adding with (.) in interface
                    names
           Product: Base System
           Version: Unspecified
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Many People
          Priority: ---
         Component: misc
          Assignee: bugs@FreeBSD.org
          Reporter: tschetter.victor@gmail.com

Jib is a script located at /usr/share/examples/jail/jib that aids in adding
epairs for use with jails.

It has the limitation of not allowing interfaces such as “em0.20” to be used.
Trying to run “jib addm test em0.20” will result in a failure due to the
following lines of code in the (derive_mac) function.

        if [ ! "$__mac_num" ]; then
                eval __mac_num=\${_${iface}_num:--1}
                __mac_num=$(( $__mac_num + 1 ))
                eval _${iface}_num=\$__mac_num
        fi

Obviously there may not be dots (.) in a variable, but in this case
iface=em0.20

A fix can be the following, where we sanitize the interface name by replacing
the (.) with a (_)

        if [ ! "$__mac_num" ]; then
                __iface_sani="$(echo ${iface} | sed 's/./_/g')"
                eval __mac_num=\${_${__iface_sani}_num:--1}
                __mac_num=$(( $__mac_num + 1 ))
                eval _${__iface_sani}_num=\$__mac_num
        fi

-- 
You are receiving this mail because:
You are the assignee for the bug.