aboutsummaryrefslogtreecommitdiff
path: root/src/mm-bearer-qmi.c
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2021-04-08 11:15:21 +0200
committerAleksander Morgado <aleksander@aleksander.es>2021-04-29 10:13:22 +0000
commitfffe49d03e650239390e0f65cc969b9713183488 (patch)
tree57ae8e5b1f91287fe420e40da7c244709cdfa69c /src/mm-bearer-qmi.c
parent865014510a976fdccb1c59d5bcf41bd8cbfc46d1 (diff)
modem-helpers-qmi: perform validation in allowed_auth_to_qmi_authentication()
If we find that none of the requested auth settings are supported, we should fail and return an error. Also, make sure we set the CHAP fallback default only if either user or password are given.
Diffstat (limited to 'src/mm-bearer-qmi.c')
-rw-r--r--src/mm-bearer-qmi.c29
1 files changed, 9 insertions, 20 deletions
diff --git a/src/mm-bearer-qmi.c b/src/mm-bearer-qmi.c
index 5ab2dc2c..d375fb7f 100644
--- a/src/mm-bearer-qmi.c
+++ b/src/mm-bearer-qmi.c
@@ -2098,27 +2098,16 @@ _connect (MMBaseBearer *_self,
auth = mm_bearer_properties_get_allowed_auth (properties);
g_object_unref (properties);
- if (auth == MM_BEARER_ALLOWED_AUTH_UNKNOWN) {
- /* We'll default to CHAP later if needed */
+ if (!ctx->user && !ctx->password)
ctx->auth = QMI_WDS_AUTHENTICATION_NONE;
- } else if (auth & (MM_BEARER_ALLOWED_AUTH_PAP |
- MM_BEARER_ALLOWED_AUTH_CHAP |
- MM_BEARER_ALLOWED_AUTH_NONE)) {
- /* Only PAP and/or CHAP or NONE are supported */
- ctx->auth = mm_bearer_allowed_auth_to_qmi_authentication (auth);
- } else {
- gchar *str;
-
- str = mm_bearer_allowed_auth_build_string_from_mask (auth);
- g_task_return_new_error (
- task,
- MM_CORE_ERROR,
- MM_CORE_ERROR_UNSUPPORTED,
- "Cannot use any of the specified authentication methods (%s)",
- str);
- g_object_unref (task);
- g_free (str);
- goto out;
+ else {
+ auth = mm_bearer_properties_get_allowed_auth (properties);
+ ctx->auth = mm_bearer_allowed_auth_to_qmi_authentication (auth, self, &error);
+ if (error) {
+ g_task_return_error (task, error);
+ g_object_unref (task);
+ goto out;
+ }
}
multiplex = mm_bearer_properties_get_multiplex (properties);