Thomas Bohl <openbsd-misc-518...@aloof.de> wrote:

> Hello,
> 
> > I suppose there is some argument that we should support hostname.MAC
> > files
> 
> Maybe a function in netstart right before vifscreate could be enough
> to achieve this? I creates this diff, against stable for now though,
> as a test.
> 
> Create a /etc/hostname.MAC file like you would create a
> /etc/hostname.if file. (MAC = lladdr as shown with ifconfig. Like
> /etc/hostname.08:00:27:14:26:0d)
> /etc/netstart than creates a symbolic link to the corresponding
> hostname.if. If there is a hostname.if file it is not overwritten. The
> rest works the same.
> 
> 
> --- netstart  Tue Sep 27 19:39:43 2022
> +++ netstart  Tue Nov 22 03:39:49 2022
> @@ -104,6 +104,21 @@ ifcreate() {
>       fi
>  }
> 
> +# Symlink hostname.MAC to hostname.if.
> +# Existing hostname.if-file (no symlink) wins.
> +link_MAC_to_if() {
> +     local _hn _mac _if
> +
> +     for _hn in /etc/hostname.??:??:??:??:??:??; do
> +             _mac=`echo $_hn | cut -c 15-31`
> +             _if=`ifconfig | grep -B 1 $_mac | head -n 1 | awk -F ": " 
> '{print $1}'`
> +             # Only create a symlink if /etc/hostname.$_if is not a normal 
> file.
> +             if [[ -h /etc/hostname.$_if ]] || [[ ! -e /etc/hostname.$_if 
> ]]; then
> +                     ln -fs /etc/hostname.$_mac /etc/hostname.$_if
> +             fi
> +     done
> +}
> +

This part of your diff to discover the hostname.##:##:##:##:##:##
files is quite nice, but symbolic linking them is pretty nasty.  I think
they will get left behind and create confusion, and someone will try to
delete them, and accidentally delete others.

I think the ifstart() function which parses a 'xx0' file, should be split up,
so that the 2nd half of the function can be used to process either type of
file.


Reply via email to