diff options
author | Gilles Chehade <gilles@cvs.openbsd.org> | 2016-08-31 10:18:09 +0000 |
---|---|---|
committer | Gilles Chehade <gilles@cvs.openbsd.org> | 2016-08-31 10:18:09 +0000 |
commit | 184f681d5dc83dfe142ab6a290003a3d9a3f6a10 (patch) | |
tree | 6a652a86dcb5e92c3ed5a3a56b2a9ffddc086181 | |
parent | 3bb7f5965295c7964b6f4ec89f1b7baf8dcc6dd3 (diff) |
allow overriding the subaddressing delimiter with subaddressing-delimiter
keyword, the default is still +
ok eric@, sunil@
-rw-r--r-- | usr.sbin/smtpd/aliases.c | 11 | ||||
-rw-r--r-- | usr.sbin/smtpd/delivery_maildir.c | 4 | ||||
-rw-r--r-- | usr.sbin/smtpd/lka_session.c | 8 | ||||
-rw-r--r-- | usr.sbin/smtpd/parse.y | 21 | ||||
-rw-r--r-- | usr.sbin/smtpd/smtpd-defines.h | 4 | ||||
-rw-r--r-- | usr.sbin/smtpd/smtpd.conf.5 | 17 | ||||
-rw-r--r-- | usr.sbin/smtpd/smtpd.h | 4 | ||||
-rw-r--r-- | usr.sbin/smtpd/util.c | 6 |
8 files changed, 54 insertions, 21 deletions
diff --git a/usr.sbin/smtpd/aliases.c b/usr.sbin/smtpd/aliases.c index 20645878ba5..b1396512db2 100644 --- a/usr.sbin/smtpd/aliases.c +++ b/usr.sbin/smtpd/aliases.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aliases.c,v 1.70 2016/05/21 19:28:19 gilles Exp $ */ +/* $OpenBSD: aliases.c,v 1.71 2016/08/31 10:18:08 gilles Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@poolp.org> @@ -54,7 +54,7 @@ aliases_get(struct expand *expand, const char *username) xlowercase(buf, username, sizeof(buf)); /* first, check if entry has a user-part tag */ - pbuf = strchr(buf, TAG_CHAR); + pbuf = strchr(buf, *env->sc_subaddressing_delim); if (pbuf) { ret = table_lookup(mapping, NULL, buf, K_ALIAS, &lk); if (ret < 0) @@ -116,7 +116,7 @@ aliases_virtual_get(struct expand *expand, const struct mailaddr *maddr) xlowercase(domain, domain, sizeof(domain)); memset(tag, '\0', sizeof tag); - pbuf = strchr(user, TAG_CHAR); + pbuf = strchr(user, *env->sc_subaddressing_delim); if (pbuf) { if (!bsnprintf(tag, sizeof(tag), "%s", pbuf + 1)) return 0; @@ -127,7 +127,7 @@ aliases_virtual_get(struct expand *expand, const struct mailaddr *maddr) /* first, check if entry has a user-part tag */ if (tag[0]) { if (!bsnprintf(buf, sizeof(buf), "%s%c%s@%s", - user, TAG_CHAR, tag, domain)) + user, *env->sc_subaddressing_delim, tag, domain)) return 0; ret = table_lookup(mapping, NULL, buf, K_ALIAS, &lk); if (ret < 0) @@ -147,7 +147,8 @@ aliases_virtual_get(struct expand *expand, const struct mailaddr *maddr) if (tag[0]) { /* Failed ? We lookup for username + user-part tag */ - if (!bsnprintf(buf, sizeof(buf), "%s%c%s", user, TAG_CHAR, tag)) + if (!bsnprintf(buf, sizeof(buf), "%s%c%s", + user, *env->sc_subaddressing_delim, tag)) return 0; ret = table_lookup(mapping, NULL, buf, K_ALIAS, &lk); if (ret < 0) diff --git a/usr.sbin/smtpd/delivery_maildir.c b/usr.sbin/smtpd/delivery_maildir.c index 83ab82ec037..2990eb61e8d 100644 --- a/usr.sbin/smtpd/delivery_maildir.c +++ b/usr.sbin/smtpd/delivery_maildir.c @@ -1,4 +1,4 @@ -/* $OpenBSD: delivery_maildir.c,v 1.17 2015/12/28 22:08:30 jung Exp $ */ +/* $OpenBSD: delivery_maildir.c,v 1.18 2016/08/31 10:18:08 gilles Exp $ */ /* * Copyright (c) 2011 Gilles Chehade <gilles@poolp.org> @@ -55,7 +55,7 @@ mailaddr_tag(const struct mailaddr *maddr, char *dest, size_t len) char *tag; char *sanitized; - if ((tag = strchr(maddr->user, TAG_CHAR))) { + if ((tag = strchr(maddr->user, *env->sc_subaddressing_delim))) { tag++; while (*tag == '.') tag++; diff --git a/usr.sbin/smtpd/lka_session.c b/usr.sbin/smtpd/lka_session.c index 87ff4641192..e70f359df3d 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.79 2015/12/28 22:08:30 jung Exp $ */ +/* $OpenBSD: lka_session.c,v 1.80 2016/08/31 10:18:08 gilles Exp $ */ /* * Copyright (c) 2011 Gilles Chehade <gilles@poolp.org> @@ -274,7 +274,7 @@ lka_expand(struct lka_session *lks, struct rule *rule, struct expandnode *xn) int r; union lookup lk; char *tag; - + if (xn->depth >= EXPAND_DEPTH) { log_trace(TRACE_EXPAND, "expand: lka_expand: node too deep."); lks->error = LKA_PERMFAIL; @@ -378,7 +378,7 @@ lka_expand(struct lka_session *lks, struct rule *rule, struct expandnode *xn) } /* gilles+hackers@ -> gilles@ */ - if ((tag = strchr(xn->u.user, TAG_CHAR)) != NULL) + if ((tag = strchr(xn->u.user, *env->sc_subaddressing_delim)) != NULL) *tag++ = '\0'; r = table_lookup(rule->r_userbase, NULL, xn->u.user, K_USERINFO, &lk); @@ -874,7 +874,7 @@ mod_strip(char *buf, size_t len) unsigned int i; /* gilles+hackers -> gilles */ - if ((tag = strchr(buf, TAG_CHAR)) != NULL) { + if ((tag = strchr(buf, *env->sc_subaddressing_delim)) != NULL) { /* gilles+hackers@poolp.org -> gilles@poolp.org */ if ((at = strchr(tag, '@')) != NULL) { for (i = 0; i <= strlen(at); ++i) diff --git a/usr.sbin/smtpd/parse.y b/usr.sbin/smtpd/parse.y index 3cce0c75054..3d319772c28 100644 --- a/usr.sbin/smtpd/parse.y +++ b/usr.sbin/smtpd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.187 2016/08/30 21:33:58 gilles Exp $ */ +/* $OpenBSD: parse.y,v 1.188 2016/08/31 10:18:08 gilles Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@poolp.org> @@ -178,7 +178,7 @@ typedef struct { %token ACCEPT REJECT INCLUDE ERROR MDA FROM FOR SOURCE MTA PKI SCHEDULER %token ARROW AUTH TLS LOCAL VIRTUAL TAG TAGGED ALIAS FILTER KEY CA DHE %token AUTH_OPTIONAL TLS_REQUIRE USERBASE SENDER SENDERS MASK_SOURCE VERIFY FORWARDONLY RECIPIENT -%token CIPHERS RECEIVEDAUTH MASQUERADE SOCKET +%token CIPHERS RECEIVEDAUTH MASQUERADE SOCKET SUBADDRESSING_DELIM %token <v.string> STRING %token <v.number> NUMBER %type <v.table> table @@ -848,6 +848,21 @@ relay_via : opt_relay_common relay_via main : BOUNCEWARN { memset(conf->sc_bounce_warn, 0, sizeof conf->sc_bounce_warn); } bouncedelays + | SUBADDRESSING_DELIM STRING { + if (strlen($2) != 1) { + yyerror("subaddressing-delimiter must be one character"); + free($2); + YYERROR; + } + + if (isspace((int)*$2) || !isprint((int)*$2) || *$2== '@') { + yyerror("subaddressing-delimiter uses invalid character"); + free($2); + YYERROR; + } + + conf->sc_subaddressing_delim = $2; + } | QUEUE COMPRESSION { conf->sc_queue_flags |= QUEUE_COMPRESSION; } @@ -1523,6 +1538,7 @@ lookup(char *s) { "smtps", SMTPS }, { "socket", SOCKET }, { "source", SOURCE }, + { "subaddressing-delimiter", SUBADDRESSING_DELIM }, { "table", TABLE }, { "tag", TAG }, { "tagged", TAGGED }, @@ -1877,6 +1893,7 @@ parse_config(struct smtpd *x_conf, const char *filename, int opts) (void)strlcpy(conf->sc_hostname, hostname, sizeof(conf->sc_hostname)); conf->sc_maxsize = DEFAULT_MAX_BODY_SIZE; + conf->sc_subaddressing_delim = SUBADDRESSING_DELIMITER; conf->sc_tables_dict = calloc(1, sizeof(*conf->sc_tables_dict)); conf->sc_rules = calloc(1, sizeof(*conf->sc_rules)); diff --git a/usr.sbin/smtpd/smtpd-defines.h b/usr.sbin/smtpd/smtpd-defines.h index 09337bf6926..0fc459cb9a7 100644 --- a/usr.sbin/smtpd/smtpd-defines.h +++ b/usr.sbin/smtpd/smtpd-defines.h @@ -1,4 +1,4 @@ -/* $OpenBSD: smtpd-defines.h,v 1.6 2015/11/30 14:39:21 gilles Exp $ */ +/* $OpenBSD: smtpd-defines.h,v 1.7 2016/08/31 10:18:08 gilles Exp $ */ /* * Copyright (c) 2013 Gilles Chehade <gilles@poolp.org> @@ -37,7 +37,7 @@ #define SMTPD_QUEUE_GROUP "_smtpq" #define PATH_SPOOL "/var/spool/smtpd" -#define TAG_CHAR '+' +#define SUBADDRESSING_DELIMITER "+" /* sendmail compat */ diff --git a/usr.sbin/smtpd/smtpd.conf.5 b/usr.sbin/smtpd/smtpd.conf.5 index 4ff848b2846..84882b51844 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.161 2016/05/19 08:21:23 gilles Exp $ +.\" $OpenBSD: smtpd.conf.5,v 1.162 2016/08/31 10:18:08 gilles 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: May 19 2016 $ +.Dd $Mdocdate: August 31 2016 $ .Dt SMTPD.CONF 5 .Os .Sh NAME @@ -899,6 +899,19 @@ utility. .Pp Queue encryption can be used with queue compression and will always perform compression before encryption. +.It Ic subaddressing-delimiter Ar delimiter +Redefine the subaddressing delimiter from the default +.Sq + +to +.Ar delimiter . +.Pp +Any printable character valid in an email address is allowed, +but spaces and +.Sq @ . +.Pp +The first character in the user-part of an email address that matches +.Ar delimiter +is considered to be the subaddressing delimiter. .It Ic table Ar name Oo Ar type : Oc Ns Ar config Tables are used to provide additional configuration information for .Xr smtpd 8 diff --git a/usr.sbin/smtpd/smtpd.h b/usr.sbin/smtpd/smtpd.h index 45e08601151..c8bbbd0ac01 100644 --- a/usr.sbin/smtpd/smtpd.h +++ b/usr.sbin/smtpd/smtpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: smtpd.h,v 1.516 2016/07/24 16:04:53 gilles Exp $ */ +/* $OpenBSD: smtpd.h,v 1.517 2016/08/31 10:18:08 gilles Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@poolp.org> @@ -633,6 +633,8 @@ struct smtpd { char sc_enqueue_filter[PATH_MAX]; char *sc_tls_ciphers; + + char *sc_subaddressing_delim; }; #define TRACE_DEBUG 0x0001 diff --git a/usr.sbin/smtpd/util.c b/usr.sbin/smtpd/util.c index 728b1a993a6..bf2b86f3061 100644 --- a/usr.sbin/smtpd/util.c +++ b/usr.sbin/smtpd/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.127 2016/05/16 17:43:18 gilles Exp $ */ +/* $OpenBSD: util.c,v 1.128 2016/08/31 10:18:08 gilles Exp $ */ /* * Copyright (c) 2000,2001 Markus Friedl. All rights reserved. @@ -455,9 +455,9 @@ mailaddr_match(const struct mailaddr *maddr1, const struct mailaddr *maddr2) if (m2.user[0]) { /* if address from table has a tag, we must respect it */ - if (strchr(m2.user, TAG_CHAR) == NULL) { + if (strchr(m2.user, *env->sc_subaddressing_delim) == NULL) { /* otherwise, strip tag from session address if any */ - p = strchr(m1.user, TAG_CHAR); + p = strchr(m1.user, *env->sc_subaddressing_delim); if (p) *p = '\0'; } |