diff mbox series

wireless: fix mode checking in for_each_interface

Message ID DB9PR01MB735470E8BBB42F6268A00D3FE48B9@DB9PR01MB7354.eurprd01.prod.exchangelabs.com
State New
Headers show
Series wireless: fix mode checking in for_each_interface | expand

Commit Message

Jean-Pierre TOSONI Nov. 2, 2021, 1:24 p.m. UTC
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@acksys.fr>
---
 scripts/netifd-wireless.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

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
 			}