[OpenWrt-Devel] [PATCH] mtd_get_mac_ascii Return first occurence of $key.
Petr Štetiar
ynezz at true.cz
Sat Jul 11 06:13:24 EDT 2020
vargagab at gmail.com <vargagab at gmail.com> [2019-11-26 14:10:03]:
Hi,
> 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')
$ echo -e "abc=moo\nabc=foo" | ( export key=abc; sed -n 's/^'"$key"'=//p' )
moo
foo
$ echo -e "abc=moo\nabc=foo" | ( export key=abc; sed -n '1,/'"$key"'=/s/^'"$key"'=//p' )
moo
foo
Seems to not work as expected.
-- ynezz
More information about the openwrt-devel
mailing list