<<< Date Index >>>     <<< Thread Index >>>

Re: [PATCH] Fix CAPABILITY handling for IMAP



On Thursday, 03 August 2006 at 11:16, Rocco Rutte wrote:
> Hi,
> 
> * Rocco Rutte [06-07-13 12:59:12 +0000] wrote:
> >Now I had time to track it down: the server sends different responses: 
> >only IMAP4rev1 and AUTH=... before authentication but much more items 
> >after authentication.
> 
> Here is a debug snippet:
> 
>   imap_cmd_step: grew buffer to 512 bytes
>   < * OK [CAPABILITY IMAP4REV1 LITERAL+ SASL-IR LOGIN-REFERRALS AUTH=PLAIN 
>   AUTH=LOGIN] mail IMAP4rev1 2004.357 at Thu, 3 Aug 2006 13:05:17 +0200 
>   (MEST)
>   Handling CAPABILITY
>   imap_authenticate: Using any available method.
>   local ip: 192.168.0.113;53468, remote ip:XXX;993
>   External SSF: 256
>   External authentication name: pdmef
>   mutt_sasl_cb_authname: getting authname for XXX:993
>   mutt_sasl_cb_authname: getting user for XXX:993
>   mutt_sasl_cb_pass: getting password for pdmef@XXX:993
>   > a0000 AUTHENTICATE PLAIN XXX
>   < a0000 OK [CAPABILITY IMAP4REV1 LITERAL+ IDLE NAMESPACE 
>   MAILBOX-REFERRALS BINARY UNSELECT SCAN SORT THREAD=REFERENCES 
>   THREAD=ORDEREDSUBJECT MULTIAPPEND] User pdmef authenticated
>   SASL protection strength: 0
>   SASL protection buffer size: 65536
>   Communication encrypted at 256 bits
>   > a0001 LIST "" ""
>   < * LIST (\NoSelect) "/" ""
>   Root delimiter: /
>   < a0001 OK LIST completed
> 
> I'm using SASL and as there's no second 'Handling CAPABILITY' in there, 
> I guess the full CAPABILITY line is eaten by SASL and not seen by mutt.

Mutt just wasn't checking for capabilities on tagged responses. Does
the following patch work for you?

> Any objections against the previous patch?

If the one I posted works, I'd be happier with it. Asking for
CAPABILITY just after receiving a gratuitous CAPABILITY is kind of
silly.

> >The second patch adds more verbose debugging to the socket layer: print 
> >which connection gets what file descriptor and use that when logging 
> >socket traffic to distinct between different hosts with identical 
> >protocols (it's really hard to debug otherwise).
> 
> Any objections against this one? For me it's highly usefull. Lately 
> someone posted info for IMAP browser bug with traffic to different 
> servers within a session and this patch improves readability.

The second patch is certainly worthwhile.
Index: imap/command.c
===================================================================
RCS file: /home/roessler/cvs/mutt/imap/command.c,v
retrieving revision 3.40
diff -u -p -r3.40 command.c
--- imap/command.c      6 Jul 2006 18:18:31 -0000       3.40
+++ imap/command.c      5 Aug 2006 00:38:13 -0000
@@ -119,6 +119,7 @@ int imap_cmd_step (IMAP_DATA* idata)
   size_t len = 0;
   int c;
   int rc;
+  char* s;
 
   if (idata->status == IMAP_FATAL)
   {
@@ -177,6 +178,9 @@ int imap_cmd_step (IMAP_DATA* idata)
 
   /* tagged completion code. TODO: I believe commands will always be completed
    * in order, but will have to double-check when I have net again */
+  s = imap_next_word (idata->buf);
+  if (!ascii_strncmp (s, "OK [CAPABILITY", 14))
+    cmd_parse_capability (idata, imap_next_word (s));
   rc = IMAP_CMD_CONTINUE;
   if (!ascii_strncmp (idata->buf, idata->cmds[idata->lastcmd].seq, SEQLEN))
   {

Attachment: pgpCB7PV2WYDO.pgp
Description: PGP signature