From 68b96cb4f8258c5120b8daec819cb8ae2456f399 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Thu, 17 Apr 1997 07:57:06 +0000 Subject: Added forcecr option. svn path=/trunk/; revision=963 --- Makefile.in | 2 +- NEWS | 5 +++-- README | 4 ++-- driver.c | 25 +++++++++++++++++++++++++ fetchmail-FAQ.html | 9 ++++++--- fetchmail.c | 4 ++++ fetchmail.h | 1 + fetchmail.man | 15 ++++++++++++--- rcfile_l.l | 1 + rcfile_y.y | 6 +++++- sample.rcfile | 2 ++ 11 files changed, 62 insertions(+), 12 deletions(-) diff --git a/Makefile.in b/Makefile.in index a85ccb2f..de7b3016 100644 --- a/Makefile.in +++ b/Makefile.in @@ -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 01ce5226..e4a04c8c 100644 --- 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 a0bda331..02626f47 100644 --- 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: diff --git a/driver.c b/driver.c index 753b90ec..701224f0 100644 --- 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') diff --git a/fetchmail-FAQ.html b/fetchmail-FAQ.html index 79ce34f3..7de91de1 100644 --- a/fetchmail-FAQ.html +++ b/fetchmail-FAQ.html @@ -9,7 +9,7 @@

Frequently Asked Questions About Fetchmail

-$Id: fetchmail-FAQ.html,v 1.3 1997/04/16 20:29:43 esr Exp $

+$Id: fetchmail-FAQ.html,v 1.4 1997/04/17 07:56:59 esr Exp $

(Added C6 on working with qmail and C7 on managing fetchmail in the presence of @@ -54,7 +54,7 @@ and is a SmartList reflector; sign up in the usual way.

C3. How do I know what interface and address to use with --interface?
C4. How can I get fetchmail to work with ssh?
C5. How can I set up support for sendmail's anti-spam 571 response?
-C6. How can I use fetchmail multidrop mode with qmail?
+C6. How can I use fetchmail with qmail?
C7. How can I do automatic startup/shutdown of fetchmail when I may have multiple login sessions going?
@@ -548,7 +548,10 @@ to allow sendmail to process the message further and generate an error message to the sender.


-

C6. How can I use fetchmail multidrop mode with qmail?

+

C6. How can I use fetchmail with qmail?

+ +Turn on the forcecr option; qmail's listener mode doesn't like +header or message lines terminated with bare linefeeds.

(This information is thanks to Robert de Bath <robert@mayday.cix.co.uk>.)

diff --git a/fetchmail.c b/fetchmail.c index 700b9bab..172eb17e 100644 --- a/fetchmail.c +++ b/fetchmail.c @@ -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); diff --git a/fetchmail.h b/fetchmail.h index 526d7370..4680bfe3 100644 --- a/fetchmail.h +++ b/fetchmail.h @@ -114,6 +114,7 @@ struct query int flush; int rewrite; int stripcr; + int forcecr; int limit; int fetchlimit; int batchlimit; diff --git a/fetchmail.man b/fetchmail.man index 72b9bb04..4abc7ad9 100644 --- a/fetchmail.man +++ b/fetchmail.man @@ -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 diff --git a/rcfile_l.l b/rcfile_l.l index 8d9ec034..9d36b41e 100644 --- a/rcfile_l.l +++ b/rcfile_l.l @@ -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; } diff --git a/rcfile_y.y b/rcfile_y.y index d9bf0ebc..f2e703a9 100644 --- a/rcfile_y.y +++ b/rcfile_y.y @@ -48,7 +48,7 @@ static void user_reset(); %token PROTO %token STRING %token 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); diff --git a/sample.rcfile b/sample.rcfile index 75bc72cd..ade59267 100644 --- a/sample.rcfile +++ b/sample.rcfile @@ -44,12 +44,14 @@ # flush # fetchall # rewrite +# forcecr # stripcr # dns # no keep # no flush # no fetchall # no rewrite +# no forcecr # no stripcr # no dns # no envelope -- cgit v1.2.3