From 649572ba29dfab09cb77a5c2f6f5d12e9822792c Mon Sep 17 00:00:00 2001 From: Eduardo Chappa Date: Sun, 1 Nov 2020 12:27:04 -0700 Subject: * Improvements to the cancel authentication logic to not to make it have a delay when cancelling authentication. --- imap/src/c-client/auth_bea.c | 2 +- imap/src/c-client/auth_oa2.c | 2 +- imap/src/c-client/imap4r1.c | 25 +++++++++++-------------- 3 files changed, 13 insertions(+), 16 deletions(-) (limited to 'imap') diff --git a/imap/src/c-client/auth_bea.c b/imap/src/c-client/auth_bea.c index 64c3aa6c..d9f5e067 100644 --- a/imap/src/c-client/auth_bea.c +++ b/imap/src/c-client/auth_bea.c @@ -150,7 +150,7 @@ long auth_oauthbearer_client (authchallenge_t challenger,authrespond_t responder if(oauth2.param[OA2_Id].value) fs_give((void **) &oauth2.param[OA2_Id].value); if(oauth2.param[OA2_Secret].value) fs_give((void **) &oauth2.param[OA2_Secret].value); if(oauth2.param[OA2_Tenant].value) fs_give((void **) &oauth2.param[OA2_Tenant].value); - if (!ret || !oauth2.name) + if (!ret) *trial = 65535; /* don't retry if bad protocol */ return ret; } diff --git a/imap/src/c-client/auth_oa2.c b/imap/src/c-client/auth_oa2.c index dac87960..b446b40f 100644 --- a/imap/src/c-client/auth_oa2.c +++ b/imap/src/c-client/auth_oa2.c @@ -169,7 +169,7 @@ long auth_oauth2_client (authchallenge_t challenger,authrespond_t responder, cha if(oauth2.param[OA2_Id].value) fs_give((void **) &oauth2.param[OA2_Id].value); if(oauth2.param[OA2_Secret].value) fs_give((void **) &oauth2.param[OA2_Secret].value); if(oauth2.param[OA2_Tenant].value) fs_give((void **) &oauth2.param[OA2_Tenant].value); - if (!ret || !oauth2.name) + if (!ret) *trial = 65535; /* don't retry if bad protocol */ return ret; } diff --git a/imap/src/c-client/imap4r1.c b/imap/src/c-client/imap4r1.c index 7343122c..344eadaf 100644 --- a/imap/src/c-client/imap4r1.c +++ b/imap/src/c-client/imap4r1.c @@ -1215,23 +1215,20 @@ long imap_auth (MAILSTREAM *stream,NETMBX *mb,char *tmp,char *usr) ok = (*at->client) (imap_challenge,imap_response,base,"imap",mb,stream, net_port(LOCAL->netstream),&trial,usr); LOCAL->sensitive = NIL; /* unhide */ - - if(base && ok && !trial){ /* return now or see below for the same code */ - mm_log ("IMAP Authentication cancelled",ERROR); - return NIL; - } + if(!base){ /* make sure have a response */ - if (!(reply = &LOCAL->reply)->tag) - reply = imap_fake (stream,tag, + if (!(reply = &LOCAL->reply)->tag) + reply = imap_fake (stream,tag, "[CLOSED] IMAP connection broken (authenticate)"); - else if (compare_cstring (reply->tag,tag)) - while (compare_cstring ((reply = imap_reply (stream,tag))->tag,tag)) - imap_soutr (stream,"*"); + else if (compare_cstring (reply->tag,tag)) + while (compare_cstring ((reply = imap_reply (stream,tag))->tag,tag)) + imap_soutr (stream,"*"); /* good if SASL ok and success response */ - if (ok && imap_OK (stream,reply)){ - if(stream->auth.name) fs_give((void **) &stream->auth.name); - stream->auth.name = cpystr(at->name); /* save method name */ - return T; + if (ok && imap_OK (stream,reply)){ + if(stream->auth.name) fs_give((void **) &stream->auth.name); + stream->auth.name = cpystr(at->name); /* save method name */ + return T; + } } if (!trial) { /* if main program requested cancellation */ mm_log ("IMAP Authentication cancelled",ERROR); -- cgit v1.2.3-54-g00ecf