]> Pileus Git - ~andy/fetchmail/blobdiff - pop3.c
Remove multidrop, a dangerous workaround for broken upstream multidrop setups.
[~andy/fetchmail] / pop3.c
diff --git a/pop3.c b/pop3.c
index dd8e46041e74728ee5286122351d25d482d5fd2f..a994f992d1641151f874a9c0bc24f485e2bc15f0 100644 (file)
--- a/pop3.c
+++ b/pop3.c
@@ -259,7 +259,7 @@ static void set_peek_capable(struct query *ctl)
      * we have a means of reliably tracking which mail we need to
      * refetch should the connection abort in the middle.
      * fetchall forces RETR, as does keep without UIDL */
-    peek_capable = !ctl->fetchall && (!ctl->keep || ctl->server.uidl);
+    peek_capable = !ctl->fetchall;
 }
 
 static int pop3_getauth(int sock, struct query *ctl, char *greeting)
@@ -439,9 +439,9 @@ static int pop3_getauth(int sock, struct query *ctl, char *greeting)
                * whether TLS is mandatory or opportunistic unless SSLOpen() fails
                * (see below). */
               if (gen_transact(sock, "STLS") == PS_SUCCESS
-                      && SSLOpen(sock, ctl->sslcert, ctl->sslkey, "tls1", ctl->sslcertck,
+                      && (set_timeout(mytimeout), SSLOpen(sock, ctl->sslcert, ctl->sslkey, "tls1", ctl->sslcertck,
                           ctl->sslcertfile, ctl->sslcertpath, ctl->sslfingerprint, commonname,
-                          ctl->server.pollname, &ctl->remotename) != -1)
+                          ctl->server.pollname, &ctl->remotename)) != -1)
               {
                   /*
                    * RFC 2595 says this:
@@ -456,6 +456,7 @@ static int pop3_getauth(int sock, struct query *ctl, char *greeting)
                    * Now that we're confident in our TLS connection we can
                    * guarantee a secure capability re-probe.
                    */
+                  set_timeout(0);
                   done_capa = FALSE;
                   ok = capa_probe(sock);
                   if (ok != PS_SUCCESS) {
@@ -468,6 +469,7 @@ static int pop3_getauth(int sock, struct query *ctl, char *greeting)
               } else if (must_tls(ctl)) {
                   /* Config required TLS but we couldn't guarantee it, so we must
                    * stop. */
+                  set_timeout(0);
                   report(stderr, GT_("%s: upgrade to TLS failed.\n"), commonname);
                   return PS_SOCKET;
               } else {
@@ -476,6 +478,7 @@ static int pop3_getauth(int sock, struct query *ctl, char *greeting)
                    * allowed til post-authentication), so leave it in an unknown
                    * state, mark it as such, and check more carefully if things
                    * go wrong when we try to authenticate. */
+                  set_timeout(0);
                   connection_may_have_tls_errors = TRUE;
                   if (outlevel >= O_VERBOSE)
                   {
@@ -830,16 +833,10 @@ static int pop3_getrange(int sock,
     } else
        return(ok);
 
-    /*
-     * Newer, RFC-1725/1939-conformant POP servers may not have the LAST
-     * command.  We work as hard as possible to hide this, but it makes
-     * counting new messages intrinsically quadratic in the worst case.
-     */
+    /* unless fetching all mail, get UID list (UIDL) */
     last = 0;
     *newp = -1;
-    /* if there are messages, and UIDL is desired, use UIDL
-     * also use UIDL if fetchall is unset */
-    if (*countp > 0 && (!ctl->fetchall || ctl->server.uidl))
+    if (*countp > 0)
     {
        int fastuidl;
        char id [IDLEN+1];
@@ -862,23 +859,6 @@ static int pop3_getrange(int sock,
        else
            dofastuidl = 0;
 
-       if (!ctl->server.uidl) {
-           gen_send(sock, "LAST");
-           ok = pop3_ok(sock, buf);
-       } else
-           ok = 1;
-
-       if (ok == 0)
-       {
-           /* scan LAST reply */
-           if (sscanf(buf, "%d", &last) == 0)
-           {
-               report(stderr, GT_("protocol error\n"));
-               return(PS_ERROR);
-           }
-           *newp = (*countp - last);
-       }
-       else
        {
            /* do UIDL */
            if (dofastuidl)
@@ -886,8 +866,10 @@ static int pop3_getrange(int sock,
            /* grab the mailbox's UID list */
            if (gen_transact(sock, "UIDL") != 0)
            {
+               if (!ctl->fetchall) {
                    report(stderr, GT_("protocol error while fetching UIDLs\n"));
                    return(PS_ERROR);
+               }
            }
            else
            {
@@ -940,8 +922,11 @@ static int pop3_getrange(int sock,
                            old_rec = uid_db_insert(&ctl->oldsaved, id, UID_UNSEEN);
 
                        }
-                       /* save the number */
-                       if (new_rec->status == UID_UNSEEN || !ctl->keep) {
+                       /*
+                        * save the number if it will be needed later on
+                        * (messsage will either be fetched or deleted)
+                        */
+                       if (new_rec->status == UID_UNSEEN || ctl->flush) {
                            set_uid_db_num(&ctl->oldsaved, old_rec, unum);
                            set_uid_db_num(&ctl->newsaved, new_rec, unum);
                        }
@@ -1025,7 +1010,6 @@ static int pop3_is_old(int sock, struct query *ctl, int num)
            return(TRUE);
 
        /* in fast uidl, we manipulate the old list only! */
-
        if ((rec = find_uid_by_num(&ctl->oldsaved, num)))
        {
            /* we already have the id! */