]> Pileus Git - ~andy/fetchmail/commitdiff
Added forcecr option.
authorEric S. Raymond <esr@thyrsus.com>
Thu, 17 Apr 1997 07:57:06 +0000 (07:57 -0000)
committerEric S. Raymond <esr@thyrsus.com>
Thu, 17 Apr 1997 07:57:06 +0000 (07:57 -0000)
svn path=/trunk/; revision=963

Makefile.in
NEWS
README
driver.c
fetchmail-FAQ.html
fetchmail.c
fetchmail.h
fetchmail.man
rcfile_l.l
rcfile_y.y
sample.rcfile

index a85ccb2f88df182d23dbc0a55916595ffe92f008..de7b3016606c6dcda0a8a338b5076b469ff8699d 100644 (file)
@@ -209,7 +209,7 @@ config = $(srcdir)/Makefile.in $(srcdir)/configure.in $(srcdir)/configure \
        $(srcdir)/acconfig.h
 scripts = $(srcdir)/install.sh $(srcdir)/mkinstalldirs $(srcdir)/specgen.sh
 all = $(docs) $(config) $(srcs) $(parser) $(headers) $(extra) $(scripts) \
-       $(srcdir)/MANIFEST contrib
+       $(srcdir)/contrib/* $(srcdir)/MANIFEST
 
 MANIFEST: $(srcdir)
        @echo $(all) | tr "[ \t]" '\n' | sort | sed "s/\\./fetchmail-$(VERS)/" >MANIFEST
diff --git a/NEWS b/NEWS
index 01ce522613a96da70e3570d2fe68f679f4addadd..e4a04c8c9cbe1fd1db58dc65ef5f1beea1b345a2 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -19,9 +19,10 @@ pl 3.9.1 (Sat Apr  5 14:22:16 EST 1997):
 * --check now turns off --daemon.
 * --syslog is now independent of --daemon.
 * Multiple-error X- headers are improved.
+* Added `forcecr' to fix qmail problems by forcing CRLF termination.
 
-There are 246 people on the fetchmail-friends list.
-(24 bad addresses were dropped)
+There are 225 people on the fetchmail-friends list.
+(many bad addresses were dropped after the switchover to SmartList)
 
 ------------------------------------------------------------------------------
 fetchmail-3.9 (Wed Apr  2 13:36:22 EST 1997)
diff --git a/README b/README
index a0bda331bb574afd142e208b895852e207682fab..02626f47226d66cfdce8bf2674c0f93e8c6b9845 100644 (file)
--- a/README
+++ b/README
@@ -25,8 +25,8 @@ Since 3.0:
 
        ** Support for ESMTP ETRN command.
 
-       ** The stripcr option to explicitly control carriage-return
-          stripping before mail forwarding.
+       ** The stripcr and forcecr option to explicitly control carriage-return
+          stripping and LF->CRLF mapping before mail forwarding.
 
 Since 2.0:
 
index 753b90ecd2a05d0857409749d09f86bdbbf3c72c..701224f00cb0ecbf02d2a44a1d9111c9bb4ab9c0 100644 (file)
--- a/driver.c
+++ b/driver.c
@@ -466,6 +466,19 @@ char *realname;            /* real name of host */
        do {
            if (!SockGets(buf, sizeof(buf)-1, sockfp))
                return(PS_SOCKET);
+
+           /* lines may not be properly CRLF terminated; fix this for qmail */
+           if (ctl->forcecr)
+           {
+               cp = buf + strlen(buf) - 1;
+               if (cp > buf && *cp == '\n' && cp[-1] != '\r')
+               {
+                   *cp++ = '\r';
+                   *cp++ = '\n';
+                   *cp++ = '\0';
+               }
+           }
+
            set_timeout(ctl->server.timeout);
            /* leave extra room for reply_hack to play with */
            line = realloc(line, strlen(line) + strlen(buf) + HOSTLEN + 1);
@@ -1008,6 +1021,18 @@ char *realname;          /* real name of host */
        }
        remaining -= n;
 
+       /* fix messages that have only \n line-termination (for qmail) */
+       if (ctl->forcecr)
+       {
+           cp = buf + strlen(buf) - 1;
+           if (cp > buf && *cp == '\n' && cp[-1] != '\r')
+           {
+               *cp++ = '\r';
+               *cp++ = '\n';
+               *cp++ = '\0';
+           }
+       }
+
        /* check for end of message */
        if (delimited && *buf == '.')
            if (buf[1] == '\r' && buf[2] == '\n')
index 79ce34f3700cadae8bb926095a430f7ca329f584..7de91de15db104647bd53005fffe5e738515c640 100644 (file)
@@ -9,7 +9,7 @@
 <BODY>
 <H1>Frequently Asked Questions About Fetchmail</H1>
 
-$Id: fetchmail-FAQ.html,v 1.3 1997/04/16 20:29:43 esr Exp $<p>
+$Id: fetchmail-FAQ.html,v 1.4 1997/04/17 07:56:59 esr Exp $<p>
 
 (Added <a href="http:#C6">C6</a> on working with qmail and 
 <a href="http:#C7">C7</a> on managing fetchmail in the presence of
@@ -54,7 +54,7 @@ and is a SmartList reflector; sign up in the usual way. <p>
 <a href="#C3">C3. How do I know what interface and address to use with --interface?</a><br>
 <a href="#C4">C4. How can I get fetchmail to work with ssh?</a><br>
 <a href="#C5">C5. How can I set up support for sendmail's anti-spam 571 response?</a><br>
-<a href="#C6">C6. How can I use fetchmail multidrop mode with qmail?</a><br>
+<a href="#C6">C6. How can I use fetchmail with qmail?</a><br>
 <a href="#C7">C7. How can I do automatic startup/shutdown of fetchmail
 when I may have multiple login sessions going?</a><br>
 
@@ -548,7 +548,10 @@ to allow sendmail to process the message further and generate an error
 message to the sender.  <p>
 
 <hr>
-<h2><a name="C6">C6. How can I use fetchmail multidrop mode with qmail?</a></h2>
+<h2><a name="C6">C6. How can I use fetchmail with qmail?</a></h2>
+
+Turn on the <tt>forcecr</tt> option; qmail's listener mode doesn't like 
+header or message lines terminated with bare linefeeds.<p>
 
 (This information is thanks to Robert de Bath 
 &lt;robert@mayday.cix.co.uk&gt;.)<p>
index 700b9babe2a6d7330c45411a523ef108d5b5e900..172eb17edba9f1085fc41f396fff1232e3d1f976 100644 (file)
@@ -631,6 +631,7 @@ static int load_params(int argc, char **argv, int optind)
            DEFAULT(ctl->fetchall, FALSE);
            DEFAULT(ctl->rewrite, TRUE);
            DEFAULT(ctl->stripcr, (ctl->mda != (char *)NULL)); 
+           DEFAULT(ctl->forcecr, FALSE);
            DEFAULT(ctl->server.dns, TRUE);
            DEFAULT(ctl->server.uidl, FALSE);
 #undef DEFAULT
@@ -853,6 +854,9 @@ void dump_params (struct query *ctl)
     printf("  Carriage-return stripping is %sabled (--stripcr %s).\n",
           ctl->stripcr ? "en" : "dis",
           ctl->stripcr ? "on" : "off");
+    printf("  Carriage-return forcing is %sabled (--forcecr %s).\n",
+          ctl->forcecr ? "en" : "dis",
+          ctl->forcecr ? "on" : "off");
     if (ctl->limit)
        printf("  Message size limit is %d bytes (--limit %d).\n", 
               ctl->limit, ctl->limit);
index 526d7370f4a58b909547ad447c52b5017666f560..4680bfe3c38961075d6e34158ae07ac5a7c9ad1f 100644 (file)
@@ -114,6 +114,7 @@ struct query
     int flush;
     int rewrite;
     int stripcr;
+    int forcecr;
     int limit;
     int fetchlimit;
     int batchlimit;
index 72b9bb04a498dc1d671ff9d9acb0b78534a89175..4abc7ad9b317602c87bebc23b4e63f3e7e73c598 100644 (file)
@@ -618,12 +618,14 @@ Legal user options are
     fetchall
     rewrite
     stripcr
+    forcecr
     dns
     no keep
     no flush
     no fetchall
     no rewrite
     no stripcr
+    no forcecr
     no dns
     no envelope
     limit
@@ -633,8 +635,8 @@ Legal user options are
 .PP
 All options correspond to the obvious command-line arguments except
 the following: `aka', `is', `to', `dns'/`no dns', `password',
-\&`preconnect', `localdomains', `stripcr'/`no stripcr' and
-\&`no received'.
+\&`preconnect', `localdomains', `stripcr'/`no stripcr' ,
+\&`forcecr'/`no forcecr' and `no received'.
 .PP
 The `is' or `to' keywords associate the following local (client)
 name(s) (or server-name to client-name mappings separated by =) with
@@ -698,11 +700,18 @@ establishes a mailserver connection.  This may be useful if you are
 attempting to set up secure POP connections with the aid of
 .IR ssh (1).
 .PP
+The `forcecr' option controls whether lines terminated by LF only are
+given CRLF termination before forwarding.  Strictly speaking RFC821
+requires this, but few MTAs enforce the requirement it so this option
+is normally off (only one such MTA, qmail, is in significant use at
+time of writing).  
+.PP
 The `stripcr' option controls whether carriage returns are stripped
 out of retrieved mail before it is forwarded.  It is normally not
 necessary to set this, because it defaults to `on' (CR stripping
 enabled) when there is an MDA declared but `off' (CR stripping
-disabled) when forwarding is via SMTP.
+disabled) when forwarding is via SMTP.  If `stripcr' and `forcecr' are
+both on, `stripcr' will override.
 .PP
 Legal protocol identifiers are
 
index 8d9ec034f0a55be7f69db9fbf23e86a94f9bf690..9d36b41ed9c2f1288a452c08a274dc1030f47fdd 100644 (file)
@@ -60,6 +60,7 @@ keep          { return KEEP; }
 flush          { return FLUSH; }
 fetchall       { return FETCHALL; }
 rewrite                { return REWRITE; }
+forcecr                { return FORCECR; }
 stripcr                { return STRIPCR; }
 dns            { return DNS; }
 uidl           { return UIDL; }
index d9bf0ebc53cf6daf62c75400a166807259efae60..f2e703a9285c2b35d363027470f962783ff4b958 100644 (file)
@@ -48,7 +48,7 @@ static void user_reset();
 %token <proto> PROTO
 %token <sval>  STRING
 %token <number> NUMBER
-%token NO KEEP FLUSH FETCHALL REWRITE STRIPCR DNS PORT UIDL
+%token NO KEEP FLUSH FETCHALL REWRITE FORCECR STRIPCR DNS PORT UIDL
 
 %%
 
@@ -199,12 +199,14 @@ user_option       : TO localnames HERE
                | FLUSH                 {current.flush      = FLAG_TRUE;}
                | FETCHALL              {current.fetchall   = FLAG_TRUE;}
                | REWRITE               {current.rewrite    = FLAG_TRUE;}
+               | FORCECR               {current.forcecr    = FLAG_TRUE;}
                | STRIPCR               {current.stripcr    = FLAG_TRUE;}
 
                | NO KEEP               {current.keep       = FLAG_FALSE;}
                | NO FLUSH              {current.flush      = FLAG_FALSE;}
                | NO FETCHALL           {current.fetchall   = FLAG_FALSE;}
                | NO REWRITE            {current.rewrite    = FLAG_FALSE;}
+               | NO FORCECR            {current.forcecr    = FLAG_FALSE;}
                | NO STRIPCR            {current.stripcr    = FLAG_FALSE;}
 
                | LIMIT NUMBER          {current.limit      = $2;}
@@ -366,6 +368,7 @@ static void record_current(void)
     FLAG_FORCE(flush);
     FLAG_FORCE(fetchall);
     FLAG_FORCE(rewrite);
+    FLAG_FORCE(forcecr);
     FLAG_FORCE(stripcr);
     FLAG_FORCE(limit);
     FLAG_FORCE(fetchlimit);
@@ -408,6 +411,7 @@ void optmerge(struct query *h2, struct query *h1)
     FLAG_MERGE(flush);
     FLAG_MERGE(fetchall);
     FLAG_MERGE(rewrite);
+    FLAG_MERGE(forcecr);
     FLAG_MERGE(stripcr);
     FLAG_MERGE(limit);
     FLAG_MERGE(fetchlimit);
index 75bc72cd30d1f48714fe14726de5d6705f4572c5..ade59267a269f1c1c81c49f5b6e5306bb4de5d25 100644 (file)
 #   flush
 #   fetchall
 #   rewrite
+#   forcecr
 #   stripcr
 #   dns
 #   no keep
 #   no flush
 #   no fetchall
 #   no rewrite
+#   no forcecr
 #   no stripcr
 #   no dns
 #   no envelope