diff options
author | Gilles Chehade <gilles@cvs.openbsd.org> | 2009-11-03 20:55:24 +0000 |
---|---|---|
committer | Gilles Chehade <gilles@cvs.openbsd.org> | 2009-11-03 20:55:24 +0000 |
commit | 2879f4cbbd7e34b53724be947402b12e4a609c48 (patch) | |
tree | ad46fefafb80fb9cc57959c8a5cc850f348e869a /usr.sbin/smtpd/parse.y | |
parent | f1e456032facee63cf671bfe73b7c3d0eebced64 (diff) |
this commit removes the hardcoded special "aliases" map and brings support
for multiple aliases maps that can be attached at the rule level. with it,
you can for example define different aliases maps for different domains or
different aliases maps for the same domain depending on the client source:
map "localiases" { source db "/etc/mail/localiases.db" }
map "netaliases" { source db "/etc/mail/netaliases.db" }
accept from 192.168.0.0/16 for local alias "localiases" deliver to mbox
accept from all for local alias "netaliases" deliver to mbox
idea discussed with jacekm@ and various other hackers, diff contains some
bug fixes too which were not part of the original diff. man page follows
very shortly ... make clean & flush queue !
Diffstat (limited to 'usr.sbin/smtpd/parse.y')
-rw-r--r-- | usr.sbin/smtpd/parse.y | 44 |
1 files changed, 29 insertions, 15 deletions
diff --git a/usr.sbin/smtpd/parse.y b/usr.sbin/smtpd/parse.y index a9668a397ef..814cb312808 100644 --- a/usr.sbin/smtpd/parse.y +++ b/usr.sbin/smtpd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.43 2009/10/19 21:09:55 gilles Exp $ */ +/* $OpenBSD: parse.y,v 1.44 2009/11/03 20:55:23 gilles Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -119,7 +119,7 @@ typedef struct { %token DNS DB TFILE EXTERNAL DOMAIN CONFIG SOURCE %token RELAY VIA DELIVER TO MAILDIR MBOX HOSTNAME %token ACCEPT REJECT INCLUDE NETWORK ERROR MDA FROM FOR -%token ARROW ENABLE AUTH TLS LOCAL VIRTUAL USER TAG +%token ARROW ENABLE AUTH TLS LOCAL VIRTUAL USER TAG ALIAS %token <v.string> STRING %token <v.number> NUMBER %type <v.map> map @@ -127,7 +127,7 @@ typedef struct { %type <v.cond> condition %type <v.tv> interval %type <v.object> mapref -%type <v.string> certname user tag on +%type <v.string> certname user tag on alias %% @@ -385,15 +385,6 @@ map : MAP STRING { map = NULL; YYERROR; } - if (strcmp(map->m_name, "aliases") == 0 || - strcmp(map->m_name, "virtual") == 0) { - if (map->m_src != S_DB) { - yyerror("map source must be db"); - free(map); - map = NULL; - YYERROR; - } - } TAILQ_INSERT_TAIL(conf->sc_maps, map, m_entry); map = NULL; } @@ -645,6 +636,10 @@ decision : ACCEPT { $$ = 1; } | REJECT { $$ = 0; } ; +alias : ALIAS STRING { $$ = $2; } + | /* empty */ { $$ = NULL; } + ; + condition : NETWORK mapref { struct cond *c; @@ -654,8 +649,18 @@ condition : NETWORK mapref { c->c_map = $2; $$ = c; } - | DOMAIN mapref { + | DOMAIN mapref alias { struct cond *c; + struct map *m; + + if ($3) { + if ((m = map_findbyname(conf, $3)) == NULL) { + yyerror("no such map: %s", $3); + free($3); + YYERROR; + } + rule->r_amap = m->m_id; + } if ((c = calloc(1, sizeof *c)) == NULL) fatal("out of memory"); @@ -675,18 +680,26 @@ condition : NETWORK mapref { free($2); m->m_flags |= F_USED; - if ((c = calloc(1, sizeof *c)) == NULL) fatal("out of memory"); c->c_type = C_VDOM; c->c_map = m->m_id; $$ = c; } - | LOCAL { + | LOCAL alias { struct cond *c; struct map *m; struct mapel *me; + if ($2) { + if ((m = map_findbyname(conf, $2)) == NULL) { + yyerror("no such map: %s", $2); + free($2); + YYERROR; + } + rule->r_amap = m->m_id; + } + if ((m = calloc(1, sizeof(*m))) == NULL) fatal("out of memory"); m->m_id = last_map_id++; @@ -970,6 +983,7 @@ lookup(char *s) /* this has to be sorted always */ static const struct keywords keywords[] = { { "accept", ACCEPT }, + { "alias", ALIAS }, { "all", ALL }, { "auth", AUTH }, { "certificate", CERTIFICATE }, |