now that static tables handle their updates internally.
ok gilles@
-/* $OpenBSD: aliases.c,v 1.75 2018/12/26 20:13:43 eric Exp $ */
+/* $OpenBSD: aliases.c,v 1.76 2018/12/28 11:40:29 eric Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@poolp.org>
char *pbuf;
dsp = dict_xget(env->sc_dispatchers, expand->rule->dispatcher);
- userbase = table_find(env, dsp->u.local.table_userbase, NULL);
- mapping = table_find(env, dsp->u.local.table_alias, NULL);
+ userbase = table_find(env, dsp->u.local.table_userbase);
+ mapping = table_find(env, dsp->u.local.table_alias);
xlowercase(buf, username, sizeof(buf));
struct table *userbase = NULL;
dsp = dict_xget(env->sc_dispatchers, expand->rule->dispatcher);
- userbase = table_find(env, dsp->u.local.table_userbase, NULL);
- mapping = table_find(env, dsp->u.local.table_virtual, NULL);
+ userbase = table_find(env, dsp->u.local.table_userbase);
+ mapping = table_find(env, dsp->u.local.table_virtual);
if (!bsnprintf(user, sizeof(user), "%s", maddr->user))
return 0;
-/* $OpenBSD: config.c,v 1.47 2018/12/21 14:33:52 gilles Exp $ */
+/* $OpenBSD: config.c,v 1.48 2018/12/28 11:40:29 eric Exp $ */
/*
* Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org>
*/
set_local(conf, conf->sc_hostname);
- t = table_create(conf, "static", "<anydestination>", NULL, NULL);
+ t = table_create(conf, "static", "<anydestination>", NULL);
t->t_type = T_LIST;
table_add(t, "*", NULL);
if (strcmp(conf->sc_hostname, hostname) != 0)
table_add(t, hostname, NULL);
- table_create(conf, "getpwnam", "<getpwnam>", NULL, NULL);
+ table_create(conf, "getpwnam", "<getpwnam>", NULL);
return conf;
{
struct table *t;
- t = table_create(conf, "static", "<localnames>", NULL, NULL);
+ t = table_create(conf, "static", "<localnames>", NULL);
t->t_type = T_LIST;
table_add(t, "localhost", NULL);
table_add(t, hostname, NULL);
struct table *t;
char buf[NI_MAXHOST + 5];
- t = table_create(conf, "static", "<anyhost>", NULL, NULL);
+ t = table_create(conf, "static", "<anyhost>", NULL);
table_add(t, "local", NULL);
table_add(t, "0.0.0.0/0", NULL);
table_add(t, "::/0", NULL);
if (getifaddrs(&ifap) == -1)
fatal("getifaddrs");
- t = table_create(conf, "static", "<localhost>", NULL, NULL);
+ t = table_create(conf, "static", "<localhost>", NULL);
table_add(t, "local", NULL);
for (p = ifap; p != NULL; p = p->ifa_next) {
-/* $OpenBSD: lka.c,v 1.231 2018/12/26 20:13:43 eric Exp $ */
+/* $OpenBSD: lka.c,v 1.232 2018/12/28 11:40:29 eric Exp $ */
/*
* Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org>
m_get_string(&m, &tablename);
m_end(&m);
- table = table_find(env, tablename, NULL);
+ table = table_find(env, tablename);
m_create(p, IMSG_MTA_LOOKUP_SOURCE, 0, 0, -1);
m_add_id(p, reqid);
m_get_string(&m, &tablename);
m_end(&m);
- table = table_find(env, tablename, NULL);
+ table = table_find(env, tablename);
m_create(p, IMSG_MTA_LOOKUP_SMARTHOST, 0, 0, -1);
m_add_id(p, reqid);
case IMSG_CTL_UPDATE_TABLE:
ret = 0;
- table = table_find(env, imsg->data, NULL);
+ table = table_find(env, imsg->data);
if (table == NULL) {
log_warnx("warn: Lookup table not found: "
"\"%s\"", (char *)imsg->data);
union lookup lk;
log_debug("debug: lka: authenticating for %s:%s", tablename, user);
- table = table_find(env, tablename, NULL);
+ table = table_find(env, tablename);
if (table == NULL) {
log_warnx("warn: could not find table %s needed for authentication",
tablename);
char *buf;
int buflen, r;
- table = table_find(env, tablename, NULL);
+ table = table_find(env, tablename);
if (table == NULL) {
log_warnx("warn: credentials table %s missing", tablename);
return (LKA_TEMPFAIL);
union lookup lk;
log_debug("debug: lka: userinfo %s:%s", tablename, username);
- table = table_find(env, tablename, NULL);
+ table = table_find(env, tablename);
if (table == NULL) {
log_warnx("warn: cannot find user table %s", tablename);
return (LKA_TEMPFAIL);
source = sa_to_text(sa);
log_debug("debug: lka: helo %s:%s", tablename, source);
- table = table_find(env, tablename, NULL);
+ table = table_find(env, tablename);
if (table == NULL) {
log_warnx("warn: cannot find helo table %s", tablename);
return (LKA_TEMPFAIL);
int found;
log_debug("debug: lka: mailaddrmap %s:%s", tablename, username);
- table = table_find(env, tablename, NULL);
+ table = table_find(env, tablename);
if (table == NULL) {
log_warnx("warn: cannot find mailaddrmap table %s", tablename);
return (LKA_TEMPFAIL);
-/* $OpenBSD: lka_session.c,v 1.91 2018/12/27 15:41:50 gilles Exp $ */
+/* $OpenBSD: lka_session.c,v 1.92 2018/12/28 11:40:29 eric Exp $ */
/*
* Copyright (c) 2011 Gilles Chehade <gilles@poolp.org>
(void)strlcpy(xn->subaddress, tag, sizeof xn->subaddress);
}
- userbase = table_find(env, dsp->u.local.table_userbase, NULL);
+ userbase = table_find(env, dsp->u.local.table_userbase);
r = table_lookup(userbase, K_USERINFO, xn->u.user, &lk);
if (r == -1) {
log_trace(TRACE_EXPAND, "expand: lka_expand: "
-/* $OpenBSD: makemap.c,v 1.71 2018/07/03 01:34:43 mortimer Exp $ */
+/* $OpenBSD: makemap.c,v 1.72 2018/12/28 11:40:29 eric Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@poolp.org>
if (parse_config(env, cfgpath, 0))
exit(1);
- table = table_find(env, "aliases", NULL);
+ table = table_find(env, "aliases");
if (table == NULL)
return (PATH_ALIASES);
-/* $OpenBSD: parse.y,v 1.248 2018/12/23 15:49:04 gilles Exp $ */
+/* $OpenBSD: parse.y,v 1.249 2018/12/28 11:40:29 eric Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@poolp.org>
rule->flag_from_socket = 1;
}
| negation FROM LOCAL {
- struct table *t = table_find(conf, "<localhost>", NULL);
+ struct table *t = table_find(conf, "<localhost>");
if (rule->flag_from) {
yyerror("from already specified for this rule");
rule->table_from = strdup(t->t_name);
}
| negation FROM ANY {
- struct table *t = table_find(conf, "<anyhost>", NULL);
+ struct table *t = table_find(conf, "<anyhost>");
if (rule->flag_from) {
yyerror("from already specified for this rule");
| negation FOR LOCAL {
- struct table *t = table_find(conf, "<localnames>", NULL);
+ struct table *t = table_find(conf, "<localnames>");
if (rule->flag_for) {
yyerror("for already specified for this rule");
rule->table_for = strdup(t->t_name);
}
| negation FOR ANY {
- struct table *t = table_find(conf, "<anydestination>", NULL);
+ struct table *t = table_find(conf, "<anydestination>");
if (rule->flag_for) {
yyerror("for already specified for this rule");
free($3);
YYERROR;
}
- table = table_create(conf, backend, $2, NULL, config);
+ table = table_create(conf, backend, $2, config);
if (!table_config(table)) {
yyerror("invalid configuration file %s for table %s",
config, table->t_name);
free($3);
}
| TABLE STRING {
- table = table_create(conf, "static", $2, NULL, NULL);
+ table = table_create(conf, "static", $2, NULL);
free($2);
} '{' tableval_list '}' {
table = NULL;
tablenew : STRING {
struct table *t;
- t = table_create(conf, "static", NULL, NULL, NULL);
+ t = table_create(conf, "static", NULL, NULL);
t->t_type = T_LIST;
table_add(t, $1, NULL);
free($1);
$$ = t;
}
| '{' {
- table = table_create(conf, "static", NULL, NULL, NULL);
+ table = table_create(conf, "static", NULL, NULL);
} tableval_list '}' {
$$ = table;
table = NULL;
tableref : '<' STRING '>' {
struct table *t;
- if ((t = table_find(conf, $2, NULL)) == NULL) {
+ if ((t = table_find(conf, $2)) == NULL) {
yyerror("no such table: %s", $2);
free($2);
YYERROR;
-/* $OpenBSD: ruleset.c,v 1.41 2018/12/26 17:37:15 eric Exp $ */
+/* $OpenBSD: ruleset.c,v 1.42 2018/12/28 11:40:29 eric Exp $ */
/*
* Copyright (c) 2009 Gilles Chehade <gilles@poolp.org>
if (r->flag_tag_regex)
service = K_REGEX;
- table = table_find(env, r->table_tag, NULL);
+ table = table_find(env, r->table_tag);
ret = table_match(table, service, evp->tag);
return MATCH_RESULT(ret, r->flag_tag);
if (r->flag_from_regex)
service = K_REGEX;
- table = table_find(env, r->table_from, NULL);
+ table = table_find(env, r->table_from);
ret = table_match(table, service, key);
return MATCH_RESULT(ret, r->flag_from);
if (r->flag_for_regex)
service = K_REGEX;
- table = table_find(env, r->table_for, NULL);
+ table = table_find(env, r->table_for);
ret = table_match(table, service, evp->dest.domain);
return MATCH_RESULT(ret, r->flag_for);
if (r->flag_smtp_helo_regex)
service = K_REGEX;
- table = table_find(env, r->table_smtp_helo, NULL);
+ table = table_find(env, r->table_smtp_helo);
ret = table_match(table, service, evp->helo);
return MATCH_RESULT(ret, r->flag_smtp_helo);
else if (r->table_smtp_auth) {
/* XXX - not until smtp_session->username is added to envelope */
/*
- * table = table_find(m->from_table, NULL);
+ * table = table_find(m->from_table);
* key = evp->username;
* return table_match(table, K_CREDENTIALS, key);
*/
if ((key = mailaddr_to_text(&evp->sender)) == NULL)
return -1;
- table = table_find(env, r->table_smtp_mail_from, NULL);
+ table = table_find(env, r->table_smtp_mail_from);
ret = table_match(table, service, key);
return MATCH_RESULT(ret, r->flag_smtp_mail_from);
if ((key = mailaddr_to_text(&evp->dest)) == NULL)
return -1;
- table = table_find(env, r->table_smtp_rcpt_to, NULL);
+ table = table_find(env, r->table_smtp_rcpt_to);
ret = table_match(table, service, key);
return MATCH_RESULT(ret, r->flag_smtp_rcpt_to);
-/* $OpenBSD: smtpd.h,v 1.613 2018/12/28 11:13:58 eric Exp $ */
+/* $OpenBSD: smtpd.h,v 1.614 2018/12/28 11:40:29 eric Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@poolp.org>
/* table.c */
-struct table *table_find(struct smtpd *, const char *, const char *);
-struct table *table_create(struct smtpd *, const char *, const char *, const char *,
+struct table *table_find(struct smtpd *, const char *);
+struct table *table_create(struct smtpd *, const char *, const char *,
const char *);
int table_config(struct table *);
int table_open(struct table *);
-/* $OpenBSD: table.c,v 1.44 2018/12/28 11:13:58 eric Exp $ */
+/* $OpenBSD: table.c,v 1.45 2018/12/28 11:40:29 eric Exp $ */
/*
* Copyright (c) 2013 Eric Faurot <eric@openbsd.org>
}
struct table *
-table_find(struct smtpd *conf, const char *name, const char *tag)
+table_find(struct smtpd *conf, const char *name)
{
- char buf[LINE_MAX];
-
- if (tag == NULL)
- return dict_get(conf->sc_tables_dict, name);
-
- if ((size_t)snprintf(buf, sizeof(buf), "%s#%s", name, tag) >= sizeof(buf)) {
- log_warnx("warn: table name too long: %s#%s", name, tag);
- return (NULL);
- }
-
- return dict_get(conf->sc_tables_dict, buf);
+ return dict_get(conf->sc_tables_dict, name);
}
int
}
struct table *
-table_create(struct smtpd *conf, const char *backend, const char *name, const char *tag,
+table_create(struct smtpd *conf, const char *backend, const char *name,
const char *config)
{
struct table *t;
struct table_backend *tb;
- char buf[LINE_MAX];
char path[LINE_MAX];
size_t n;
struct stat sb;
- if (name && tag) {
- if ((size_t)snprintf(buf, sizeof(buf), "%s#%s", name, tag) >=
- sizeof(buf))
- fatalx("table_create: name too long \"%s#%s\"",
- name, tag);
- name = buf;
- }
-
- if (name && table_find(conf, name, NULL))
+ if (name && table_find(conf, name))
fatalx("table_create: table \"%s\" already defined", name);
if ((tb = table_backend_lookup(backend)) == NULL) {