]> Pileus Git - ~andy/fetchmail/commitdiff
Debian 5.9.10 fixes.
authorEric S. Raymond <esr@thyrsus.com>
Mon, 1 Apr 2002 07:50:04 +0000 (07:50 -0000)
committerEric S. Raymond <esr@thyrsus.com>
Mon, 1 Apr 2002 07:50:04 +0000 (07:50 -0000)
svn path=/trunk/; revision=3603

NEWS
conf.c
daemon.c
driver.c
fetchmail-FAQ.html
fetchmailconf
imap.c
rcfile_y.y
sink.c
socket.c

diff --git a/NEWS b/NEWS
index cfc271c0e472e387485ec3642c24c2d9922b22f6..bb67df7ec616cd73eaf80409c735bcaaa8032f6f 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,22 @@
 
 * Updated Turkish translation.
 * Added warning about auth failures on the GMX server.
+* HMH's Debian 5.9.10 patches:
+1. Fix minor typo in FAQ
+2. Fix partial implementation of ESMTP auth, and some minor
+   fetchmailconf stuff
+3. Add proper error reporting to bad logfile creation.
+   patch by Sunil Shetye <shetye@bombay.retortsoft.com>
+4. Fix incredible aggravating bug that caused dataloss
+   risks if 4xx errors were returned by the MTA
+5. Corrected version of the fix-timeouts-for-ssl and descriptor
+   leaking patches from Sylvain Benoist <sylvainb@whitepj.com>
+   Also fix outdated comments in driver.c
+6. Sunil Shetye's patch to stop fetchmail from trying to fetch
+   twice with IMAP
+7. Stop stupid complaint about turning off SSL being illegal
+   without SSL support.
+8. Byrial Jensen <byrial@image.dk> i18n fixes
 
 fetchmail-5.9.10 (Sun Mar 10 15:09:57 EST 2002), 21529 lines:
 
diff --git a/conf.c b/conf.c
index b969e15cec8aef024c4582f9a5915f8a67bb3760..089bb93a060c5694fd487ed5339889dcf7a7095f 100644 (file)
--- a/conf.c
+++ b/conf.c
@@ -311,6 +311,10 @@ void dump_config(struct runctl *runp, struct query *querylist)
            stringdump("plugin", ctl->server.plugin);
            stringdump("plugout", ctl->server.plugout);
            stringdump("principal", ctl->server.principal);
+           if (ctl->server.esmtp_name)
+               stringdump("esmtpname",ctl->server.esmtp_name);
+           if (ctl->server.esmtp_password)
+               stringdump("esmtppassword",ctl->server.esmtp_password);
            booldump("tracepolls", ctl->tracepolls);
 
            indent(0);
index 331ca767049cc7347425d0dad96140ff629da659..d2a5b2d9e9f33403574548cb811d0394f165368a 100644 (file)
--- a/daemon.c
+++ b/daemon.c
@@ -234,12 +234,19 @@ nottyDetach:
   }
 
   if (logfile)
-    fd = open(logfile, O_CREAT|O_WRONLY|O_APPEND, 0666);       /* stdout */
+  {
+    if ((fd = open(logfile, O_CREAT|O_WRONLY|O_APPEND, 0666)) < 0) {   /* stdout */
+      report(stderr, "open %s (%s)\n", logfile, strerror(errno));
+      return(PS_IOERR);
+    }
+  }
   else
+  {
     if (dup(fd) < 0) {                         /* stdout */
       report(stderr, "dup (%s)\n", strerror(errno));
       return(PS_IOERR);
     }
+  }
   if (dup(fd) < 0) {                           /* stderr */
     report(stderr, "dup (%s)\n", strerror(errno));
     return(PS_IOERR);
index d1a7bb4eed1dde085addd543c21601549772344c..b11d75365df226d9e547de211fed978d1c35cb01 100644 (file)
--- a/driver.c
+++ b/driver.c
@@ -64,6 +64,7 @@ int stage;            /* where are we? */
 int phase;             /* where are we, for error-logging purposes? */
 int batchcount;                /* count of messages sent in current batch */
 flag peek_capable;     /* can we peek for better error recovery? */
+int mailserver_socket_temp;    /* socket to free if connect timeout */ 
 
 static int timeoutcount;               /* count consecutive timeouts */
 
@@ -557,11 +558,6 @@ static int fetch_messages(int mailserver_socket, struct query *ctl,
            {
                if (suppress_readbody)
                {
-                   /* When readheaders returns PS_TRUNCATED,
-                    * the body (which has no content)
-                    * has already been read by readheaders,
-                    * so we say readbody returned PS_SUCCESS
-                    */
                    err = PS_SUCCESS;
                }
                else
@@ -746,7 +742,12 @@ const int maxfetch;                /* maximum number of messages to fetch */
        sigfillset(&allsigs);
        sigprocmask(SIG_UNBLOCK, &allsigs, NULL);
 #endif /* HAVE_SIGPROCMASK */
-
+       
+       /* If there was a connect timeout, the socket should be closed.
+        * mailserver_socket_temp contains the socket to close.
+        */
+       mailserver_socket = mailserver_socket_temp;
+       
        if (js == THROW_SIGPIPE)
        {
            signal(SIGPIPE, SIG_IGN);
@@ -1008,10 +1009,14 @@ const int maxfetch;             /* maximum number of messages to fetch */
            phase = oldphase;
            goto closeUp;
        }
-       set_timeout(0);
-       phase = oldphase;
 
 #ifdef SSL_ENABLE
+       /* Save the socket opened. Usefull if Fetchmail hangs on SSLOpen 
+        * because the socket can be closed
+        */
+       mailserver_socket_temp = mailserver_socket;
+       set_timeout(mytimeout);
+
        /* perform initial SSL handshake on open connection */
        /* Note:  We pass the realhost name over for certificate
                verification.  We may want to make this configurable */
@@ -1021,8 +1026,18 @@ const int maxfetch;              /* maximum number of messages to fetch */
            report(stderr, GT_("SSL connection failed.\n"));
            goto closeUp;
        }
+       
+       /* Fetchmail didn't hang on SSLOpen, 
+        * then no need to set mailserver_socket_temp 
+        */
+       mailserver_socket_temp = -1;
 #endif
-
+       
+       /* A timeout is still defined before SSLOpen, 
+        * then Fetchmail hanging on SSLOpen is handled.
+        */
+       set_timeout(0);
+       phase = oldphase;
 #ifdef KERBEROS_V4
        if (ctl->server.authenticate == A_KERBEROS_V4)
        {
@@ -1352,6 +1367,8 @@ is restored."));
                            continue;
                        else if (ctl->server.base_protocol->is_old && (ctl->server.base_protocol->is_old)(mailserver_socket,ctl,num))
                            msgcodes[num-1] = MSGLEN_OLD;
+/*                     else if (msgsizes[num-1] == 512)
+                               msgcodes[num-1] = MSGLEN_OLD;  (hmh) sample code to skip message */
                    }
 
                    /* read, forward, and delete messages */
index f3be2774e6b3e8ff3f2438c8c95f6f14ea521a3d..0017511f870c2f6e49b75f6d106a2ce8578dc3ed 100644 (file)
@@ -10,7 +10,7 @@
 <table width="100%" cellpadding=0><tr>
 <td width="30%">Back to <a href="index.html">Fetchmail Home Page</a>
 <td width="30%" align=center>To <a href="/~esr/sitemap.html">Site Map</a>
-<td width="30%" align=right>$Date: 2002/03/26 14:41:17 $
+<td width="30%" align=right>$Date: 2002/04/01 07:49:49 $
 </table>
 <HR>
 <H1>Frequently Asked Questions About Fetchmail</H1>
@@ -225,7 +225,7 @@ bugs, please include the following:
 <ol>
 <li>Your operating system.
 <li>Your compiler version, if you built from source; otherwise, the
-    name and origin ogf the RPM or other binary package you installed.
+    name and origin of the RPM or other binary package you installed.
 <li>A copy of your POP or IMAP server's greeting line.
 <li>The name and version of the SMTP listener or MDA you are forwarding to.
 <li>Any command-line options you used.
@@ -3015,7 +3015,7 @@ date from the last Received header.<p>
 <table width="100%" cellpadding=0><tr>
 <td width="30%">Back to <a href="index.html">Fetchmail Home Page</a>
 <td width="30%" align=center>To <a href="/~esr/sitemap.html">Site Map</a>
-<td width="30%" align=right>$Date: 2002/03/26 14:41:17 $
+<td width="30%" align=right>$Date: 2002/04/01 07:49:49 $
 </table>
 
 <ADDRESS>Eric S. Raymond <A HREF="mailto:esr@thyrsus.com">&lt;esr@thyrsus.com&gt;</A></ADDRESS>
index fda0d9b798d9cea49e70c4976294de4846976c19..b7a69fdbecaf2c99186ec3665e4ff9db3176c5e6 100755 (executable)
@@ -118,6 +118,8 @@ class Server:
            ('monitor',   'String'),
            ('plugin',    'String'),
            ('plugout',   'String'),
+            ('esmtpname', 'String'),
+            ('esmtppassword', 'String'),
            ('netsec',    'String'),
            ('principal', 'String'),
            ('tracepolls','Boolean'))
@@ -1189,7 +1191,7 @@ class ServerEdit(Frame, MyWidget):
        for (protocol, port) in (("IMAP",143), ("POP3",110), ("POP2",109)):
            sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            try:
-               sock.connect(realhost, port)
+                sock.connect((realhost, port))
                greetline = sock.recv(1024)
                sock.close()
            except:
@@ -1386,7 +1388,7 @@ You may have to use the fetchall option.
            if string.find(greetline, " IMS POP3") > 0:
                warnings = warnings + """
 Some servers issuing the greeting line 'IMS POP3' have been known to
-do byte-stuffing correctly.  This means that if a message you receive
+do byte-stuffing incorrectly.  This means that if a message you receive
 has a . (period) at start of line, fetchmail will become confused and
 probably wedge itself.  (This bug was recorded on IMS POP3 0.86.)
 
diff --git a/imap.c b/imap.c
index fd850d7840865453e3beb24e9963b37490f7c486..96f485cf89d2c9dc24d27ec7457d58c18f582f12 100644 (file)
--- a/imap.c
+++ b/imap.c
@@ -517,6 +517,9 @@ static int imap_getrange(int sock,
                return(ok);
            }
        }
+       /* if recentcount is 0, return no mail */
+       if (recentcount == 0)
+               count = 0;
        if (outlevel >= O_DEBUG)
            report(stdout, GT_("%d messages waiting after re-poll\n"), count);
     }
@@ -617,6 +620,7 @@ static int imap_getrange(int sock,
        unseen = -1;
 
     *newp = unseen;
+    count = 0;
     expunged = 0;
     deletions = 0;
 
index a85a7fa08d79ae72031f12ddb88d2223facfacf2..5b0c50889bf9e7073a5b172adf057a4bdd10fd11 100644 (file)
@@ -366,13 +366,7 @@ user_option        : TO localnames HERE
                | NO MIMEDECODE         {current.mimedecode  = FLAG_FALSE;}
                | NO IDLE               {current.idle        = FLAG_FALSE;}
 
-               | NO SSL                {
-#ifdef SSL_ENABLE
-                   current.use_ssl = FLAG_FALSE;
-#else
-                   yyerror(GT_("SSL is not enabled"));
-#endif 
-               }
+               | NO SSL                {current.use_ssl     = FLAG_FALSE;}
 
                | LIMIT NUMBER          {current.limit       = NUM_VALUE_IN($2);}
                | WARNINGS NUMBER       {current.warnings    = NUM_VALUE_IN($2);}
diff --git a/sink.c b/sink.c
index bd1d9243a6121877f3d24487ca0b22358568a26f..74244e105ae71ff401c1a479bb7b4eea1da6da07 100644 (file)
--- a/sink.c
+++ b/sink.c
@@ -618,6 +618,7 @@ static int open_smtp_sink(struct query *ctl, struct msgblk *msg,
     char               **from_responses;
 #endif /* EXPLICIT_BOUNCE_ON_BAD_ADDRESS */
     int                total_addresses;
+    int                force_transient_error;
 
     /*
      * Compute ESMTP options.
@@ -727,7 +728,8 @@ static int open_smtp_sink(struct query *ctl, struct msgblk *msg,
 #ifdef EXPLICIT_BOUNCE_ON_BAD_ADDRESS
                    char errbuf[POPBUFSIZE];
 #endif /* EXPLICIT_BOUNCE_ON_BAD_ADDRESS */
-               handle_smtp_report(ctl, msg);
+               if (handle_smtp_report(ctl, msg) == PS_TRANSIENT)
+                   force_transient_error = 1;
 
 #ifdef EXPLICIT_BOUNCE_ON_BAD_ADDRESS
 #ifdef HAVE_SNPRINTF
@@ -774,6 +776,14 @@ static int open_smtp_sink(struct query *ctl, struct msgblk *msg,
      */
     if (!(*good_addresses)) 
     {
+       if (force_transient_error) {
+               /* do not risk dataloss due to overengineered multidrop
+                * crap. If one of the recipients returned PS_TRANSIENT,
+                * we return exactly that.
+                */
+               SMTP_rset(ctl->smtp_socket);        /* required by RFC1870 */
+               return(PS_TRANSIENT);
+       }
        if (!run.postmaster[0])
        {
            if (outlevel >= O_VERBOSE)
index 27b928ccd473a6fe81d5970892d1b8bbafa4042b..3310b179d9d24b40a85306e4a3f862e0cdd93c8c 100644 (file)
--- a/socket.c
+++ b/socket.c
@@ -36,7 +36,6 @@
 #else
 #include <varargs.h>
 #endif
-#include <signal.h>
 #include "socket.h"
 #include "fetchmail.h"
 #include "i18n.h"
@@ -68,6 +67,8 @@ static int h_errno;
 
 #endif /* ndef h_errno */
 
+extern int mailserver_socket_temp;     /* Socket to close if connect timeout */
+
 #if NET_SECURITY
 #include <net/security.h>
 #endif /* NET_SECURITY */
@@ -219,10 +220,6 @@ int SockCheckOpen(int fd)
 
 int UnixOpen(const char *path)
 {
-#ifdef HAVE_SIGPROCMASK
-    sigset_t   allsigs;
-#endif /* HAVE_SIGPROCMASK */
-
     int sock = -1;
     struct sockaddr_un ad;
     memset(&ad, 0, sizeof(ad));
@@ -236,13 +233,12 @@ int UnixOpen(const char *path)
        return -1;
     }
 
-#ifdef HAVE_SIGPROCMASK
-    /* avoid socket leak on alarm signal during connect(2) */
-    sigfillset(&allsigs);
-    sigprocmask(SIG_BLOCK, &allsigs, NULL);
-#endif /* HAVE_SIGPROCMASK */
-
-    if (connect(sock, (struct sockaddr *) &ad, sizeof(ad)) < 0)
+       /* Socket opened saved. Usefull if connect timeout 
+        * because it can be closed.
+        */
+       mailserver_socket_temp = sock;
+    
+       if (connect(sock, (struct sockaddr *) &ad, sizeof(ad)) < 0)
     {
        int olderr = errno;
        fm_close(sock); /* don't use SockClose, no traffic yet */
@@ -250,10 +246,9 @@ int UnixOpen(const char *path)
        errno = olderr;
        sock = -1;
     }
-
-#ifdef HAVE_SIGPROCMASK
-    sigprocmask(SIG_UNBLOCK, &allsigs, NULL);
-#endif /* HAVE_SIGPROCMASK */
+       
+       /* No connect timeout, then no need to set mailserver_socket_temp */
+       mailserver_socket_temp = -1;
 
     return sock;
 }
@@ -262,10 +257,6 @@ int UnixOpen(const char *path)
 int SockOpen(const char *host, const char *service, const char *options,
             const char *plugin)
 {
-#ifdef HAVE_SIGPROCMASK
-    sigset_t   allsigs;
-#endif /* HAVE_SIGPROCMASK */
-
     struct addrinfo *ai, *ai0, req;
     int i;
 #if NET_SECURITY
@@ -304,29 +295,29 @@ int SockOpen(const char *host, const char *service, const char *options,
        break;
 #else
 
-#ifdef HAVE_SIGPROCMASK
-    /* avoid socket leak on alarm signal during connect(2) */
-    sigfillset(&allsigs);
-    sigprocmask(SIG_BLOCK, &allsigs, NULL);
-#endif /* HAVE_SIGPROCMASK */
-
     i = -1;
     for (ai = ai0; ai; ai = ai->ai_next) {
        i = socket(ai->ai_family, ai->ai_socktype, 0);
        if (i < 0)
            continue;
+
+       /* Socket opened saved. Usefull if connect timeout 
+        * because it can be closed.
+        */
+       mailserver_socket_temp = i;
+
        if (connect(i, (struct sockaddr *) ai->ai_addr, ai->ai_addrlen) < 0) {
            fm_close(i);
            i = -1;
            continue;
        }
+       
+       /* No connect timeout, then no need to set mailserver_socket_temp */
+       mailserver_socket_temp = -1;
+       
        break;
     }
 
-#ifdef HAVE_SIGPROCMASK
-    sigprocmask(SIG_UNBLOCK, &allsigs, NULL);
-#endif /* HAVE_SIGPROCMASK */
-
 #endif
 #endif /* NET_SECURITY */
 
@@ -389,6 +380,12 @@ int SockOpen(const char *host, int clientPort, const char *options,
             h_errno = 0;
             return -1;
         }
+
+               /* Socket opened saved. Usefull if connect timeout because
+                * it can be closed
+                */
+               mailserver_socket_temp = sock;
+               
         if (connect(sock, (struct sockaddr *) &ad, sizeof(ad)) < 0)
         {
             int olderr = errno;
@@ -397,6 +394,10 @@ int SockOpen(const char *host, int clientPort, const char *options,
             errno = olderr;
             return -1;
         }
+
+               /* No connect timeout, then no need to set mailserver_socket_temp */
+               mailserver_socket_temp = -1;
+               
 #ifndef HAVE_INET_ATON
     }
 #else
@@ -434,10 +435,19 @@ int SockOpen(const char *host, int clientPort, const char *options,
                h_errno = 0;
                return -1;
            }
+
+               /* Socket opened saved. Usefull if connect timeout because
+                * it can be closed
+                */
+               mailserver_socket_temp = sock;
+               
            ad.sin_port = htons(clientPort);
            memcpy(&ad.sin_addr, *pptr, sizeof(struct in_addr));
-           if (connect(sock, (struct sockaddr *) &ad, sizeof(ad)) == 0)
-               break; /* success */
+           if (connect(sock, (struct sockaddr *) &ad, sizeof(ad)) == 0) {
+                       /* No connect timeout, then no need to set mailserver_socket_temp */
+                       mailserver_socket_temp = -1;
+                       break; /* success */
+               }       
            fm_close(sock);     /* don't use SockClose, no traffic yet */
            memset(&ad, 0, sizeof(ad));
            ad.sin_family = AF_INET;
@@ -804,11 +814,11 @@ int SSL_verify_callback( int ok_return, X509_STORE_CTX *ctx, int strict )
                                }
                                tp += esz;
                        }
-                       if (outlevel > O_SILENT)
+                       if (outlevel > O_NORMAL)
                            report(stdout, GT_("%s key fingerprint: %s\n"), _server_label, text);
                        if (_check_digest != NULL) {
                                if (strcmp(text, _check_digest) == 0) {
-                                   if (outlevel > O_SILENT)
+                                   if (outlevel > O_NORMAL)
                                        report(stdout, GT_("%s fingerprints match.\n"), _server_label);
                                } else {
                                    if (outlevel > O_SILENT)