[OpenWrt-Devel] mtd_get_mac_ascii Return first occurence of $key.
diff mbox series

Message ID 20191126131003.324777-1-vargagab@gmail.com
State New
Headers show
Series
  • [OpenWrt-Devel] mtd_get_mac_ascii Return first occurence of $key.
Related show

Commit Message

Gábor Varga Nov. 26, 2019, 1:10 p.m. UTC
From: Gabor Varga <vargagab@gmail.com>

 For example on Asus RT-AC65P router (and the identical Asus RT-AC85P)
 the et1macaddr string has multiple occurences in u-boot-env partition.
 So, the mtd_get_mac_ascii cannot determine the WAN MAC address
 (called from /etc/board.d/02_network script), and with default 
 configuration the WAN and LAN MAC addresses are swapped.

Signed-off-by: Gabor Varga <vargagab@gmail.com>
---
 package/base-files/files/lib/functions/system.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch
diff mbox series

diff --git a/package/base-files/files/lib/functions/system.sh b/package/base-files/files/lib/functions/system.sh
index c4dc3cc3a9..067157f53f 100644
--- a/package/base-files/files/lib/functions/system.sh
+++ b/package/base-files/files/lib/functions/system.sh
@@ -72,7 +72,7 @@  mtd_get_mac_ascii() {
 		return
 	fi
 
-	mac_dirty=$(strings "$part" | sed -n 's/^'"$key"'=//p')
+	mac_dirty=$(strings "$part" | sed -n '1,/'"$key"'=/s/^'"$key"'=//p')
 
 	# "canonicalize" mac
 	[ -n "$mac_dirty" ] && macaddr_canonicalize "$mac_dirty"