aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGilles Chehade <gilles@poolp.org>2012-11-14 17:25:27 +0100
committerGilles Chehade <gilles@poolp.org>2012-11-14 17:25:27 +0100
commitafd43584af93f99a28dc062de2f259bfb02501b8 (patch)
tree7e5672fd478caefe1f6c327940762850c09146e2
parentMerge branch 'master' of ssh.poolp.org:/git/opensmtpd (diff)
parentMerge branch 'master' into parse_y (diff)
downloadOpenSMTPD-afd43584af93f99a28dc062de2f259bfb02501b8.tar.xz
OpenSMTPD-afd43584af93f99a28dc062de2f259bfb02501b8.zip
Merge branch 'parse_y'
-rw-r--r--smtpd/parse.y82
-rw-r--r--smtpd/smtpd.conf.5106
2 files changed, 100 insertions, 88 deletions
diff --git a/smtpd/parse.y b/smtpd/parse.y
index 52a5a192..f079bdbd 100644
--- a/smtpd/parse.y
+++ b/smtpd/parse.y
@@ -119,8 +119,8 @@ typedef struct {
%}
%token AS QUEUE COMPRESSION SIZE LISTEN ON ANY PORT EXPIRE
-%token MAP HASH LIST SINGLE SSL SMTPS CERTIFICATE
-%token DB LDAP FILE DOMAIN SOURCE
+%token TABLE HASH LIST SINGLE SSL SMTPS CERTIFICATE
+%token DB FILE DOMAIN SOURCE
%token RELAY BACKUP VIA DELIVER TO MAILDIR MBOX HOSTNAME
%token ACCEPT REJECT INCLUDE ERROR MDA FROM FOR
%token ARROW AUTH TLS LOCAL VIRTUAL TAG ALIAS FILTER KEY
@@ -130,9 +130,9 @@ typedef struct {
%type <v.map> map
%type <v.number> port from auth ssl size expire
%type <v.cond> condition
-%type <v.object> mapref
+%type <v.object> maps mapnew mapref alias
%type <v.maddr> relay_as
-%type <v.string> certname tag on alias credentials compression
+%type <v.string> certname tag on credentials compression
%%
grammar : /* empty */
@@ -437,20 +437,15 @@ mapsource : SOURCE FILE STRING {
>= sizeof(map->m_config))
err(1, "pathname too long");
}
+ | '{' mapval_list '}' { }
;
mapopt : mapsource { }
-map : MAP STRING {
+map : TABLE STRING {
map = map_create("static", $2);
free($2);
- } optlbracket mapopt optrbracket {
- if (!strcmp(map->m_src, "static")) {
- yyerror("map %s has no source defined", $2);
- free(map);
- map = NULL;
- YYERROR;
- }
+ } mapopt {
map = NULL;
}
;
@@ -476,24 +471,25 @@ string_list : stringel
| stringel comma string_list
;
-mapref : STRING {
+mapval_list : string_list { }
+ | keyval_list { }
+ ;
+
+mapnew : STRING {
struct map *m;
m = map_create("static", NULL);
map_add(m, $1, NULL);
$$ = m->m_id;
}
- | '(' {
- map = map_create("static", NULL);
- } string_list ')' {
- $$ = map->m_id;
- }
| '{' {
map = map_create("static", NULL);
- } keyval_list '}' {
+ } mapval_list '}' {
$$ = map->m_id;
}
- | MAP STRING {
+ ;
+
+mapref : '<' STRING '>' {
struct map *m;
if ((m = map_findbyname($2)) == NULL) {
@@ -506,29 +502,25 @@ mapref : STRING {
}
;
-alias : ALIAS STRING { $$ = $2; }
- | /* empty */ { $$ = NULL; }
+maps : mapnew { $$ = $1; }
+ | mapref { $$ = $1; }
;
-condition : DOMAIN mapref alias {
+alias : ALIAS mapref { $$ = $2; }
+ | /* empty */ { $$ = 0; }
+ ;
+
+condition : DOMAIN maps alias {
struct cond *c;
- struct map *m;
- if ($3) {
- if ((m = map_findbyname($3)) == NULL) {
- yyerror("no such map: %s", $3);
- free($3);
- YYERROR;
- }
- rule->r_amap = m->m_id;
- }
+ rule->r_amap = $3;
c = xcalloc(1, sizeof *c, "parse condition: DOMAIN");
c->c_type = COND_DOM;
c->c_map = $2;
$$ = c;
}
- | VIRTUAL mapref {
+ | VIRTUAL maps {
struct cond *c;
struct map *m;
@@ -553,14 +545,7 @@ condition : DOMAIN mapref alias {
YYERROR;
}
- if ($2) {
- if ((m = map_findbyname($2)) == NULL) {
- yyerror("no such map: %s", $2);
- free($2);
- YYERROR;
- }
- rule->r_amap = m->m_id;
- }
+ rule->r_amap = $2;
m = map_create("static", NULL);
map_add(m, "localhost", NULL);
@@ -574,19 +559,11 @@ condition : DOMAIN mapref alias {
}
| ANY alias {
struct cond *c;
- struct map *m;
c = xcalloc(1, sizeof *c, "parse condition: ANY");
c->c_type = COND_ANY;
- if ($2) {
- if ((m = map_findbyname($2)) == NULL) {
- yyerror("no such map: %s", $2);
- free($2);
- YYERROR;
- }
- rule->r_amap = m->m_id;
- }
+ rule->r_amap = $2;
$$ = c;
}
;
@@ -760,7 +737,7 @@ action : DELIVER TO MAILDIR {
}
;
-from : FROM mapref {
+from : FROM maps {
$$ = $2;
}
| FROM ANY {
@@ -927,12 +904,10 @@ lookup(char *s)
{ "hostname", HOSTNAME },
{ "include", INCLUDE },
{ "key", KEY },
- { "ldap", LDAP },
{ "list", LIST },
{ "listen", LISTEN },
{ "local", LOCAL },
{ "maildir", MAILDIR },
- { "map", MAP },
{ "mbox", MBOX },
{ "mda", MDA },
{ "on", ON },
@@ -946,6 +921,7 @@ lookup(char *s)
{ "smtps", SMTPS },
{ "source", SOURCE },
{ "ssl", SSL },
+ { "table", TABLE },
{ "tag", TAG },
{ "tls", TLS },
{ "tls-require", TLS_REQUIRE },
diff --git a/smtpd/smtpd.conf.5 b/smtpd/smtpd.conf.5
index d8710fc9..4ef20a18 100644
--- a/smtpd/smtpd.conf.5
+++ b/smtpd/smtpd.conf.5
@@ -180,40 +180,72 @@ untrusted senders and outgoing mail from authenticated users in
situations where it is not possible to listen on the submission
port.
.It Xo
-.Ic map Ar map
-.Ic source Ar type Ar source
+.Ic table Ar name
+.Ic Op backend Ar type
+.Ar config
.Xc
-Maps are used to provide additional configuration information for
-.Xr smtpd 8 .
+Tables are used to provide additional configuration information for
+.Xr smtpd 8
+in the form of lists or key-value mappings.
.Pp
-The map is identified using map name
-.Ar map ;
+The table is identified using table name
+.Ar name ;
the name itself is arbitrarily chosen.
.Pp
.Ar type
-specifies the file format,
+specifies the table backend,
and should be one of the following:
.Pp
.Bl -tag -width "fileXXX" -compact
.It db
-Mappings are stored in a file created using
+Information is stored in a file created using
.Xr makemap 8 .
-This is the default type if none is specified.
.It plain
-Mappings are stored in a plain text file using the
+Information is stored in a plain text file using the
same format as used to generate
.Xr makemap 8
mappings.
This is the default.
.El
.Pp
-.Ar source
-specifies the source of the map data.
+.Ar config
+specifies a configuration file for the table data.
It must be an absolute path to a file for the
.Dq file
and
.Dq db
-map types.
+table types.
+
+.It Xo
+.Ic table Ar name
+.Ic { Ar value
+.Op , Ar value_n
+.Ic }
+.Xc
+Tables containing list of static values may be declared using an inlined notation.
+.Pp
+The table is identified using table name
+.Ar name ;
+the name itself is arbitrarily chosen.
+.Pp
+The table must contain at least one value and may declare many values as a list of
+comma separated strings.
+.It Xo
+.Ic table Ar name
+.Ic { Ar key => value
+.Op , key_n => value_n
+.Ic }
+.Xc
+Tables containing static key-value mappings may be declared using an inlined notation.
+.Pp
+The table is identified using table name
+.Ar name ;
+the name itself is arbitrarily chosen.
+.Pp
+The table must contain at least one key-value mapping and may declare many mappings as
+a list of comma separated
+.Ar key => value
+descriptions.
.It Ic size Ar n
Specify a maximum message size of
.Ar n
@@ -255,21 +287,25 @@ and may be omitted.
The rule matches if the connection is made from the specified
.Ar network ,
specified in CIDR notation.
+.It Ic from Ar <table>
+The rule matches if the connection is made from a client whose address
+is declared in the table
+.Ar table .
.El
.Pp
Next comes the selection based on the domain the message is sent to:
.Bl -tag -width Ds
.It Xo
.Ic for any
-.Op Ic alias Ar aliases
+.Op Ic alias Ar <aliases>
.Xc
Make the rule match regardless of the domain it is sent to.
-If specified,
+If specified, the table
.Ar aliases
is used for looking up alternative destinations for all addresses.
.It Xo
.Ic for domain Ar domain
-.Op Ic alias Ar aliases
+.Op Ic alias Ar <aliases>
.Xc
This rule applies to mail destined for the specified
.Ar domain .
@@ -281,35 +317,35 @@ so that a single rule for all sub-domains can be used, for example:
accept for domain "*.example.com" deliver to mbox
.Ed
.Pp
-If specified,
+If specified, the table
.Ar aliases
is used for looking up alternative destinations for addresses in this
.Ar domain .
.It Xo
-.Ic for domain map Ar domains
-.Op Ic alias Ar aliases
+.Ic for domain Ar <domains>
+.Op Ic alias Ar <aliases>
.Xc
-This rule applies to mail destined to domains which are part of the map
+This rule applies to mail destined to domains which are part of the table
.Ar domains .
.Pp
-If specified,
+If specified, the table
.Ar aliases
is used for looking up alternative destinations for addresses in these
.Ar domains .
.It Xo
.Ic for local
-.Op Ic alias Ar map
+.Op Ic alias Ar <aliases>
.Xc
This rule applies to mail destined to
.Dq localhost
and to the server's fully qualified domain name,
as returned by
.Xr hostname 1 .
-.It Ic for virtual map Ar vmap
+.It Ic for virtual Ar <vdomains>
This rule applies to mail destined for the virtual domains specified
-in the map
-.Ar vmap .
-For an example of how to configure a virtual map, see
+in the table
+.Ar vdomains .
+For an example of how to configure a virtual table, see
.Xr makemap 8 .
.El
.Pp
@@ -367,7 +403,7 @@ respectively.
.Ic relay via
.Ar host
.Op Ic certificate Ar name
-.Op Ic auth Ar map
+.Op Ic auth Ar <auth>
.Op Ic as Ar address
.Xc
Mail is relayed through the specified
@@ -414,8 +450,8 @@ If an SMTPAUTH session with
is desired, the
.Ic auth
parameter is used to specify the
-.Ar map
-that holds the credentials.
+.Ar auth
+table that holds the credentials.
.Pp
If the
.Ic as
@@ -467,10 +503,10 @@ A secrets file is needed to specify a username and password:
would look like this:
.Bd -literal -offset indent
listen on lo0
-map aliases source db "/etc/mail/aliases.db"
-map secrets source db "/etc/mail/secrets.db"
-accept for local alias aliases deliver to mbox
-accept for any relay via tls+auth://smtp.example.com auth secrets
+table aliases backend db "/etc/mail/aliases.db"
+table secrets backend db "/etc/mail/secrets.db"
+accept for local alias <aliases> deliver to mbox
+accept for any relay via tls+auth://smtp.example.com auth <secrets>
.Ed
.Pp
In this second example,
@@ -493,8 +529,8 @@ The configuration file would look like this:
.Bd -literal -offset indent
listen on lo0
listen on egress tls certificate mail.example.com auth
-map aliases source db "/etc/mail/aliases.db"
-accept for local deliver to mda "/path/to/mda -f -"
+table aliases backend db "/etc/mail/aliases.db"
+accept for local alias <aliases> deliver to mda "/path/to/mda -f -"
accept from any for domain example.org \e
deliver to mda "/path/to/mda -f -"
accept for any relay