diff options
author | Gilles Chehade <gilles@cvs.openbsd.org> | 2015-01-05 21:00:37 +0000 |
---|---|---|
committer | Gilles Chehade <gilles@cvs.openbsd.org> | 2015-01-05 21:00:37 +0000 |
commit | 8057e4b5d835f6cedcf7729ad20c02e69813dd51 (patch) | |
tree | 276fd3c6522eb833586ec91b489959afae962969 /usr.sbin | |
parent | 04297469186d5d829efb9d6f4d47ad6db1b1cf54 (diff) |
some third-party mda require a prepended From separator line, so remove the
prepending from delivery_filename backend and prepend conditionally earlier
in the code path if delivery method is through mda or filename.
ok eric@
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/smtpd/delivery_filename.c | 6 | ||||
-rw-r--r-- | usr.sbin/smtpd/mda.c | 36 |
2 files changed, 26 insertions, 16 deletions
diff --git a/usr.sbin/smtpd/delivery_filename.c b/usr.sbin/smtpd/delivery_filename.c index 1ce62432834..ade9de88577 100644 --- a/usr.sbin/smtpd/delivery_filename.c +++ b/usr.sbin/smtpd/delivery_filename.c @@ -1,4 +1,4 @@ -/* $OpenBSD: delivery_filename.c,v 1.9 2013/05/24 17:03:14 eric Exp $ */ +/* $OpenBSD: delivery_filename.c,v 1.10 2015/01/05 21:00:36 gilles Exp $ */ /* * Copyright (c) 2011 Gilles Chehade <gilles@poolp.org> @@ -52,7 +52,6 @@ static void delivery_filename_open(struct deliver *deliver) { struct stat sb; - time_t now; size_t len; int fd; FILE *fp; @@ -74,9 +73,6 @@ delivery_filename_open(struct deliver *deliver) fp = fdopen(fd, "a"); if (fp == NULL) error("fdopen"); - time(&now); - fprintf(fp, "From %s@%s %s", SMTPD_USER, env->sc_hostname, - ctime(&now)); while ((ln = fgetln(stdin, &len)) != NULL) { if (ln[len - 1] == '\n') len--; diff --git a/usr.sbin/smtpd/mda.c b/usr.sbin/smtpd/mda.c index c5ec554fe86..8dfd196d776 100644 --- a/usr.sbin/smtpd/mda.c +++ b/usr.sbin/smtpd/mda.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mda.c,v 1.107 2014/07/08 07:59:31 sobrado Exp $ */ +/* $OpenBSD: mda.c,v 1.108 2015/01/05 21:00:36 gilles Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@poolp.org> @@ -119,6 +119,7 @@ mda_imsg(struct mproc *p, struct imsg *imsg) const void *data; const char *error, *parent_error; uint64_t reqid; + time_t now; size_t sz; char out[256], buf[SMTPD_MAXLINESIZE]; int n; @@ -237,16 +238,29 @@ mda_imsg(struct mproc *p, struct imsg *imsg) return; } - /* start queueing delivery headers */ - if (e->sender[0]) - /* XXX: remove existing Return-Path, if any */ - n = iobuf_fqueue(&s->iobuf, - "Return-Path: %s\nDelivered-To: %s\n", - e->sender, e->rcpt ? e->rcpt : e->dest); - else - n = iobuf_fqueue(&s->iobuf, - "Delivered-To: %s\n", - e->rcpt ? e->rcpt : e->dest); + n = 0; + /* prepend "From " separator ... for A_MDA and A_FILENAME backends only */ + if (e->method == A_MDA || e->method == A_FILENAME) { + time(&now); + if (e->sender[0]) + n = iobuf_fqueue(&s->iobuf, + "From %s %s", e->sender, ctime(&now)); + else + n = iobuf_fqueue(&s->iobuf, + "From MAILER-DAEMON@%s %s", env->sc_hostname, ctime(&now)); + } + if (n != -1) { + /* start queueing delivery headers */ + if (e->sender[0]) + /* XXX: remove existing Return-Path, if any */ + n = iobuf_fqueue(&s->iobuf, + "Return-Path: %s\nDelivered-To: %s\n", + e->sender, e->rcpt ? e->rcpt : e->dest); + else + n = iobuf_fqueue(&s->iobuf, + "Delivered-To: %s\n", + e->rcpt ? e->rcpt : e->dest); + } if (n == -1) { log_warn("warn: mda: " "fail to write delivery info"); |