[OpenWrt-Devel] [PATCH] mtd_get_mac_ascii Return first occurence of $key.

vargagab at gmail.com vargagab at gmail.com
Tue Nov 26 08:10:03 EST 2019


From: Gabor Varga <vargagab at 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 at gmail.com>
---
 package/base-files/files/lib/functions/system.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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"
-- 
2.24.0


_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list