From 45bcf00ee95d474f989d5594da378116d63702be Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Thu, 8 Nov 2001 16:53:54 +0000 Subject: [PATCH] Easy bug fixes for this round. svn path=/trunk/; revision=3543 --- Makefile.in | 8 ++++---- NEWS | 13 +++++++++++++ checkalias.c | 6 +++--- env.c | 22 +++++++++++++++++----- etrn.c | 6 +++--- fetchmail-FAQ.html | 8 ++++++-- fetchmail.h | 2 +- fetchmailconf | 8 ++++---- imap.c | 2 +- kerberos.c | 2 +- sink.c | 6 +++++- socket.c | 4 ++-- transact.c | 2 +- xalloca.c | 2 +- 14 files changed, 62 insertions(+), 29 deletions(-) diff --git a/Makefile.in b/Makefile.in index d010f562..ca352610 100644 --- a/Makefile.in +++ b/Makefile.in @@ -185,20 +185,20 @@ uninstall: .PHONY: clean realclean distclean mostlyclean clean: -cd intl; $(MAKE) clean - #work around braindamage in GNU gettext - -rm -f $(top_builddir)/intl/libintl.h + -rm -f $(top_builddir)/intl/libintl.h # work around GNU gettext brain-damage -cd po; $(MAKE) clean -rm -f fetchmail *.o core fetchmail.dvi \ rcfile_l.c rcfile_y.h rcfile_y.c \ fetchmail.tar fetchmail.tar.gz \ netrc rfc822 unmime fetchmail-man.html +# This target would also normally invoke the following line, but doing so +# messes up the RPM build, so the line was disabled. +# -rm -f config.h config.cache config.status config.log stamp-config distclean: clean -cd intl; $(MAKE) distclean -cd po; $(MAKE) distclean -rm -f TAGS tags - # Can't do these, it messes up RPM build - #-rm -f config.h config.cache config.status config.log stamp-config realclean: distclean -rm -f FAQ FEATURES NOTES MANIFEST diff --git a/NEWS b/NEWS index 542f0327..be11b9da 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,19 @@ (The `lines' figures total .c, .h, .l, and .y files under version control.) * Changed the logging logic along lines suggested by Jan Klaverstijn, +* fetchmauilconf looks first in the directory it's running from to find + fetchmail. +* Make sure we vet a success status correctly from open_smtp_sink() + and open_bsmtp_sink(). +* Matthias Andree's env.c patch to refuse service when QMAILINJECT is defined. +* Immediately abort if a non-empty QMAILINJECT environment variable is + found. If it is set and contains f or i, qmail-inject or qmail's + sendmail `compatibility' wrapper will rewrite From: or Message-ID: + headers, respectively. En passant, fix the bug that program_name was + not filled in before used when the user's ID had no PW entry, leading + to (null) or crash when printing the error message. Patch by Matthias + Andree. +* NextStep and OpenStep port patch from Eric Sunshine. fetchmail-5.9.4 (Wed Oct 3 07:47:45 EDT 2001), 21104 lines: diff --git a/checkalias.c b/checkalias.c index f8f8058b..cd5caca5 100644 --- a/checkalias.c +++ b/checkalias.c @@ -48,7 +48,7 @@ static int is_ip_alias(const char *name1,const char *name2) struct hostent *hp; char **p; - hp = gethostbyname(name1); + hp = gethostbyname((char*)name1); dummy_addr = (address_e *)NULL; @@ -63,7 +63,7 @@ static int is_ip_alias(const char *name1,const char *name2) dummy_addr = host_a_addr; } - hp = gethostbyname(name2); + hp = gethostbyname((char*)name2); dummy_addr = (address_e *)NULL; for (i=0,p = hp->h_addr_list; *p != 0; i++,p++) @@ -161,7 +161,7 @@ int is_host_alias(const char *name, struct query *ctl) * delivering the current message or anything else from the * current server until it's back up. */ - if ((he = gethostbyname(name)) != (struct hostent *)NULL) + if ((he = gethostbyname((char*)name)) != (struct hostent *)NULL) { if (strcasecmp(ctl->server.truename, he->h_name) == 0) goto match; diff --git a/env.c b/env.c index f83c0f02..93651a44 100644 --- a/env.c +++ b/env.c @@ -49,6 +49,23 @@ void envquery(int argc, char **argv) } } + if ((program_name = strrchr(argv[0], '/')) != NULL) + ++program_name; + else + program_name = argv[0]; + + if (getenv("QMAILINJECT") && strcmp(getenv("QMAILINJECT"), "")) + { + fprintf(stderr, + GT_("%s: The QMAILINJECT environment variable is set.\n" + "This is dangerous as it can make qmail-inject or qmail's sendmail wrapper\n" + "tamper with your From: or Message-ID: headers.\n" + "Try \"env QMAILINJECT= %s YOUR ARGUMENTS HERE\"\n" + "%s: Abort.\n"), + program_name, program_name, program_name); + exit(PS_UNDEFINED); + } + if (!(pwp = getpwuid(getuid()))) { fprintf(stderr, @@ -85,11 +102,6 @@ void envquery(int argc, char **argv) if (!(fmhome = getenv("FETCHMAILHOME"))) fmhome = home; - if ((program_name = strrchr(argv[0], '/')) != NULL) - ++program_name; - else - program_name = argv[0]; - #define RCFILE_NAME "fetchmailrc" /* * The (fmhome==home) leaves an extra character for a . at the diff --git a/etrn.c b/etrn.c index 8912513e..00455faf 100644 --- a/etrn.c +++ b/etrn.c @@ -71,18 +71,18 @@ static int etrn_getrange(int sock, struct query *ctl, const char *id, switch(atoi(buf)) { case 250: /* OK, queuing for node started */ - if (outlevel >= O_SILENT) + if (outlevel > O_SILENT) report(stdout, GT_("Queuing for %s started\n"), qnp->id); break; case 251: /* OK, no messages waiting for node */ - if (outlevel >= O_SILENT) + if (outlevel > O_SILENT) report(stdout, GT_("No messages waiting for %s\n"), qnp->id); return(PS_NOMAIL); case 252: /* OK, pending messages for node started */ case 253: /* OK, pending messages for node started */ - if (outlevel >= O_SILENT) + if (outlevel > O_SILENT) report(stdout, GT_("Pending messages for %s started\n"), qnp->id); break; diff --git a/fetchmail-FAQ.html b/fetchmail-FAQ.html index 50b9ffb6..db64b9ff 100644 --- a/fetchmail-FAQ.html +++ b/fetchmail-FAQ.html @@ -10,7 +10,7 @@
Back to Fetchmail Home Page To Site Map -$Date: 2001/10/13 04:51:50 $ +$Date: 2001/11/08 16:53:52 $

Frequently Asked Questions About Fetchmail

@@ -1609,6 +1609,10 @@ Fetchmail normally uses TOP for message retrieval in order to avoid marking messages seen, but `fetchall' forces it to use RETR instead. +

Also, we're told USA.NET adds a ton of hops to your messages. You may +need to raise the MaxHopCount parameter in your sendmail.cf to avoid having +fetched mail rejected. +

(Note: Other failure modes have been reported on usa.net's servers. They seem to be chronically flaky. We recommend finding another provider.) @@ -2921,7 +2925,7 @@ date from the last Received header.

Back to Fetchmail Home Page To Site Map -$Date: 2001/10/13 04:51:50 $ +$Date: 2001/11/08 16:53:52 $

Eric S. Raymond <esr@thyrsus.com>
diff --git a/fetchmail.h b/fetchmail.h index 1380ee95..46344627 100644 --- a/fetchmail.h +++ b/fetchmail.h @@ -540,7 +540,7 @@ char *xstrdup(const char *); #endif #define xalloca(ptr, t, n) if (!(ptr = (t) alloca(n)))\ {report(stderr, GT_("alloca failed")); exit(PS_UNDEFINED);} -#if FALSE +#if 0 /* * This is a hack to help xgettext which cannot find strings in * macro definitions like the one for xalloca above. diff --git a/fetchmailconf b/fetchmailconf index 18c81fd8..f049a04c 100755 --- a/fetchmailconf +++ b/fetchmailconf @@ -1770,10 +1770,10 @@ class RunWindow(Frame): self.update() # Draw widget before executing fetchmail - # Always look for a runnable command in the current directory first. - # This avoids some obscure version-skew errors that can occur if you - # pick up an old fetchmail from the standard system locations. - os.environ["PATH"] = ".:" + os.environ["PATH"] + # Always look for a runnable command in the directory we're running in + # first. This avoids some obscure version-skew errors that can occur + # if you pick up an old fetchmail from the standard system locations. + os.environ["PATH"] = os.path.dirname(sys.argv[0]) + ":" + os.environ["PATH"] child_stdout = os.popen(command + " 2>&1", "r") while 1: ch = child_stdout.read(1) diff --git a/imap.c b/imap.c index 2ee7759e..9a22a37c 100644 --- a/imap.c +++ b/imap.c @@ -181,7 +181,7 @@ static int do_imap_ntlm(int sock, struct query *ctl) if ((gen_recv(sock, msgbuf, sizeof msgbuf))) return result; - len = from64tobits ((unsigned char*)&challenge, msgbuf); + len = from64tobits ((unsigned char*)&challenge, msgbuf, sizeof(msgbuf)); if (outlevel >= O_DEBUG) dumpSmbNtlmAuthChallenge(stdout, &challenge); diff --git a/kerberos.c b/kerberos.c index a6d97758..3254873d 100644 --- a/kerberos.c +++ b/kerberos.c @@ -208,7 +208,7 @@ int do_rfc1731(int sock, char *command, char *truename) * process is complete. */ - len = from64tobits(buf2, buf1, sizeof(buf2x)); + len = from64tobits(buf2, buf1, sizeof(buf2)); if (len < 0) { report(stderr, GT_("could not decode BASE64 ready response\n")); return PS_AUTHFAIL; diff --git a/sink.c b/sink.c index a72be53a..e0b904e6 100644 --- a/sink.c +++ b/sink.c @@ -793,6 +793,8 @@ static int open_smtp_sink(struct query *ctl, struct msgblk *msg, SMTP_rset(ctl->smtp_socket); /* stay on the safe side */ return(handle_smtp_report(ctl, msg)); } + + return(PS_SUCCESS); } static int open_mda_sink(struct query *ctl, struct msgblk *msg, @@ -951,13 +953,15 @@ static int open_mda_sink(struct query *ctl, struct msgblk *msg, * error status instead of 0 for successful completion. */ #ifndef HAVE_SIGACTION - sigchld = signal(SIGCHLD, SIG_DFL); + signal(SIGCHLD, SIG_DFL); #else memset (&sa_new, 0, sizeof sa_new); sigemptyset (&sa_new.sa_mask); sa_new.sa_handler = SIG_DFL; sigaction (SIGCHLD, &sa_new, NULL); #endif /* HAVE_SIGACTION */ + + return(PS_SUCCESS); } int open_sink(struct query *ctl, struct msgblk *msg, diff --git a/socket.c b/socket.c index c108b9b2..93a2be2f 100644 --- a/socket.c +++ b/socket.c @@ -340,7 +340,7 @@ int SockOpen(const char *host, int clientPort, const char *options, /* we'll accept a quad address */ #ifndef HAVE_INET_ATON - inaddr = inet_addr(host); + inaddr = inet_addr((char*)host); if (inaddr != INADDR_NONE) { memcpy(&ad.sin_addr, &inaddr, sizeof(inaddr)); @@ -370,7 +370,7 @@ int SockOpen(const char *host, int clientPort, const char *options, } #endif /* HAVE_INET_ATON */ else { - hp = gethostbyname(host); + hp = gethostbyname((char*)host); if (hp == NULL) { diff --git a/transact.c b/transact.c index 73629a63..638ccd6e 100644 --- a/transact.c +++ b/transact.c @@ -549,7 +549,7 @@ int readheaders(int sock, { if (ctl->lastid) free(ctl->lastid); - ctl->lastid = strdup(line); + ctl->lastid = xstrdup(line); } } diff --git a/xalloca.c b/xalloca.c index 2bb4e4ed..812b5514 100644 --- a/xalloca.c +++ b/xalloca.c @@ -41,7 +41,7 @@ int n; p = (XALLOCATYPE *) alloca(n); if (p == (XALLOCATYPE *) 0) { - report(stderr, "alloca failed\n"); + report(stderr, GT_("alloca failed\n")); exit(PS_UNDEFINED); } return(p); -- 2.43.2