summaryrefslogtreecommitdiff
path: root/usr.sbin/smtpd
diff options
context:
space:
mode:
authorEric Faurot <eric@cvs.openbsd.org>2018-12-28 14:21:03 +0000
committerEric Faurot <eric@cvs.openbsd.org>2018-12-28 14:21:03 +0000
commit600c795e13a7163026bfae6ff00cf431e99a2b72 (patch)
tree79fb3b007dcc4721e74be387f484b4a6f585b74a /usr.sbin/smtpd
parentf36f0a3d8943186f8e65735ee022234164f48074 (diff)
type static tables on the fly when the first element is added
ok gilles@
Diffstat (limited to 'usr.sbin/smtpd')
-rw-r--r--usr.sbin/smtpd/config.c4
-rw-r--r--usr.sbin/smtpd/parse.y5
-rw-r--r--usr.sbin/smtpd/table_static.c9
3 files changed, 10 insertions, 8 deletions
diff --git a/usr.sbin/smtpd/config.c b/usr.sbin/smtpd/config.c
index 3fce648c476..8b8b857096e 100644
--- a/usr.sbin/smtpd/config.c
+++ b/usr.sbin/smtpd/config.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: config.c,v 1.48 2018/12/28 11:40:29 eric Exp $ */
+/* $OpenBSD: config.c,v 1.49 2018/12/28 14:21:02 eric Exp $ */
/*
* Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -134,7 +134,6 @@ config_default(void)
set_local(conf, conf->sc_hostname);
t = table_create(conf, "static", "<anydestination>", NULL);
- t->t_type = T_LIST;
table_add(t, "*", NULL);
hostname[strcspn(hostname, ".")] = '\0';
@@ -169,7 +168,6 @@ set_local(struct smtpd *conf, const char *hostname)
struct table *t;
t = table_create(conf, "static", "<localnames>", NULL);
- t->t_type = T_LIST;
table_add(t, "localhost", NULL);
table_add(t, hostname, NULL);
diff --git a/usr.sbin/smtpd/parse.y b/usr.sbin/smtpd/parse.y
index af69c231f26..33159dec095 100644
--- a/usr.sbin/smtpd/parse.y
+++ b/usr.sbin/smtpd/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.249 2018/12/28 11:40:29 eric Exp $ */
+/* $OpenBSD: parse.y,v 1.250 2018/12/28 14:21:02 eric Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@poolp.org>
@@ -278,7 +278,6 @@ assign : '=' | ARROW;
keyval : STRING assign STRING {
- table->t_type = T_HASH;
table_add(table, $1, $3);
free($1);
free($3);
@@ -290,7 +289,6 @@ keyval_list : keyval
;
stringel : STRING {
- table->t_type = T_LIST;
table_add(table, $1, NULL);
free($1);
}
@@ -2177,7 +2175,6 @@ tablenew : STRING {
struct table *t;
t = table_create(conf, "static", NULL, NULL);
- t->t_type = T_LIST;
table_add(t, $1, NULL);
free($1);
$$ = t;
diff --git a/usr.sbin/smtpd/table_static.c b/usr.sbin/smtpd/table_static.c
index 73c18164a42..f9519cb4ab4 100644
--- a/usr.sbin/smtpd/table_static.c
+++ b/usr.sbin/smtpd/table_static.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: table_static.c,v 1.31 2018/12/28 11:11:36 eric Exp $ */
+/* $OpenBSD: table_static.c,v 1.32 2018/12/28 14:21:02 eric Exp $ */
/*
* Copyright (c) 2013 Eric Faurot <eric@openbsd.org>
@@ -260,6 +260,13 @@ table_static_add(struct table *table, const char *key, const char *val)
if (*table->t_config)
return 0;
+ if (table->t_type == T_NONE)
+ table->t_type = val ? T_HASH : T_LIST;
+ else if (table->t_type == T_LIST && val)
+ return 0;
+ else if (table->t_type == T_HASH && val == NULL)
+ return 0;
+
if (priv == NULL) {
if (table_static_config(table) == 0)
return 0;