hostapd: improve error handling when adding supplicant config
authorDaniel Golle <daniel@makrotopia.org>
Tue, 12 Jan 2021 00:28:17 +0000 (00:28 +0000)
committerDaniel Golle <daniel@makrotopia.org>
Thu, 14 Jan 2021 00:52:49 +0000 (00:52 +0000)
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
package/network/services/hostapd/Makefile
package/network/services/hostapd/files/hostapd.sh

index a6d56d1433813b7496145f8dfca49f1f87bda23d..a64065db1076a09bd1ab03c68b2d6b23f57a4571 100644 (file)
@@ -7,7 +7,7 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=hostapd
-PKG_RELEASE:=24
+PKG_RELEASE:=25
 
 PKG_SOURCE_URL:=http://w1.fi/hostap.git
 PKG_SOURCE_PROTO:=git
index cee9a8eaa2777bbee10ee4501d331259f16ed97c..a48e8d0766abd4fb30464c0ed82a428b38e009cd 100644 (file)
@@ -1392,18 +1392,18 @@ wpa_supplicant_run() {
        _wpa_supplicant_common "$ifname"
 
        ubus wait_for wpa_supplicant
-       local supplicant_pid=$(ubus call wpa_supplicant config_add "{ \
+       local supplicant_res="$(ubus call wpa_supplicant config_add "{ \
                \"driver\": \"${_w_driver:-wext}\", \"ctrl\": \"$_rpath\", \
                \"iface\": \"$ifname\", \"config\": \"$_config\" \
                ${network_bridge:+, \"bridge\": \"$network_bridge\"} \
                ${hostapd_ctrl:+, \"hostapd_ctrl\": \"$hostapd_ctrl\"} \
-               }" | jsonfilter -l 1 -e @.pid)
+               }")"
 
        ret="$?"
 
-       [ "$ret" != 0 ] && wireless_setup_vif_failed WPA_SUPPLICANT_FAILED
+       [ "$ret" != 0 -o -z "$supplicant_res" ] && wireless_setup_vif_failed WPA_SUPPLICANT_FAILED
 
-       wireless_add_process "$supplicant_pid" "/usr/sbin/wpa_supplicant" 1 1
+       wireless_add_process "$(jsonfilter -s "$supplicant_res" -l 1 -e @.pid)" "/usr/sbin/wpa_supplicant" 1 1
 
        return $ret
 }