From d6b9a139e46027c49b5f59792a90e92aff00af29 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 9 Dec 2021 11:42:40 +0100 Subject: [PATCH] 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. --- src/drv_imap.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/drv_imap.c b/src/drv_imap.c index 6286045..064761c 100644 --- 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; @@ -2512,6 +2515,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 );