It seems etpan and outlook.com has diverged in their interpretation on the IMAP protocol: ** Message: 21:41:41.531: IMAP connection is un-authenticated passwordstore.c:204:Getting password 'oauth2_access_expiry' from block (1/23) password.c:597:Trying to decrypt password... password.c:100:TIMING _make_key_deriv PBKDF2: 0s088ms password.c:491:Encrypted password string length: 144 ** Message: 21:41:41.619: OAuth2 access token still fresh passwordstore.c:204:Getting password 'recv' from block (1/23) password.c:597:Trying to decrypt password... password.c:100:TIMING _make_key_deriv PBKDF2: 0s072ms password.c:491:Encrypted password string length: 1168 imap-thread.c:459:found imap 0x7fded80160a0 imap-thread.c:459:found imap 0x7fded80160a0 [2024-01-08 21:41:41] IMAP> 1 CAPABILITY [2024-01-08 21:41:41] IMAP< * CAPABILITY IMAP4 IMAP4rev1 AUTH=PLAIN AUTH=XOAUTH2 SASL-IR UIDPLUS ID UNSELECT CHILDREN IDLE NAMESPACE LITERAL+ [2024-01-08 21:41:41] IMAP< 1 OK CAPABILITY completed. imap-thread.c:475:generic_cb imap-thread.c:459:found imap 0x7fded80160a0 imap-thread.c:759:capa 0 imap.c:872:got capa IMAP4 imap.c:872:got capa IMAP4rev1 imap.c:872:got capa PLAIN imap.c:872:got capa XOAUTH2 imap.c:872:got capa SASL-IR imap.c:872:got capa UIDPLUS imap.c:872:got capa ID imap.c:872:got capa UNSELECT imap.c:872:got capa CHILDREN imap.c:872:got capa IDLE imap.c:872:got capa NAMESPACE imap.c:872:got capa LITERAL+ [2024-01-08 21:41:41] IMAP> Logging XXXXX@outlook.com to outlook.office365.com using XOAUTH2 imap-thread.c:1030:imap login - begin imap-thread.c:459:found imap 0x2362ce0 imap-thread.c:459:found imap 0x2362ce0 [2024-01-08 21:39:56] IMAP< AUTHENTICATE completed. imap-thread.c:1020:imap login run - end 0 imap-thread.c:475:generic_cb imap-thread.c:459:found imap 0x2362ce0 imap-thread.c:1046:imap login - end [2024-01-08 21:39:56] IMAP< Login to outlook.office365.com successful imap.c:535:locking session 0x23b10b0 (0) folder.c:4658:Folder datanom.net wants sync folder.c:4658:Folder datanom.net wants sync imap.c:4774:get_num_list: updating num list imap-thread.c:867:imap list - begin imap-thread.c:459:found imap 0x2362ce0 imap-thread.c:459:found imap 0x2362ce0 [2024-01-08 21:39:56] IMAP> 3 LIST "" "" [2024-01-08 21:39:56] IMAP< 3 BAD User is authenticated but not connected. imap-thread.c:857:imap list run - end imap-thread.c:475:generic_cb imap-thread.c:459:found imap 0x2362ce0 imap-thread.c:878:imap list - end (nil) ** (claws-mail:264775): WARNING **: 21:39:56.401: [2024-01-08 21:39:56] IMAP error on outlook.office365.com: protocol error (very probably non-RFC compliance from the server) ** (claws-mail:264775): WARNING **: 21:39:56.401: [2024-01-08 21:39:56] IMAP connection broken ** (claws-mail:264775): WARNING **: 21:39:56.401: [2024-01-08 21:39:56] LIST failed imap-thread.c:867:imap list - begin imap-thread.c:459:found imap 0x2362ce0 imap-thread.c:459:found imap 0x2362ce0 [2024-01-08 21:39:56] IMAP> 4 LIST "" "INBOX" [2024-01-08 21:39:56] IMAP< 4 BAD User is authenticated but not connected. [2024-01-08 21:39:56] IMAP< * BYE Connection closed. 14 imap-thread.c:857:imap list run - end imap-thread.c:475:generic_cb imap-thread.c:459:found imap 0x2362ce0 imap-thread.c:878:imap list - end (nil) ** (claws-mail:264775): WARNING **: 21:39:56.431: [2024-01-08 21:39:56] IMAP error on outlook.office365.com: protocol error (very probably non-RFC compliance from the server) ** (claws-mail:264775): WARNING **: 21:39:56.431: [2024-01-08 21:39:56] IMAP connection broken ** (claws-mail:264775): WARNING **: 21:39:56.431: [2024-01-08 21:39:56] LIST failed
Did you report this upstream (to libetpan)?
No, I was waiting for a second guess - I could be wrong ;-)
Reported upstream to libetpan: https://github.com/dinhvh/libetpan/issues/443
"BAD User is authenticated but not connected." Is this with 91ebb5e00 or 4306848d8? It looks like I broke oauth2_contact_server while fiddling with coding style in bug#4730. Sorry for that.
There is still something wrong with etpan and outlook.com but I also think there are some logic wich your patch brake. So for now reverting.
Created attachment 2392 [details] master-oauth2-fix-logic-error-in-oauth2_contact_server.patch oauth2: fix logic error in oauth2_contact_server The function sock_read will return zero to indicate EOF. This will terminate the do/while loop as expected. But the logic introduced in commit 91ebb5e00 ("Fix bug #4730. Patch by Olaf Hering") handles this as "no data received" and returns NULL to the caller. Adjust the logic to handle EOF. Only a negative return value is an error, unless it is EAGAIN (which is the common case). In case the final result is an empty string, the callers will handle this properly. Append to the string only if there is something to append, to avoid a warning from g_string_insert_len.
Since I have reverted the previous patch could you provide a complete patch (the privious + this patch) as one patch? ;-)
FWIW, seems it's happening to other people too: https://learn.microsoft.com/en-us/answers/questions/1183166/imap-returning-bad-user-is-authenticated-but-not-c