fetchmail-friends
[Top] [All Lists]

Re: [fetchmail]fetchmail 5.9.13: SOCKET error when fetching mail

2002-06-26 22:33:31
Quoting from Sunil Shetye's mail on Wed, Jun 26, 2002 at 05:48:17PM +0530:
Ok. Here is a better patch than the previous one. It treats socket
error as CAPA not supported only if authentication have never occurred
before. (I was going to add a new flag, however this should be
sufficient for the purpose.)

It is better to add a separate flag because a previous successful
authentication could be because of a different protocol when protocol
is set to auto.

Here is the fixed patch (please ignore the previous patches):

============================================================
diff -Naur fetchmail-5.9.13.orig/driver.c fetchmail-5.9.13/driver.c
--- fetchmail-5.9.13.orig/driver.c      Sun Jun 23 02:37:12 2002
+++ fetchmail-5.9.13/driver.c   Thu Jun 27 10:39:42 2002
@@ -1423,7 +1423,7 @@
 
     cleanUp:
        /* we only get here on error */
-       if (err != 0 && err != PS_SOCKET)
+       if (err != 0 && err != PS_SOCKET && err != PS_REPOLL)
        {
            stage = STAGE_LOGOUT;
            (ctl->server.base_protocol->logout_cmd)(mailserver_socket, ctl);
diff -Naur fetchmail-5.9.13.orig/fetchmail.h fetchmail-5.9.13/fetchmail.h
--- fetchmail-5.9.13.orig/fetchmail.h   Sun Jun 23 01:33:13 2002
+++ fetchmail-5.9.13/fetchmail.h        Thu Jun 27 10:41:03 2002
@@ -303,6 +303,7 @@
     const char *destaddr;      /* destination host for this query */
     int errcount;              /* count transient errors in last pass */
     int authfailcount;         /* count of authorization failures */
+    int wehavesentcapa;                /* We've sent CAPA successfully atleast 
once */
     int wehaveauthed;          /* We've managed to logon at least once! */
     int wehavesentauthnote;    /* We've sent an authorization failure note */
     int wedged;                        /* wedged by auth failures or timeouts? 
*/
diff -Naur fetchmail-5.9.13.orig/pop3.c fetchmail-5.9.13/pop3.c
--- fetchmail-5.9.13.orig/pop3.c        Sun Jun 23 01:33:15 2002
+++ fetchmail-5.9.13/pop3.c     Thu Jun 27 10:46:00 2002
@@ -227,15 +227,24 @@
                    if (strstr(buffer, "CRAM-MD5"))
                        has_cram = TRUE;
                }
+               ctl->wehavesentcapa = 1;
            }
            /* we are in STAGE_GETAUTH! */
-           else if (ok == PS_AUTHFAIL)
+           else if (ok == PS_AUTHFAIL ||
+               /* Some servers directly close the socket. However, if we
+                * have already sent CAPA successfully before, this must be
+                * a genuine socket error, so do not change the auth
+                * method. */
+               (ok == PS_SOCKET && !ctl->wehavesentcapa))
            {
                ctl->server.authenticate = A_PASSWORD;
                /* repoll immediately */
                ok = PS_REPOLL;
                break;
            }
+           /* a genuine socket error */
+           else if (ok == PS_SOCKET)
+               break;
        }
 
 #ifdef SSL_ENABLE
============================================================

Sunil Shetye.