uqmi: stop proto handler if verify pin count is not 3
[openwrt/.git] / package / network / utils / uqmi / files / lib / netifd / proto / qmi.sh
index bfe01ddcc39843264ffd08105e48c3e675198c0f..f7b5f27ef67891654685898ed4d09b39e9e7cd5c 100755 (executable)
@@ -94,6 +94,7 @@ proto_qmi_setup() {
                . /usr/share/libubox/jshn.sh
                json_load "$(uqmi -s -d "$device" --get-pin-status)"
                json_get_var pin1_status pin1_status
+               json_get_var pin1_verify_tries pin1_verify_tries
 
                case "$pin1_status" in
                        disabled)
@@ -106,6 +107,12 @@ proto_qmi_setup() {
                                return 1
                                ;;
                        not_verified)
+                               [ "$pin1_verify_tries" -lt "3" ] && {
+                                       echo "PIN verify count value is $pin1_verify_tries this is below the limit of 3"
+                                       proto_notify_error "$interface" PIN_TRIES_BELOW_LIMIT
+                                       proto_block_restart "$interface"
+                                       return 1
+                               }
                                if [ -n "$pincode" ]; then
                                        uqmi -s -d "$device" --verify-pin1 "$pincode" > /dev/null 2>&1 || uqmi -s -d "$device" --uim-verify-pin1 "$pincode" > /dev/null 2>&1 || {
                                                echo "Unable to verify PIN"