From b27a35eae5e2f63a15ec9c151b70b31b7be6c8fe Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Sun, 1 Apr 2001 22:54:44 +0000 Subject: New files to handle the LOGIN SASL mechanism. 2001-04-01 Jeffrey Stedfast * camel-sasl-login.[c,h]: New files to handle the LOGIN SASL mechanism. * camel-sasl-plain.c: Removed the definition of camel_sasl_login_authtype. * camel-sasl.c (camel_sasl_new): Oops. I thought LOGIN was an alias to PLAIN. I was wrong. These two SASL objects have to be separate. * providers/smtp/camel-smtp-transport.c (smtp_auth): Updated to check for and use authmech->quick_login when available. svn path=/trunk/; revision=9088 --- camel/providers/smtp/camel-smtp-transport.c | 33 +++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 9 deletions(-) (limited to 'camel/providers') diff --git a/camel/providers/smtp/camel-smtp-transport.c b/camel/providers/smtp/camel-smtp-transport.c index af41b2f5b9..1c18c154b3 100644 --- a/camel/providers/smtp/camel-smtp-transport.c +++ b/camel/providers/smtp/camel-smtp-transport.c @@ -696,18 +696,39 @@ smtp_helo (CamelSmtpTransport *transport, CamelException *ex) static gboolean smtp_auth (CamelSmtpTransport *transport, const char *mech, CamelException *ex) { + CamelServiceAuthType *authtype; gchar *cmdbuf, *respbuf = NULL; CamelSasl *sasl; + sasl = camel_sasl_new ("smtp", mech, CAMEL_SERVICE (transport)); + if (!sasl) { + g_free (respbuf); + camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, + _("Error creating SASL authentication object.")); + return FALSE; + } + + /* get the authtype object so we know if we can challenge the server */ + authtype = camel_sasl_authtype (mech); + /* tell the server we want to authenticate... */ - cmdbuf = g_strdup_printf ("AUTH %s\r\n", mech); + if (authtype && authtype->quick_login) { + /* cool, we can challenge the server in our initial request */ + char *challenge; + + challenge = camel_sasl_challenge_base64 (sasl, NULL, ex); + cmdbuf = g_strdup_printf ("AUTH %s %s\r\n", mech, challenge); + g_free (challenge); + } else + cmdbuf = g_strdup_printf ("AUTH %s\r\n", mech); + d(fprintf (stderr, "sending : %s", cmdbuf)); if (camel_stream_write (transport->ostream, cmdbuf, strlen (cmdbuf)) == -1) { g_free (cmdbuf); camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, _("AUTH request timed out: %s"), g_strerror (errno)); - return FALSE; + goto lose; } g_free (cmdbuf); @@ -719,13 +740,7 @@ smtp_auth (CamelSmtpTransport *transport, const char *mech, CamelException *ex) camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, _("AUTH request timed out: %s"), g_strerror (errno)); - return FALSE; - } - - sasl = camel_sasl_new ("smtp", mech, CAMEL_SERVICE (transport)); - if (!sasl) { - g_free (respbuf); - goto break_and_lose; + goto lose; } while (!camel_sasl_authenticated (sasl)) { -- cgit