[evolution-data-server] Bug 615239 - Fix GSSAPI (and other SASL) authentication for imapx
- From: David Woodhouse <dwmw2 src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] Bug 615239 - Fix GSSAPI (and other SASL) authentication for imapx
- Date: Mon, 14 Jun 2010 11:32:20 +0000 (UTC)
commit 35f61b39d3f1c272d6607d87b43394db4f51dd83
Author: David Woodhouse <David Woodhouse intel com>
Date: Mon Jun 14 12:19:38 2010 +0100
Bug 615239 - Fix GSSAPI (and other SASL) authentication for imapx
camel/providers/imapx/camel-imapx-server.c | 49 +++++++++++++++++++++------
1 files changed, 38 insertions(+), 11 deletions(-)
---
diff --git a/camel/providers/imapx/camel-imapx-server.c b/camel/providers/imapx/camel-imapx-server.c
index 1bb4a79..8a6ce5a 100644
--- a/camel/providers/imapx/camel-imapx-server.c
+++ b/camel/providers/imapx/camel-imapx-server.c
@@ -1487,14 +1487,19 @@ imapx_continuation(CamelIMAPXServer *imap, CamelException *ex)
case CAMEL_IMAPX_COMMAND_AUTH: {
gchar *resp;
guchar *token;
- gint tok;
- guint len;
- tok = camel_imapx_stream_token(imap->stream, &token, &len, ex);
+ camel_imapx_stream_text (imap->stream, &token, ex);
+ if (camel_exception_is_set(ex))
+ return -1;
+
resp = camel_sasl_challenge_base64((CamelSasl *)cp->ob, (const gchar *) token, ex);
+ g_free(token);
if (camel_exception_is_set(ex))
return -1;
-
+ if (!resp) {
+ camel_exception_set (ex, 1, "Authentication mechanism failed");
+ return -1;
+ }
c(printf("got auth continuation, feeding token '%s' back to auth mech\n", resp));
camel_stream_write((CamelStream *)imap->stream, resp, strlen(resp));
@@ -1502,7 +1507,7 @@ imapx_continuation(CamelIMAPXServer *imap, CamelException *ex)
/* we want to keep getting called until we get a status reponse from the server
ignore what sasl tells us */
newliteral = ic;
-
+ goto noskip;
break; }
case CAMEL_IMAPX_COMMAND_FILE: {
CamelStream *file;
@@ -1528,7 +1533,7 @@ imapx_continuation(CamelIMAPXServer *imap, CamelException *ex)
}
camel_imapx_stream_skip(imap->stream, ex);
-
+ noskip:
cp = cp->next;
if (cp->next) {
ic->current = cp;
@@ -1668,6 +1673,8 @@ imapx_command_run(CamelIMAPXServer *is, CamelIMAPXCommand *ic)
do {
imapx_step(is, ic->ex);
} while (ic->status == NULL && !camel_exception_is_set (ic->ex));
+ if (is->literal == ic)
+ is->literal = NULL;
QUEUE_LOCK(is);
camel_dlist_remove((CamelDListNode *)ic);
@@ -2440,6 +2447,7 @@ imapx_reconnect (CamelIMAPXServer *is, CamelException *ex)
CamelService *service = (CamelService *) is->store;
const gchar *auth_domain = NULL;
gboolean authenticated = FALSE;
+ CamelServiceAuthType *authtype = NULL;
guint32 prompt_flags = CAMEL_SESSION_PASSWORD_SECRET;
while (!authenticated) {
@@ -2458,7 +2466,28 @@ imapx_reconnect (CamelIMAPXServer *is, CamelException *ex)
if (is->state == IMAPX_AUTHENTICATED)
break;
- if (service->url->passwd == NULL) {
+ if (!authtype && service->url->authmech) {
+ if (is->cinfo && !g_hash_table_lookup (is->cinfo->auth_types, service->url->authmech)) {
+ camel_exception_setv (
+ ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE,
+ _("IMAP server %s does not support requested "
+ "authentication type %s"),
+ service->url->host,
+ service->url->authmech);
+ goto exception;
+ }
+
+ authtype = camel_sasl_authtype (service->url->authmech);
+ if (!authtype) {
+ camel_exception_setv (
+ ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE,
+ _("No support for authentication type %s"),
+ service->url->authmech);
+ goto exception;
+ }
+ }
+
+ if (service->url->passwd == NULL && (!authtype || authtype->need_password)) {
gchar *base_prompt;
gchar *full_prompt;
@@ -2486,10 +2515,8 @@ imapx_reconnect (CamelIMAPXServer *is, CamelException *ex)
goto exception;
}
}
-
- if (service->url->authmech
- && (sasl = camel_sasl_new("imap", service->url->authmech, NULL))) {
- ic = camel_imapx_command_new("AUTHENTICATE", NULL, "AUTHENTICATE %A", sasl);
+ if (authtype && (sasl = camel_sasl_new ("imap", authtype->authproto, service))) {
+ ic = camel_imapx_command_new ("AUTHENTICATE", NULL, "AUTHENTICATE %A", sasl);
g_object_unref (sasl);
} else {
ic = camel_imapx_command_new("LOGIN", NULL, "LOGIN %s %s", service->url->user, service->url->passwd);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]