git: c93cddd19baf - stable/13 - libexec/rc.d/hostapd: Down/up interface when interface is specified

From: Cy Schubert <cy_at_FreeBSD.org>
Date: Mon, 25 Apr 2022 13:49:20 UTC
The branch stable/13 has been updated by cy:

URL: https://cgit.FreeBSD.org/src/commit/?id=c93cddd19baf396806a982f7659dcc77cdd5867e

commit c93cddd19baf396806a982f7659dcc77cdd5867e
Author:     Cy Schubert <cy@FreeBSD.org>
AuthorDate: 2022-04-22 16:03:08 +0000
Commit:     Cy Schubert <cy@FreeBSD.org>
CommitDate: 2022-04-25 13:49:04 +0000

    libexec/rc.d/hostapd: Down/up interface when interface is specified
    
    When no interface is specified results in a syntax error in the rc
    script. Only execute poststart when an interface has been specified.
    
    PR:             263358
    Submitted by:   markj
    Reported by:    Joshua Kinard <freebsd@kumba.dev>
    Fixes:          0da2c91e64528d896f69d36670e25b4b4a140579
    
    (cherry picked from commit 1452bfcd9bbcb2f5bbb89fa38d01ce51dd9b6d44)
---
 libexec/rc/rc.d/hostapd | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/libexec/rc/rc.d/hostapd b/libexec/rc/rc.d/hostapd
index 7e1611350438..d2d8dd253efa 100755
--- a/libexec/rc/rc.d/hostapd
+++ b/libexec/rc/rc.d/hostapd
@@ -15,9 +15,11 @@ command=${hostapd_program}
 start_postcmd="hostapd_poststart"
 
 hostapd_poststart() {
-	ifconfig ${ifn} down
-	sleep 2
-	ifconfig ${ifn} up
+	if [ -n "$ifn" ]; then
+		ifconfig ${ifn} down
+		sleep 2
+		ifconfig ${ifn} up
+	fi
 }
 
 ifn="$2"