diff options
-rw-r--r-- | usr.sbin/smtpd/aliases.5 | 7 | ||||
-rw-r--r-- | usr.sbin/smtpd/lka_session.c | 28 | ||||
-rw-r--r-- | usr.sbin/smtpd/smtpd.h | 5 | ||||
-rw-r--r-- | usr.sbin/smtpd/to.c | 21 |
4 files changed, 55 insertions, 6 deletions
diff --git a/usr.sbin/smtpd/aliases.5 b/usr.sbin/smtpd/aliases.5 index c9d72e4cfb8..66ea5d62c92 100644 --- a/usr.sbin/smtpd/aliases.5 +++ b/usr.sbin/smtpd/aliases.5 @@ -1,4 +1,4 @@ -.\" $OpenBSD: aliases.5,v 1.9 2015/09/03 12:23:23 millert Exp $ +.\" $OpenBSD: aliases.5,v 1.10 2015/10/28 07:25:30 gilles Exp $ .\" .\" Copyright (c) 2012 Gilles Chehade <gilles@poolp.org> .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: September 3 2015 $ +.Dd $Mdocdate: October 28 2015 $ .Dt ALIASES 5 .Os .Sh NAME @@ -85,6 +85,9 @@ A status code and message to return. The code must be 3 digits, starting 4XX (TempFail) or 5XX (PermFail). The message must be present and can be freely chosen. +.It Ar maildir Ns : Ns /path +Deliver messages to Maildir at the +.Ar path. .El .Sh FILES .Bl -tag -width "/etc/mail/aliasesXXX" -compact diff --git a/usr.sbin/smtpd/lka_session.c b/usr.sbin/smtpd/lka_session.c index f36642396ea..28e9dd220aa 100644 --- a/usr.sbin/smtpd/lka_session.c +++ b/usr.sbin/smtpd/lka_session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lka_session.c,v 1.71 2015/10/06 06:44:47 gilles Exp $ */ +/* $OpenBSD: lka_session.c,v 1.72 2015/10/28 07:25:30 gilles Exp $ */ /* * Copyright (c) 2011 Gilles Chehade <gilles@poolp.org> @@ -452,6 +452,27 @@ lka_expand(struct lka_session *lks, struct rule *rule, struct expandnode *xn) "[depth=%d]", xn->u.buffer, xn->depth); lka_submit(lks, rule, xn); break; + + case EXPAND_MAILDIR: + log_trace(TRACE_EXPAND, "expand: lka_expand: maildir: %s " + "[depth=%d]", xn->u.buffer, xn->depth); + r = table_lookup(rule->r_userbase, NULL, + xn->parent->u.user, K_USERINFO, &lk); + if (r == -1) { + log_trace(TRACE_EXPAND, "expand: lka_expand: maildir: " + "backend error while searching user"); + lks->error = LKA_TEMPFAIL; + break; + } + if (r == 0) { + log_trace(TRACE_EXPAND, "expand: lka_expand: maildir: " + "user-part does not match system user"); + lks->error = LKA_PERMFAIL; + break; + } + + lka_submit(lks, rule, xn); + break; } } @@ -544,6 +565,11 @@ lka_submit(struct lka_session *lks, struct rule *rule, struct expandnode *xn) (void)strlcpy(ep->agent.mda.buffer, rule->r_value.buffer, sizeof ep->agent.mda.buffer); } + else if (xn->type == EXPAND_MAILDIR) { + ep->agent.mda.method = A_MAILDIR; + (void)strlcpy(ep->agent.mda.buffer, xn->u.buffer, + sizeof ep->agent.mda.buffer); + } else fatalx("lka_deliver: bad node type"); diff --git a/usr.sbin/smtpd/smtpd.h b/usr.sbin/smtpd/smtpd.h index 57a6a7e1ffc..a7711d2f0e6 100644 --- a/usr.sbin/smtpd/smtpd.h +++ b/usr.sbin/smtpd/smtpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: smtpd.h,v 1.480 2015/10/27 20:14:19 gilles Exp $ */ +/* $OpenBSD: smtpd.h,v 1.481 2015/10/28 07:25:30 gilles Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@poolp.org> @@ -431,7 +431,8 @@ enum expand_type { EXPAND_FILTER, EXPAND_INCLUDE, EXPAND_ADDRESS, - EXPAND_ERROR + EXPAND_ERROR, + EXPAND_MAILDIR }; struct expandnode { diff --git a/usr.sbin/smtpd/to.c b/usr.sbin/smtpd/to.c index da508a39dd9..498783c3420 100644 --- a/usr.sbin/smtpd/to.c +++ b/usr.sbin/smtpd/to.c @@ -1,4 +1,4 @@ -/* $OpenBSD: to.c,v 1.20 2015/10/14 22:01:43 gilles Exp $ */ +/* $OpenBSD: to.c,v 1.21 2015/10/28 07:25:30 gilles Exp $ */ /* * Copyright (c) 2009 Jacek Masiulaniec <jacekm@dobremiasto.net> @@ -51,6 +51,7 @@ #include "log.h" static const char *in6addr_to_text(const struct in6_addr *); +static int alias_is_maildir(struct expandnode *, const char *, size_t); static int alias_is_filter(struct expandnode *, const char *, size_t); static int alias_is_username(struct expandnode *, const char *, size_t); static int alias_is_address(struct expandnode *, const char *, size_t); @@ -677,6 +678,7 @@ text_to_expandnode(struct expandnode *expandnode, const char *s) alias_is_filter(expandnode, s, l) || alias_is_filename(expandnode, s, l) || alias_is_address(expandnode, s, l) || + alias_is_maildir(expandnode, s, l) || alias_is_username(expandnode, s, l)) return (1); @@ -691,6 +693,7 @@ expandnode_to_text(struct expandnode *expandnode) case EXPAND_FILENAME: case EXPAND_INCLUDE: case EXPAND_ERROR: + case EXPAND_MAILDIR: return expandnode->u.buffer; case EXPAND_USERNAME: return expandnode->u.user; @@ -706,6 +709,22 @@ expandnode_to_text(struct expandnode *expandnode) /******/ static int +alias_is_maildir(struct expandnode *alias, const char *line, size_t len) +{ + if (strncasecmp("maildir:", line, 8) != 0) + return (0); + + line += 8; + memset(alias, 0, sizeof *alias); + alias->type = EXPAND_MAILDIR; + if (strlcpy(alias->u.buffer, line, + sizeof(alias->u.buffer)) >= sizeof(alias->u.buffer)) + return (0); + + return (1); +} + +static int alias_is_filter(struct expandnode *alias, const char *line, size_t len) { int v = 0; |