isync

mailbox synchronization program
git clone https://git.code.sf.net/p/isync/isync
Log | Files | Refs | README | LICENSE

commit d6b9a139e46027c49b5f59792a90e92aff00af29
parent b6c36624f04cd388873785c0631df3f2f9ac4bf0
Author: Oswald Buddenhagen <ossi@users.sf.net>
Date:   Thu,  9 Dec 2021 11:42:40 +0100

re-issue IMAP CAPABILITY after authentication

... if the server didn't include a corresponding response code by
itself. required for the sorry excuse of an imap server that ms
exchange is.

Diffstat:
Msrc/drv_imap.c | 16++++++++++++++++
1 file changed, 16 insertions(+), 0 deletions(-)

diff --git a/src/drv_imap.c b/src/drv_imap.c @@ -1906,6 +1906,7 @@ static void imap_open_store_authenticate_p3( imap_store_t *, imap_cmd_t *, int ) #endif static void imap_open_store_authenticate2( imap_store_t * ); static void imap_open_store_authenticate2_p2( imap_store_t *, imap_cmd_t *, int ); +static void imap_open_store_authenticate2_p3( imap_store_t *, imap_cmd_t *, int ); static void imap_open_store_compress( imap_store_t * ); #ifdef HAVE_LIBZ static void imap_open_store_compress_p2( imap_store_t *, imap_cmd_t *, int ); @@ -2472,6 +2473,7 @@ imap_open_store_authenticate2( imap_store_t *ctx ) cmd = new_imap_cmd( sizeof(*cmd) ); cmd->param.cont = do_sasl_auth; + ctx->caps = 0; imap_exec( ctx, cmd, done_sasl_auth, enc ? "AUTHENTICATE %s %s" : "AUTHENTICATE %s", gotmech, enc ); free( enc ); return; @@ -2494,6 +2496,7 @@ imap_open_store_authenticate2( imap_store_t *ctx ) if (!ctx->conn.ssl) #endif warn( "*** IMAP Warning *** Password is being sent in the clear\n" ); + ctx->caps = 0; imap_exec( ctx, NULL, imap_open_store_authenticate2_p2, "LOGIN \"%\\s\" \"%\\s\"", srvc->user, srvc->pass ); return; @@ -2513,6 +2516,19 @@ imap_open_store_authenticate2( imap_store_t *ctx ) static void imap_open_store_authenticate2_p2( imap_store_t *ctx, imap_cmd_t *cmd ATTR_UNUSED, int response ) { + if (response == RESP_NO) { + imap_open_store_bail( ctx, FAIL_FINAL ); + } else if (response == RESP_OK) { + if (!ctx->caps) + imap_exec( ctx, NULL, imap_open_store_authenticate2_p3, "CAPABILITY" ); + else + imap_open_store_compress( ctx ); + } +} + +static void +imap_open_store_authenticate2_p3( imap_store_t *ctx, imap_cmd_t *cmd ATTR_UNUSED, int response ) +{ if (response == RESP_NO) imap_open_store_bail( ctx, FAIL_FINAL ); else if (response == RESP_OK)