From 2e0d58d93811d43a16f078562cbfa1526c96a371 Mon Sep 17 00:00:00 2001 From: Pierre Habouzit Date: Mon, 21 May 2007 11:00:23 +0200 Subject: [PATCH] some fixes wrt imap and pop authentication. Signed-off-by: Pierre Habouzit --- imap/imap.c | 18 ++++++------------ imap/imap_private.h | 1 + imap/util.c | 1 + pop.c | 2 ++ 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/imap/imap.c b/imap/imap.c index ac9363e..15f02f2 100644 --- a/imap/imap.c +++ b/imap/imap.c @@ -299,7 +299,6 @@ IMAP_DATA *imap_conn_find (const ACCOUNT * account, int flags) CONNECTION *conn; IMAP_DATA *idata; ACCOUNT *creds; - int new = 0; if (!(conn = mutt_conn_find (NULL, account))) return NULL; @@ -332,26 +331,28 @@ IMAP_DATA *imap_conn_find (const ACCOUNT * account, int flags) idata = imap_new_idata(); conn->data = idata; idata->conn = conn; - new = 1; } if (idata->state == IMAP_DISCONNECTED) imap_open_connection (idata); if (idata->state == IMAP_CONNECTED) { - if (!imap_authenticate (idata)) { + if (!imap_authenticate(idata)) { idata->state = IMAP_AUTHENTICATED; } else { + mutt_socket_close(idata->conn); + idata->state = IMAP_DISCONNECTED; idata->conn->account.has_pass = 0; } p_delete(&idata->capstr); } - if (new && idata->state == IMAP_AUTHENTICATED) { + if (idata->isnew && idata->state == IMAP_AUTHENTICATED) { imap_get_delim (idata); if (option (OPTIMAPCHECKSUBSCRIBED)) { mutt_message _("Checking mailbox subscriptions"); imap_exec (idata, "LSUB \"\" \"*\"", 0); } + idata->isnew = 0; } return idata; @@ -1336,7 +1337,6 @@ int imap_subscribe (char *path, int subscribe) char buf[LONG_STRING]; char mbox[LONG_STRING]; char errstr[STRING]; - BUFFER err, token; IMAP_MBOX mx; if (mx_get_magic (path) != M_IMAP || imap_parse_path (path, &mx) < 0) { @@ -1352,13 +1352,7 @@ int imap_subscribe (char *path, int subscribe) imap_fix_path (idata, mx.mbox, buf, sizeof (buf)); if (option (OPTIMAPCHECKSUBSCRIBED)) { - p_clear(&token, 1); - err.data = errstr; - err.dsize = sizeof (errstr); - snprintf (mbox, sizeof (mbox), "%smailboxes \"%s\"", - subscribe ? "" : "un", path); - mutt_parse_rc_line (mbox, &token, &err); - p_delete(&token.data); + buffy_do_mailboxes(path, subscribe); } if (subscribe) diff --git a/imap/imap_private.h b/imap/imap_private.h index cfa9b4d..cebd4ff 100644 --- a/imap/imap_private.h +++ b/imap/imap_private.h @@ -124,6 +124,7 @@ typedef struct { CONNECTION *conn; unsigned char state; unsigned char status; + unsigned char isnew; /* let me explain capstr: SASL needs the capability string (not bits). * we have 3 options: * 1. rerun CAPABILITY inside SASL function. diff --git a/imap/util.c b/imap/util.c index db7e3af..230f005 100644 --- a/imap/util.c +++ b/imap/util.c @@ -148,6 +148,7 @@ IMAP_DATA *imap_new_idata (void) { IMAP_DATA *res = p_new(IMAP_DATA, 1); buffer_init(&res->cmd.buf); + res->isnew = 1; return res; } diff --git a/pop.c b/pop.c index 2cc16e7..b223c31 100644 --- a/pop.c +++ b/pop.c @@ -416,6 +416,7 @@ static pop_query_status pop_authenticate (pop_data_t * pop_data) attempts++; break; } + mutt_socket_close(pop_data->conn); } } } else { @@ -431,6 +432,7 @@ static pop_query_status pop_authenticate (pop_data_t * pop_data) attempts++; break; } + mutt_socket_close(pop_data->conn); } } -- 2.20.1