From ed41914db25525515d52f28b7c3771b2895fac68 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Mon, 6 Aug 2001 08:25:55 +0000 Subject: Two of Matthias Andree's four bugs. svn path=/trunk/; revision=3444 --- NEWS | 3 +++ fetchmail.c | 2 +- fetchmail.h | 3 +-- fetchmail.man | 4 ++-- sink.c | 34 ++++++---------------------------- 5 files changed, 13 insertions(+), 33 deletions(-) diff --git a/NEWS b/NEWS index 71499f8f..60ba759c 100644 --- a/NEWS +++ b/NEWS @@ -8,6 +8,9 @@ fetchmail-5.8.17 (Sat Aug 4 19:02:47 EDT 2001), 21093 lines: and the attacker can either subvert the mailserver or redirect to a fake one using DNS spoofing. Bugtraq announcement to follow soon. Thanks to antirez@invece.org. +* Eliminated second bounce on failed RCPT TO address. +* Always use fetchmail host's FQDN to identify the daemon when + sending bounce messages. There are people on fetchmail-friends and on fetchmail-announce. diff --git a/fetchmail.c b/fetchmail.c index cba2c678..5d513010 100644 --- a/fetchmail.c +++ b/fetchmail.c @@ -73,7 +73,7 @@ char *home; /* invoking user's home directory */ char *fmhome; /* fetchmail's home directory */ char *program_name; /* the name to prefix error messages with */ flag configdump; /* dump control blocks for configurator */ -const char *fetchmailhost; /* either `localhost' or the host's FQDN */ +char *fetchmailhost; /* either `localhost' or the host's FQDN */ #if NET_SECURITY void *request = NULL; diff --git a/fetchmail.h b/fetchmail.h index f171d67c..87e08e57 100644 --- a/fetchmail.h +++ b/fetchmail.h @@ -380,8 +380,7 @@ extern char *home; /* home directory of invoking user */ extern char *fmhome; /* fetchmail home directory */ extern int pass; /* number of re-polling pass */ extern flag configdump; /* dump control blocks as Python dictionary */ -extern const char *fetchmailhost; - /* either "localhost" or an FQDN */ +extern char *fetchmailhost; /* either "localhost" or an FQDN */ extern int suppress_tags; /* suppress tags in tagged protocols? */ extern char shroud[PASSWORDLEN]; /* string to shroud in debug output */ #ifdef SDPS_ENABLE diff --git a/fetchmail.man b/fetchmail.man index a85c4c09..7c0f86ef 100644 --- a/fetchmail.man +++ b/fetchmail.man @@ -6,7 +6,7 @@ .\" For license terms, see the file COPYING in this directory. .TH fetchmail 1 .SH NAME -fetchmail \- fetch mail from a POP, IMAP, or ETRN-capable server +fetchmail \- fetch mail from a POP, IMAP, ETRN, or ODMR-capable server .SH SYNOPSIS \fBfetchmail\fR [\fIoption...\fR] [\fImailserver...\fR] @@ -131,7 +131,7 @@ suppress actual error messages). The --verbose option overrides this. .B \-v, --verbose Verbose mode. All control messages passed between .I fetchmail -and the mailserver are echoed to stderr. Overrides --silent. +and the mailserver are echoed to stdout. Overrides --silent. Doubling this option (-v -v) causes extra diagnostic information to be printed. .SS Disposal Options diff --git a/sink.c b/sink.c index 502e989d..36b4ce54 100644 --- a/sink.c +++ b/sink.c @@ -281,12 +281,13 @@ static int send_bouncemail(struct query *ctl, struct msgblk *msg, SMTP_setmode(SMTP_MODE); - strcat(daemon_name, fetchmailhost); + /* can't just use fetchmailhost here, it might be localhost */ + strcat(daemon_name, host_fqdn()); /* we need only SMTP for this purpose */ if ((sock = SockOpen("localhost", SMTP_PORT, NULL, NULL)) == -1 || SMTP_ok(sock) != SM_OK - || SMTP_helo(sock, "localhost") != SM_OK + || SMTP_helo(sock, fetchmailhost) != SM_OK || SMTP_from(sock, daemon_name, (char *)NULL) != SM_OK || SMTP_rcpt(sock, bounce_to) != SM_OK || SMTP_data(sock) != SM_OK) @@ -342,7 +343,8 @@ static int send_bouncemail(struct query *ctl, struct msgblk *msg, char *error; /* Minimum RFC1894 compliance + Diagnostic-Code field */ SockPrintf(sock, "\r\n"); - SockPrintf(sock, "Final-Recipient: rfc822; %s\r\n", idp->id); + SockPrintf(sock, "Final-Recipient: rfc822; %s@%s\r\n", + idp->id, fetchmailhost); SockPrintf(sock, "Last-Attempt-Date: %s\r\n", rfc822timestamp()); SockPrintf(sock, "Action: failed\r\n"); @@ -584,7 +586,6 @@ int open_sink(struct query *ctl, struct msgblk *msg, const char *ap; char options[MSGBUFSIZE]; char addr[HOSTLEN+USERNAMELEN+1]; - char **from_responses; int total_addresses; /* @@ -664,7 +665,6 @@ int open_sink(struct query *ctl, struct msgblk *msg, total_addresses = 0; for (idp = msg->recipients; idp; idp = idp->next) total_addresses++; - xalloca(from_responses, char **, sizeof(char *) * total_addresses); for (idp = msg->recipients; idp; idp = idp->next) if (idp->val.status.mark == XMIT_ACCEPT) { @@ -692,27 +692,8 @@ int open_sink(struct query *ctl, struct msgblk *msg, { char errbuf[POPBUFSIZE]; - /* - * Do *not* interpret a PS_REFUSED here as a directive - * to break out of the address loop. We want to go through - * and process the rest of the RCPT TO addresses. - */ handle_smtp_report(ctl, msg); -#ifdef HAVE_SNPRINTF - snprintf(errbuf, sizeof(errbuf), "%s: %s", - idp->id, smtp_response); -#else - strncpy(errbuf, idp->id, sizeof(errbuf)); - strcat(errbuf, ": "); - strcat(errbuf, smtp_response); -#endif /* HAVE_SNPRINTF */ - - xalloca(from_responses[*bad_addresses], - char *, - strlen(errbuf)+1); - strcpy(from_responses[*bad_addresses], errbuf); - (*bad_addresses)++; idp->val.status.mark = XMIT_RCPTBAD; if (outlevel >= O_VERBOSE) @@ -721,10 +702,7 @@ int open_sink(struct query *ctl, struct msgblk *msg, ctl->listener, addr); } } - if (*bad_addresses) - send_bouncemail(ctl, msg, XMIT_RCPTBAD, - "Some addresses were rejected by the MDA fetchmail forwards to.\r\n", - *bad_addresses, from_responses); + /* * It's tempting to do local notification only if bouncemail was * insufficient -- that is, to add && total_addresses > *bad_addresses -- cgit v1.2.3