aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2015-10-20 10:37:48 +0200
committerAleksander Morgado <aleksander@aleksander.es>2015-10-21 17:24:24 +0200
commita89dadcbc630099fce11a9fc0088d5269e34aee8 (patch)
tree83059a359228a8b1cdd3281e5835fb4604afbde2
parent5b568e97f8126879099c349486465cc9f14f64e5 (diff)
bearer-qmi: don't add auth settings if no user/pass/auth given
Auth settings will be added in a QMI message only if at least one of these is requested: * An explicit auth preference is requested. * User string is given and isn't empty. * Password string is given and isn't empty.
-rw-r--r--src/mm-bearer-qmi.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/mm-bearer-qmi.c b/src/mm-bearer-qmi.c
index db8e0acb..2f722e27 100644
--- a/src/mm-bearer-qmi.c
+++ b/src/mm-bearer-qmi.c
@@ -222,6 +222,7 @@ static QmiMessageWdsStartNetworkInput *
build_start_network_input (ConnectContext *ctx)
{
QmiMessageWdsStartNetworkInput *input;
+ gboolean has_user, has_password;
g_assert (ctx->running_ipv4 || ctx->running_ipv6);
g_assert (!(ctx->running_ipv4 && ctx->running_ipv6));
@@ -231,12 +232,21 @@ build_start_network_input (ConnectContext *ctx)
if (ctx->apn && ctx->apn[0])
qmi_message_wds_start_network_input_set_apn (input, ctx->apn, NULL);
- if (ctx->auth != QMI_WDS_AUTHENTICATION_NONE) {
- qmi_message_wds_start_network_input_set_authentication_preference (input, ctx->auth, NULL);
+ has_user = (ctx->user && ctx->user[0]);
+ has_password = (ctx->password && ctx->password[0]);
- if (ctx->user)
+ /* Need to add auth info? */
+ if (has_user || has_password || ctx->auth != QMI_WDS_AUTHENTICATION_NONE) {
+ /* We define a valid auth preference if we have either user or password, or a explicit
+ * request for one to be set. If no explicit one was given, default to PAP. */
+ qmi_message_wds_start_network_input_set_authentication_preference (
+ input,
+ (ctx->auth != QMI_WDS_AUTHENTICATION_NONE) ? ctx->auth : QMI_WDS_AUTHENTICATION_PAP,
+ NULL);
+
+ if (has_user)
qmi_message_wds_start_network_input_set_username (input, ctx->user, NULL);
- if (ctx->password)
+ if (has_password)
qmi_message_wds_start_network_input_set_password (input, ctx->password, NULL);
}
@@ -1032,8 +1042,8 @@ _connect (MMBaseBearer *self,
g_object_unref (properties);
if (auth == MM_BEARER_ALLOWED_AUTH_UNKNOWN) {
- mm_dbg ("Using default (PAP) authentication method");
- ctx->auth = QMI_WDS_AUTHENTICATION_PAP;
+ /* We'll default to PAP later if needed */
+ ctx->auth = QMI_WDS_AUTHENTICATION_NONE;
} else if (auth & (MM_BEARER_ALLOWED_AUTH_PAP |
MM_BEARER_ALLOWED_AUTH_CHAP |
MM_BEARER_ALLOWED_AUTH_NONE)) {