[openwrt/openwrt] base-files: enable get_mac_ascii() to handle redundant strings

LEDE Commits lede-commits at lists.infradead.org
Sat Jan 4 10:45:01 PST 2025


hauke pushed a commit to openwrt/openwrt.git, branch openwrt-24.10:
https://git.openwrt.org/676dfd1363fbfc1b92331aa293672f8af9770a02

commit 676dfd1363fbfc1b92331aa293672f8af9770a02
Author: Shiji Yang <yangshiji66 at qq.com>
AuthorDate: Fri Dec 13 13:30:38 2024 +0800

    base-files: enable get_mac_ascii() to handle redundant strings
    
    The function get_mac_ascii() will fail when there are two or more
    same MAC address variable names in the mtd partition. Only retain
    the first variable to workaround this rare situation.
    
    Fixes: https://github.com/openwrt/openwrt/issues/17236
    Signed-off-by: Shiji Yang <yangshiji66 at qq.com>
    Link: https://github.com/openwrt/openwrt/pull/17262
    Signed-off-by: Hauke Mehrtens <hauke at hauke-m.de>
    (cherry picked from commit 3410ad2f40c085e5db7a71f6ae4b80734826a1e3)
---
 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 048e32f0e1..aaeb75f261 100644
--- a/package/base-files/files/lib/functions/system.sh
+++ b/package/base-files/files/lib/functions/system.sh
@@ -66,7 +66,7 @@ get_mac_ascii() {
 	local key="$2"
 	local mac_dirty
 
-	mac_dirty=$(strings "$part" | sed -n 's/^'"$key"'=//p')
+	mac_dirty=$(strings "$part" | sed -n 's/^'"$key"'=//p' | head -n 1)
 
 	# "canonicalize" mac
 	[ -n "$mac_dirty" ] && macaddr_canonicalize "$mac_dirty"




More information about the lede-commits mailing list