aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Andree <matthias.andree@gmx.de>2010-02-26 00:24:06 +0100
committerMatthias Andree <matthias.andree@gmx.de>2010-02-26 00:24:33 +0100
commita02ccfaeb28ac0cd1d8f2020b238c4861e068666 (patch)
tree5bf19de3a97be6459e9f7c4d3e2fe0d617b0e207
parent7a33fb4c7bbaf1d026fd6acc4591feb746bda744 (diff)
downloadfetchmail-a02ccfaeb28ac0cd1d8f2020b238c4861e068666.tar.gz
fetchmail-a02ccfaeb28ac0cd1d8f2020b238c4861e068666.tar.bz2
fetchmail-a02ccfaeb28ac0cd1d8f2020b238c4861e068666.zip
BSMTP error reporting and stdout handling fixes
* Do not close stdout when using mda and "bsmtp -" at the same time. * Log operating system errors when BSMTP writes fail.
-rw-r--r--NEWS2
-rw-r--r--sink.c46
2 files changed, 26 insertions, 22 deletions
diff --git a/NEWS b/NEWS
index 2ec905d9..44a07363 100644
--- a/NEWS
+++ b/NEWS
@@ -58,6 +58,8 @@ fetchmail 6.3.15 (not yet released):
* In the rcfile, recognize "local" as abbreviation for "localdomains", as
documented. The short form has not ever worked since this feature was added in
January 1997. Reported by Frédéric Marchal.
+* Do not close stdout when using mda and "bsmtp -" at the same time.
+* Log operating system errors when BSMTP writes fail.
# CHANGES
* The repository has been converted and moved from the Subversion (SVN) format
diff --git a/sink.c b/sink.c
index c5160364..a7a2820e 100644
--- a/sink.c
+++ b/sink.c
@@ -784,7 +784,7 @@ static int open_bsmtp_sink(struct query *ctl, struct msgblk *msg,
if (fflush(sinkfp) || ferror(sinkfp))
{
- report(stderr, GT_("BSMTP preamble write failed.\n"));
+ report(stderr, GT_("BSMTP preamble write failed: %s.\n"), strerror(errno));
return(PS_BSMTP);
}
@@ -1347,8 +1347,29 @@ int close_sink(struct query *ctl, struct msgblk *msg, flag forward)
/* perform end-of-message actions on the current output sink */
{
int smtp_err;
- if (ctl->mda)
- {
+
+ if (ctl->bsmtp && sinkfp) {
+ int error, oerrno;
+
+ /* implicit disk-full check here... */
+ fputs(".\r\n", sinkfp);
+ error = ferror(sinkfp);
+ oerrno = errno;
+ if (strcmp(ctl->bsmtp, "-"))
+ {
+ if (fclose(sinkfp) == EOF) {
+ error = 1;
+ oerrno = errno;
+ }
+ sinkfp = (FILE *)NULL;
+ }
+ if (error)
+ {
+ report(stderr,
+ GT_("Message termination or close of BSMTP file failed: %s\n"), strerror(oerrno));
+ return(FALSE);
+ }
+ } else if (ctl->mda) {
int rc = 0, e = 0, e2 = 0, err = 0;
/* close the delivery pipe, we'll reopen before next message */
@@ -1388,25 +1409,6 @@ int close_sink(struct query *ctl, struct msgblk *msg, flag forward)
return(FALSE);
}
}
- else if (ctl->bsmtp && sinkfp)
- {
- int error;
-
- /* implicit disk-full check here... */
- fputs(".\r\n", sinkfp);
- error = ferror(sinkfp);
- if (strcmp(ctl->bsmtp, "-"))
- {
- if (fclose(sinkfp) == EOF) error = 1;
- sinkfp = (FILE *)NULL;
- }
- if (error)
- {
- report(stderr,
- GT_("Message termination or close of BSMTP file failed\n"));
- return(FALSE);
- }
- }
else if (forward)
{
/* write message terminator */