From: Pierre Habouzit Date: Mon, 21 May 2007 09:00:23 +0000 (+0200) Subject: some fixes wrt imap and pop authentication. X-Git-Url: http://git.madism.org/?a=commitdiff_plain;h=2e0d58d93811d43a16f078562cbfa1526c96a371;p=apps%2Fmadmutt.git some fixes wrt imap and pop authentication. Signed-off-by: Pierre Habouzit --- 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); } }