[Bug 263358] hostapd rc script defines function hostapd_poststart() before $ifn

From: <bugzilla-noreply_at_freebsd.org>
Date: Sun, 17 Apr 2022 04:08:49 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=263358

            Bug ID: 263358
           Summary: hostapd rc script defines function hostapd_poststart()
                    before $ifn
           Product: Base System
           Version: 13.1-RELEASE
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: misc
          Assignee: bugs@FreeBSD.org
          Reporter: freebsd@kumba.dev

In commit 0da2c91e6452, the hostapd rc script was modified to down and then up
the wireless interface by way of a new hostapd_poststart function:

hostapd_poststart() {
        ifconfig ${ifn} down
        sleep 2
        ifconfig ${ifn} up
}

But this function, which references the variable $ifn, is defined before $ifn
is defined.  Thus, when hostapd is started or restarted, the poststart function
simply executes 'ifconfig down', sleeps, then 'ifconfig up'.  This results in
errors from the ifconfig calls that 'down' and 'up' are not valid interfaces,
and the wireless interface is not properly restarted.

I don't follow the logic because I don't know what is supposed to be passed in
$2 to $ifn.  Would it be better to define a new var for rc.conf called
something like $hostapd_iface that the user can use to identify which interface
is the wireless one that hostapd should control?

Note, this first appeared in 13.1-RC2, so a fix should probably be pushed out
so it makes it into the final RC before release.

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