fetchmail-friends
[Top] [All Lists]

Re: [fetchmail]Bug in doing CAPA /w fetchmail-5.9.11?

2002-05-25 01:07:21
Quoting from Sunil Shetye's mail on Mon, May 06, 2002 at 10:57:35AM +0530:
This looks like a good solution. In fact, there is no need to quit if
CAPA succeeds. Only if the response to CAPA is an -ERR should the
POP server be reconnected.

Here is a patch which sends a CAPA anyway. Also, if CAPA fails, it   
forces the authentication method to "password" for the next poll.

Warning: This patch may break for pop3 servers which do not support
apop when polling in non-daemon mode. I intend to write one more patch
for that if this patch is otherwise acceptable.

============================================================
--- fetchmail-5.9.11.orig/pop3.c        Sat Mar  9 09:40:24 2002
+++ fetchmail-5.9.11/pop3.c     Fri May 24 17:57:22 2002
@@ -190,18 +190,16 @@
         * latches the server's authentication type, so that in daemon mode
         * the CAPA check only needs to be done once at start of run.
         *
-        * APOP was introduced in RFC 1450, and CAPA not until
-        * RFC2449. So the < check is an easy way to prevent CAPA from
-        * being sent to the more primitive POP3 servers dating from
-        * RFC 1081 and RFC 1225, which seem more likely to choke on
-        * it.  This certainly catches IMAP-2000's POP3 gateway.
-        * 
+        * If CAPA fails, then force the authentication method to PASSORD
+        * for the next run in daemon mode.
+        *
         * These authentication methods are blessed by RFC1734,
         * describing the POP3 AUTHentication command.
         */
-       if (ctl->server.authenticate == A_ANY 
-           && strchr(greeting, '<') 
-           && gen_transact(sock, "CAPA") == 0)
+       if (ctl->server.authenticate == A_ANY)
+       {
+       ok = gen_transact(sock, "CAPA");
+       if (ok == 0)
        {
            char buffer[64];
 
@@ -229,6 +227,12 @@
                if (strstr(buffer, "CRAM-MD5"))
                    has_cram = TRUE;
            }
+       }
+       /* we are in STAGE_GETAUTH! */
+       else if (ok == PS_AUTHFAIL)
+       {
+           ctl->server.authenticate = A_PASSWORD;
+       }
        }
 
 #ifdef SSL_ENABLE
============================================================

One surprising thing is that the existing comment (part of which is
visible in the patch above) claims that CAPA needs to be sent only
once as the authentication method is latched on to for the next poll.
However, this does not seem to be happening anywhere in the code! And
CAPA seems to be sent during every poll anyway!

Sunil Shetye.