diff options
author | Matthias Andree <matthias.andree@gmx.de> | 2010-02-26 00:24:06 +0100 |
---|---|---|
committer | Matthias Andree <matthias.andree@gmx.de> | 2010-02-26 00:24:33 +0100 |
commit | a02ccfaeb28ac0cd1d8f2020b238c4861e068666 (patch) | |
tree | 5bf19de3a97be6459e9f7c4d3e2fe0d617b0e207 /sink.c | |
parent | 7a33fb4c7bbaf1d026fd6acc4591feb746bda744 (diff) | |
download | fetchmail-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.
Diffstat (limited to 'sink.c')
-rw-r--r-- | sink.c | 46 |
1 files changed, 24 insertions, 22 deletions
@@ -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 */ |