diff -Naur fetchmail-6.1.2.orig/fetchmail.c fetchmail-6.1.2/fetchmail.c --- fetchmail-6.1.2.orig/fetchmail.c Thu Oct 31 17:45:41 2002 +++ fetchmail-6.1.2/fetchmail.c Fri Nov 1 15:28:49 2002 @@ -1356,7 +1356,9 @@ break; case P_IMAP: #ifdef IMAP_ENABLE - st = doIMAP(ctl); + do { + st = doIMAP(ctl); + } while (st == PS_REPOLL); #else report(stderr, GT_("IMAP support is not configured.\n")); st = PS_PROTOCOL; diff -Naur fetchmail-6.1.2.orig/imap.c fetchmail-6.1.2/imap.c --- fetchmail-6.1.2.orig/imap.c Fri Oct 18 18:39:57 2002 +++ fetchmail-6.1.2/imap.c Fri Nov 1 15:28:49 2002 @@ -251,6 +251,9 @@ /* apply for connection authorization */ { int ok = 0; +#ifdef SSL_ENABLE + flag did_stls = FALSE; +#endif /* SSL_ENABLE */ /* probe to see if we're running IMAP4 and can use RFC822.PEEK */ capabilities[0] = '\0'; @@ -376,6 +379,7 @@ GT_("SSL connection failed.\n")); return(PS_AUTHFAIL); } + did_stls = TRUE; } #endif /* SSL_ENABLE */ @@ -470,6 +474,16 @@ strcpy(shroud, password); ok = gen_transact(sock, "LOGIN \"%s\" \"%s\"", remotename, password); shroud[0] = '\0'; +#ifdef SSL_ENABLE + /* this is for servers which claim to support TLS, but actually + * don't! */ + if (did_stls && ok == PS_SOCKET && !ctl->wehaveauthed) + { + ctl->server.authenticate = A_PASSWORD; + /* repoll immediately */ + ok = PS_REPOLL; + } +#endif if (ok) { /* SASL cancellation of authentication */ diff -Naur fetchmail-6.1.2.orig/pop3.c fetchmail-6.1.2/pop3.c --- fetchmail-6.1.2.orig/pop3.c Thu Oct 31 18:11:37 2002 +++ fetchmail-6.1.2/pop3.c Fri Nov 1 15:38:46 2002 @@ -145,6 +145,7 @@ #endif /* OPIE_ENABLE */ #ifdef SSL_ENABLE flag has_ssl = FALSE; + flag did_stls = FALSE; #endif /* SSL_ENABLE */ #ifdef SDPS_ENABLE @@ -261,6 +262,7 @@ GT_("SSL connection failed.\n")); return(PS_AUTHFAIL); } + did_stls = TRUE; } #endif /* SSL_ENABLE */ @@ -350,6 +352,16 @@ strcpy(shroud, ctl->password); ok = gen_transact(sock, "PASS %s", ctl->password); shroud[0] = '\0'; +#ifdef SSL_ENABLE + /* this is for servers which claim to support TLS, but actually + * don't! */ + if (did_stls && ok == PS_SOCKET && !ctl->wehaveauthed) + { + ctl->server.authenticate = A_PASSWORD; + /* repoll immediately */ + ok = PS_REPOLL; + } +#endif break; case P_APOP: