]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
comgt-ncm: fix modem manufacturer detection 18460/head
authorJakub Łabuz <jakub@labuz.dev>
Fri, 11 Apr 2025 16:33:49 +0000 (18:33 +0200)
committerRobert Marko <robimarko@gmail.com>
Thu, 17 Apr 2025 23:37:48 +0000 (01:37 +0200)
Fix an issue where NCM interface initialization fails because of wrong
modem manufacturer detection.

gcom call returns an output with Windows-style line breaks (containing \r)
what makes awk call return empty or malformed manufacturer name. Changing
awk RS variable to handle both \n and \r\n as line break fixes this issue.

Fixes #17448 and #17998 GitHub issues.

Signed-off-by: Jakub Łabuz <jakub@labuz.dev>
Link: https://github.com/openwrt/openwrt/pull/18460
Signed-off-by: Robert Marko <robimarko@gmail.com>
package/network/utils/comgt/files/ncm.sh

index 761dafb24e3131b8583d4f80db79b46739fa6677..a986973838717083d7391d7727df68b112ca3a7d 100644 (file)
@@ -91,7 +91,7 @@ proto_ncm_setup() {
 
        start=$(date +%s)
        while true; do
-               manufacturer=$(gcom -d "$device" -s /etc/gcom/getcardinfo.gcom | awk 'NF && $0 !~ /AT\+CGMI/ { sub(/\+CGMI: /,""); print tolower($1); exit; }')
+               manufacturer=$(gcom -d "$device" -s /etc/gcom/getcardinfo.gcom | awk -v RS='\r?\n' 'NF && $0 !~ /AT\+CGMI/ { sub(/\+CGMI: /,""); print tolower($1); exit; }')
                [ "$manufacturer" = "error" ] && {
                        manufacturer=""
                }