From c61ac41df976c1fbf759bd0775d53f571dfe5a85 Mon Sep 17 00:00:00 2001 From: ktetzlaff Date: Mon, 8 Apr 2024 04:28:11 +0200 Subject: [PATCH] modem-manager-autosetup: Fix jq filter for apn without 'type' attribute The initial jq filter used to extract the APN info from apns-conf.json fails with: ``` text jq: error (...): null (null) and string ("default") cannot have their containment checked ``` when one of the apn objects selected by mcc/mnc doesn't have a 'type' attribute (as is the case for mcc=262, mnc=07). As a result, otherwise matching APN objects will not be considered. This commit fixes the jq filter by checking for the presence of the 'type' attribute. --- utils/modem-manager-autosetup/files/autosetup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100644 => 100755 utils/modem-manager-autosetup/files/autosetup.sh diff --git a/utils/modem-manager-autosetup/files/autosetup.sh b/utils/modem-manager-autosetup/files/autosetup.sh old mode 100644 new mode 100755 index 6b0b433b5..6b0118628 --- a/utils/modem-manager-autosetup/files/autosetup.sh +++ b/utils/modem-manager-autosetup/files/autosetup.sh @@ -7,7 +7,7 @@ get_settings() { [ -n "$1" ] || return local mcc="$(echo "$1" | head -c 3)" local mnc="$(echo "$1" | tail -c +4)" - local info="$(jq '.apns.apn| [ .[] | select(.mcc == "'"$mcc"'" and .mnc == "'"$mnc"'" and (.type | contains("default"))) ][0]' < /usr/share/modem-manager-autosetup/apns-conf.json)" + local info="$(jq '.apns.apn| [ .[] | select(.mcc == "'"$mcc"'" and .mnc == "'"$mnc"'" and has("type") and (.type | contains("default"))) ][0]' < /usr/share/modem-manager-autosetup/apns-conf.json)" [ -n "$info" ] || info="$(jq '.apns.apn| [ .[] | select(.mcc == "'"$mcc"'" and .mnc == "'"$mnc"'") ][0]' < /usr/share/modem-manager-autosetup/apns-conf.json)" if [ -n "$info" ] && [ "$info" != null ]; then APN="$(echo "$info" | jq -r .apn)"