From a131c6953a0a24a6ed8c365cb5e398fa5e52afcf Mon Sep 17 00:00:00 2001 From: Aleksander Morgado Date: Mon, 6 Jul 2020 16:53:08 +0200 Subject: [PATCH] cinterion: quote user/password strings in AT^SGAUTH calls The ELS61 doesn't like authentication given without quotes: [modem3/ttyACM1/at] --> 'AT^SGAUTH=8,1,tm,t-mobile' [modem3/ttyACM1/at] <-- '+CME ERROR: 4' Only when user/pass strings are quoted it works: [modem6/ttyACM1/at] --> 'AT^SGAUTH=8,1,"t-mobile","tm"' [modem6/ttyACM1/at] <-- 'OK' --- .../cinterion/mm-broadband-bearer-cinterion.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/plugins/cinterion/mm-broadband-bearer-cinterion.c b/plugins/cinterion/mm-broadband-bearer-cinterion.c index a4ee87d2..b3b1d240 100644 --- a/plugins/cinterion/mm-broadband-bearer-cinterion.c +++ b/plugins/cinterion/mm-broadband-bearer-cinterion.c @@ -203,12 +203,14 @@ build_auth_string (MMBroadbandBearerCinterion *self, MMBearerProperties *config, guint cid) { - const gchar *user; - const gchar *passwd; - gboolean has_user; - gboolean has_passwd; MMBearerAllowedAuth auth; BearerCinterionAuthType encoded_auth = BEARER_CINTERION_AUTH_UNKNOWN; + gboolean has_user; + gboolean has_passwd; + const gchar *user; + const gchar *passwd; + g_autofree gchar *quoted_user = NULL; + g_autofree gchar *quoted_passwd = NULL; user = mm_bearer_properties_get_user (config); passwd = mm_bearer_properties_get_password (config); @@ -236,11 +238,14 @@ build_auth_string (MMBroadbandBearerCinterion *self, encoded_auth = BEARER_CINTERION_AUTH_PAP; } + quoted_user = mm_port_serial_at_quote_string (user ? user : ""); + quoted_passwd = mm_port_serial_at_quote_string (passwd ? passwd : ""); + return g_strdup_printf ("^SGAUTH=%u,%d,%s,%s", cid, encoded_auth, - passwd ? passwd : "", - user ? user : ""); + quoted_passwd, + quoted_user); } /******************************************************************************/