aboutsummaryrefslogtreecommitdiffstats
path: root/camel/providers
diff options
context:
space:
mode:
authorNot Zed <NotZed@Ximian.com>2001-08-03 23:33:57 +0800
committerMichael Zucci <zucchi@src.gnome.org>2001-08-03 23:33:57 +0800
commit99e55fbc6b1ad39fd840c8b917583bc1b2cce2dd (patch)
tree81f1d48fe93bc80703eaeba37dcb94ed29e226db /camel/providers
parent68518c1d989ded3031c490fb0b542424aef369cf (diff)
downloadgsoc2013-evolution-99e55fbc6b1ad39fd840c8b917583bc1b2cce2dd.tar
gsoc2013-evolution-99e55fbc6b1ad39fd840c8b917583bc1b2cce2dd.tar.gz
gsoc2013-evolution-99e55fbc6b1ad39fd840c8b917583bc1b2cce2dd.tar.bz2
gsoc2013-evolution-99e55fbc6b1ad39fd840c8b917583bc1b2cce2dd.tar.lz
gsoc2013-evolution-99e55fbc6b1ad39fd840c8b917583bc1b2cce2dd.tar.xz
gsoc2013-evolution-99e55fbc6b1ad39fd840c8b917583bc1b2cce2dd.tar.zst
gsoc2013-evolution-99e55fbc6b1ad39fd840c8b917583bc1b2cce2dd.zip
special case popb4smtp auth before we try and connect, and do the magic
2001-08-03 Not Zed <NotZed@Ximian.com> * providers/smtp/camel-smtp-transport.c (smtp_connect): special case popb4smtp auth before we try and connect, and do the magic here first. 2001-08-02 Not Zed <NotZed@Ximian.com> * providers/smtp/camel-smtp-transport.c (smtp_connect): Check for POPB4SMTP separate to the esmtp auth list. (smtp_auth): If creating the sasl object means it is already authenticated, then exit early. Sort of 'clean hack' to help popb4smtp work. (smtp_auth): Unref the sasl object, clean up a memleak i think. * providers/smtp/camel-smtp-provider.c (camel_provider_module_init): Added POPB4SMTP auth type. * camel-sasl.c (camel_sasl_authtype): Added POPB4SMTP type. * camel-sasl-popb4smtp.c: New file for pop before smtp 'authentication'. * Makefile.am (libcamel_la_SOURCES, HEADERS): Add camel-sasl-popb4smtp.[ch]. svn path=/trunk/; revision=11615
Diffstat (limited to 'camel/providers')
-rw-r--r--camel/providers/smtp/camel-smtp-provider.c4
-rw-r--r--camel/providers/smtp/camel-smtp-transport.c38
2 files changed, 30 insertions, 12 deletions
diff --git a/camel/providers/smtp/camel-smtp-provider.c b/camel/providers/smtp/camel-smtp-provider.c
index 299cdc1ccb..a52f3c3a14 100644
--- a/camel/providers/smtp/camel-smtp-provider.c
+++ b/camel/providers/smtp/camel-smtp-provider.c
@@ -54,8 +54,8 @@ camel_provider_module_init (CamelSession *session)
{
smtp_provider.object_types[CAMEL_PROVIDER_TRANSPORT] =
camel_smtp_transport_get_type ();
- smtp_provider.authtypes = g_list_append (camel_sasl_authtype_list (TRUE),
- camel_sasl_authtype ("LOGIN"));
+ smtp_provider.authtypes = g_list_append(camel_sasl_authtype_list(TRUE), camel_sasl_authtype ("LOGIN"));
+ smtp_provider.authtypes = g_list_append(smtp_provider.authtypes, camel_sasl_authtype ("POPB4SMTP"));
smtp_provider.service_cache = g_hash_table_new (camel_url_hash, camel_url_equal);
camel_session_register_provider (session, &smtp_provider);
diff --git a/camel/providers/smtp/camel-smtp-transport.c b/camel/providers/smtp/camel-smtp-transport.c
index 93963ffe1b..86674fdc2a 100644
--- a/camel/providers/smtp/camel-smtp-transport.c
+++ b/camel/providers/smtp/camel-smtp-transport.c
@@ -233,7 +233,7 @@ connect_to_server (CamelService *service, CamelException *ex)
struct hostent *h;
guint32 addrlen;
int port, ret;
-
+
if (!CAMEL_SERVICE_CLASS (parent_class)->connect (service, ex))
return FALSE;
@@ -343,6 +343,25 @@ smtp_connect (CamelService *service, CamelException *ex)
{
CamelSmtpTransport *transport = CAMEL_SMTP_TRANSPORT (service);
+ /* We (probably) need to check popb4smtp before we connect ... */
+ if (strcmp(service->url->authmech, "POPB4SMTP") == 0) {
+ int truth;
+ GByteArray *chal;
+ CamelSasl *sasl;
+
+ sasl = camel_sasl_new("smtp", "POPB4SMTP", service);
+ chal = camel_sasl_challenge(sasl, NULL, ex);
+ truth = camel_sasl_authenticated(sasl);
+ if (chal)
+ g_byte_array_free(chal, TRUE);
+ camel_object_unref((CamelObject *)sasl);
+
+ if (!truth)
+ return FALSE;
+
+ return connect_to_server(service, ex);
+ }
+
if (!connect_to_server (service, ex))
return FALSE;
@@ -352,11 +371,11 @@ smtp_connect (CamelService *service, CamelException *ex)
CamelServiceAuthType *authtype;
gboolean authenticated = FALSE;
char *errbuf = NULL;
-
+
if (!transport->is_esmtp || !g_hash_table_lookup (transport->authtypes, service->url->authmech)) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE,
_("SMTP server %s does not support requested "
- "authentication type %s"), service->url->host,
+ "authentication type %s"), service->url->host,
service->url->authmech);
camel_service_disconnect (service, TRUE, NULL);
return FALSE;
@@ -737,17 +756,17 @@ smtp_auth (CamelSmtpTransport *transport, const char *mech, CamelException *ex)
gchar *cmdbuf, *respbuf = NULL, *challenge;
CamelSasl *sasl;
+ camel_operation_start_transient(NULL, _("SMTP Authentication"));
+
sasl = camel_sasl_new ("smtp", mech, CAMEL_SERVICE (transport));
if (!sasl) {
- g_free (respbuf);
+ camel_operation_end(NULL);
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Error creating SASL authentication object."));
return FALSE;
}
- camel_operation_start_transient(NULL, _("SMTP Authentication"));
-
- challenge = camel_sasl_challenge_base64 (sasl, NULL, ex);
+ challenge = camel_sasl_challenge_base64(sasl, NULL, ex);
if (challenge) {
cmdbuf = g_strdup_printf ("AUTH %s %s\r\n", mech, challenge);
g_free (challenge);
@@ -812,6 +831,7 @@ smtp_auth (CamelSmtpTransport *transport, const char *mech, CamelException *ex)
goto lose;
}
+ camel_object_unref((CamelObject *)sasl);
camel_operation_end(NULL);
return TRUE;
@@ -829,9 +849,7 @@ smtp_auth (CamelSmtpTransport *transport, const char *mech, CamelException *ex)
_("Bad authentication response from server.\n"));
}
- if (sasl)
- camel_object_unref (CAMEL_OBJECT (sasl));
-
+ camel_object_unref (CAMEL_OBJECT (sasl));
camel_operation_end(NULL);
return FALSE;