[PATCH] wireless: fix mode checking in for_each_interface

Jean-Pierre TOSONI jp.tosoni at acksys.fr
Tue Nov 2 06:24:13 PDT 2021


When searching through wifi-ifaces for specific modes, the mode string
must be compared as a full word. So, add spaces around the searched name.

Else, adding a future new mode like "newap" or "apdetector" which embed
an existing "ap" mode string, will end in detecting the wrong interface.

This was found while trying to create a new detection service for WIDS.

Signed-off-by: Jean-Pierre Tosoni <jp.tosoni at acksys.fr>
---
 scripts/netifd-wireless.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/netifd-wireless.sh b/scripts/netifd-wireless.sh
index 80fbf75..9dd5431 100644
--- a/scripts/netifd-wireless.sh
+++ b/scripts/netifd-wireless.sh
@@ -321,7 +321,7 @@ for_each_interface() {
 			json_get_var _w_type mode
 			json_select ..
 			_w_types=" $_w_types "
-			[[ "${_w_types%$_w_type*}" = "$_w_types" ]] && {
+			[[ "${_w_types% $_w_type *}" = "$_w_types" ]] && {
 				json_select ..
 				continue
 			}
-- 
2.17.1




More information about the openwrt-devel mailing list