diff options
author | Jeffrey Stedfast <fejj@ximian.com> | 2001-04-02 06:54:44 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2001-04-02 06:54:44 +0800 |
commit | b27a35eae5e2f63a15ec9c151b70b31b7be6c8fe (patch) | |
tree | 5171fb44493d387053774d9568133ed36ed61434 /camel/providers | |
parent | 1193763d9e8b6abf209bc6593a7e09dd76359bb1 (diff) | |
download | gsoc2013-evolution-b27a35eae5e2f63a15ec9c151b70b31b7be6c8fe.tar.gz gsoc2013-evolution-b27a35eae5e2f63a15ec9c151b70b31b7be6c8fe.tar.zst gsoc2013-evolution-b27a35eae5e2f63a15ec9c151b70b31b7be6c8fe.zip |
New files to handle the LOGIN SASL mechanism.
2001-04-01 Jeffrey Stedfast <fejj@ximian.com>
* 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
Diffstat (limited to 'camel/providers')
-rw-r--r-- | camel/providers/smtp/camel-smtp-transport.c | 33 |
1 files changed, 24 insertions, 9 deletions
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)) { |