uqmi: ensure CID is a numeric value before proceeding
authorKoen Vandeputte <koen.vandeputte@ncentric.com>
Mon, 19 Feb 2018 10:02:45 +0000 (11:02 +0100)
committerJohn Crispin <john@phrozen.org>
Tue, 20 Feb 2018 09:50:37 +0000 (10:50 +0100)
The current implementation only checked if uqmi itself executed
correctly which is also the case when the returned value is actually
an error.

Rework this, checking that CID is a numeric value, which can only
be true if uqmi itself also executed correctly.

Signed-off-by: Koen Vandeputte <koen.vandeputte@ncentric.com>
package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh

index c3da5ede26b14cae5e57d6f9b0f62edfc09421eb..46ea134182e3a9e12b885f1eb72ab7982516efc0 100755 (executable)
@@ -140,11 +140,11 @@ proto_qmi_setup() {
 
        [ "$pdptype" = "ip" -o "$pdptype" = "ipv4v6" ] && {
                cid_4=$(uqmi -s -d "$device" --get-client-id wds)
-               [ $? -ne 0 ] && {
+               if ! [ "$cid_4" -eq "$cid_4" ] 2> /dev/null; then
                        echo "Unable to obtain client ID"
                        proto_notify_error "$interface" NO_CID
                        return 1
-               }
+               fi
 
                uqmi -s -d "$device" --set-client-id wds,"$cid_4" --set-ip-family ipv4 > /dev/null
 
@@ -177,11 +177,11 @@ proto_qmi_setup() {
 
        [ "$pdptype" = "ipv6" -o "$pdptype" = "ipv4v6" ] && {
                cid_6=$(uqmi -s -d "$device" --get-client-id wds)
-               [ $? -ne 0 ] && {
+               if ! [ "$cid_6" -eq "$cid_6" ] 2> /dev/null; then
                        echo "Unable to obtain client ID"
                        proto_notify_error "$interface" NO_CID
                        return 1
-               }
+               fi
 
                uqmi -s -d "$device" --set-client-id wds,"$cid_6" --set-ip-family ipv6 > /dev/null