diff options
author | Joerg Jung <jung@cvs.openbsd.org> | 2015-10-27 21:20:12 +0000 |
---|---|---|
committer | Joerg Jung <jung@cvs.openbsd.org> | 2015-10-27 21:20:12 +0000 |
commit | 93cd0f55070d3b7ee4a47a809f313f5f04309bf6 (patch) | |
tree | e026236c261789dcb5406393ea4bc85d15d17e94 /usr.sbin | |
parent | 75870e0d1943fb67349510366c28e8c5ea52b571 (diff) |
add a rcpt-to parameter to be able to use the original (probably expanded)
RCPT TO within LMTP sessions
ok gilles eric
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/smtpd/delivery_lmtp.c | 9 | ||||
-rw-r--r-- | usr.sbin/smtpd/mda.c | 4 | ||||
-rw-r--r-- | usr.sbin/smtpd/parse.y | 20 | ||||
-rw-r--r-- | usr.sbin/smtpd/smtpd.conf.5 | 15 |
4 files changed, 39 insertions, 9 deletions
diff --git a/usr.sbin/smtpd/delivery_lmtp.c b/usr.sbin/smtpd/delivery_lmtp.c index dfb3be10908..05f86b0a6f8 100644 --- a/usr.sbin/smtpd/delivery_lmtp.c +++ b/usr.sbin/smtpd/delivery_lmtp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: delivery_lmtp.c,v 1.13 2015/10/27 21:11:27 jung Exp $ */ +/* $OpenBSD: delivery_lmtp.c,v 1.14 2015/10/27 21:20:11 jung Exp $ */ /* * Copyright (c) 2013 Ashish SHUKLA <ashish.is@lostca.se> @@ -119,11 +119,13 @@ static void lmtp_open(struct deliver *deliver) { FILE *fp; - char *buf = NULL, hn[HOST_NAME_MAX+1], *to = deliver->to; + char *buf = NULL, hn[HOST_NAME_MAX + 1], + *rcpt = deliver->to, *to = deliver->to; size_t sz = 0; ssize_t len; int s; + strsep(&rcpt, " "); s = (to[0] == '/') ? unix_socket(to) : inet_socket(to); if ((fp = fdopen(s, "r+")) == NULL) err(1, "fdopen"); @@ -143,7 +145,8 @@ lmtp_open(struct deliver *deliver) if (lmtp_cmd(&buf, &sz, '2', fp, "MAIL FROM:<%s>", deliver->from) != 0) errx(1, "MAIL FROM rejected: %s", buf); - if (lmtp_cmd(&buf, &sz, '2', fp, "RCPT TO:<%s>", deliver->user) != 0) + if (lmtp_cmd(&buf, &sz, '2', fp, "RCPT TO:<%s>", + rcpt ? deliver->dest : deliver->user) != 0) errx(1, "RCPT TO rejected: %s", buf); if (lmtp_cmd(&buf, &sz, '3', fp, "DATA") != 0) diff --git a/usr.sbin/smtpd/mda.c b/usr.sbin/smtpd/mda.c index e2989387552..a5b5460a74f 100644 --- a/usr.sbin/smtpd/mda.c +++ b/usr.sbin/smtpd/mda.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mda.c,v 1.111 2015/10/26 09:22:03 jsg Exp $ */ +/* $OpenBSD: mda.c,v 1.112 2015/10/27 21:20:11 jung Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@poolp.org> @@ -349,6 +349,8 @@ mda_imsg(struct mproc *p, struct imsg *imsg) sizeof(deliver.user)); (void)strlcpy(deliver.from, e->sender, sizeof(deliver.from)); + (void)strlcpy(deliver.dest, e->dest, + sizeof(deliver.dest)); if (strlcpy(deliver.to, e->buffer, sizeof(deliver.to)) >= sizeof(deliver.to)) { diff --git a/usr.sbin/smtpd/parse.y b/usr.sbin/smtpd/parse.y index 19c2ba79a31..3689a581bda 100644 --- a/usr.sbin/smtpd/parse.y +++ b/usr.sbin/smtpd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.154 2015/09/07 15:36:53 gilles Exp $ */ +/* $OpenBSD: parse.y,v 1.155 2015/10/27 21:20:11 jung Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@poolp.org> @@ -163,7 +163,7 @@ typedef struct { %token AS QUEUE COMPRESSION ENCRYPTION MAXMESSAGESIZE MAXMTADEFERRED LISTEN ON ANY PORT EXPIRE %token TABLE SECURE SMTPS CERTIFICATE DOMAIN BOUNCEWARN LIMIT INET4 INET6 NODSN -%token RELAY BACKUP VIA DELIVER TO LMTP MAILDIR MBOX HOSTNAME HOSTNAMES +%token RELAY BACKUP VIA DELIVER TO LMTP MAILDIR MBOX RCPTTO HOSTNAME HOSTNAMES %token ACCEPT REJECT INCLUDE ERROR MDA FROM FOR SOURCE MTA PKI SCHEDULER %token ARROW AUTH TLS LOCAL VIRTUAL TAG TAGGED ALIAS FILTER KEY CA DHPARAMS %token AUTH_OPTIONAL TLS_REQUIRE USERBASE SENDER MASK_SOURCE VERIFY FORWARDONLY RECIPIENT @@ -993,6 +993,21 @@ deliver_action : DELIVER TO MAILDIR { fatal("invalid lmtp destination"); free($4); } + | DELIVER TO LMTP STRING RCPTTO { + rule->r_action = A_LMTP; + if (strchr($4, ':') || $4[0] == '/') { + if (strlcpy(rule->r_value.buffer, $4, + sizeof(rule->r_value.buffer)) + >= sizeof(rule->r_value.buffer)) + fatal("lmtp destination too long"); + if (strlcat(rule->r_value.buffer, " rcpt-to", + sizeof(rule->r_value.buffer)) + >= sizeof(rule->r_value.buffer)) + fatal("lmtp recipient too long"); + } else + fatal("invalid lmtp destination"); + free($4); + } | DELIVER TO MDA STRING { rule->r_action = A_MDA; if (strlcpy(rule->r_value.buffer, $4, @@ -1306,6 +1321,7 @@ lookup(char *s) { "pki", PKI }, { "port", PORT }, { "queue", QUEUE }, + { "rcpt-to", RCPTTO }, { "recipient", RECIPIENT }, { "reject", REJECT }, { "relay", RELAY }, diff --git a/usr.sbin/smtpd/smtpd.conf.5 b/usr.sbin/smtpd/smtpd.conf.5 index 3f7a9bf4205..3626e694bf8 100644 --- a/usr.sbin/smtpd/smtpd.conf.5 +++ b/usr.sbin/smtpd/smtpd.conf.5 @@ -1,4 +1,4 @@ -.\" $OpenBSD: smtpd.conf.5,v 1.129 2015/09/03 12:23:23 millert Exp $ +.\" $OpenBSD: smtpd.conf.5,v 1.130 2015/10/27 21:20:11 jung Exp $ .\" .\" Copyright (c) 2008 Janne Johansson <jj@openbsd.org> .\" Copyright (c) 2009 Jacek Masiulaniec <jacekm@dobremiasto.net> @@ -17,7 +17,7 @@ .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" .\" -.Dd $Mdocdate: September 3 2015 $ +.Dd $Mdocdate: October 27 2015 $ .Dt SMTPD.CONF 5 .Os .Sh NAME @@ -275,13 +275,22 @@ function. .Pp Finally, the method of delivery is specified: .Bl -tag -width Ds -.It Ic deliver to lmtp Op Ar host : Ns Ar port | socket +.It Xo +.Ic deliver to lmtp +.Op Ar host : Ns Ar port | socket +.Op Ic rcpt-to +.Xc Mail is delivered to .Ar host : Ns Ar port , or to the .Ux .Ar socket over LMTP. +.Pp +Optionally, +.Ic rcpt-to +might be specified to use the recipient email address (after expansion) instead +of the local user in the LMTP session as RCPT TO. .It Ic deliver to maildir Op Ar path Mail is added to a maildir. Its location, |