-/* $OpenBSD: aliases.c,v 1.73 2018/06/16 19:41:26 gilles Exp $ */
+/* $OpenBSD: aliases.c,v 1.74 2018/12/26 14:15:12 eric Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@poolp.org>
/* first, check if entry has a user-part tag */
pbuf = strchr(buf, *env->sc_subaddressing_delim);
if (pbuf) {
- ret = table_lookup(mapping, NULL, buf, K_ALIAS, &lk);
+ ret = table_lookup(mapping, buf, K_ALIAS, &lk);
if (ret < 0)
return (-1);
if (ret)
}
/* no user-part tag, try looking up user */
- ret = table_lookup(mapping, NULL, buf, K_ALIAS, &lk);
+ ret = table_lookup(mapping, buf, K_ALIAS, &lk);
if (ret <= 0)
return ret;
if (!bsnprintf(buf, sizeof(buf), "%s%c%s@%s",
user, *env->sc_subaddressing_delim, tag, domain))
return 0;
- ret = table_lookup(mapping, NULL, buf, K_ALIAS, &lk);
+ ret = table_lookup(mapping, buf, K_ALIAS, &lk);
if (ret < 0)
return (-1);
if (ret)
/* then, check if entry exists without user-part tag */
if (!bsnprintf(buf, sizeof(buf), "%s@%s", user, domain))
return 0;
- ret = table_lookup(mapping, NULL, buf, K_ALIAS, &lk);
+ ret = table_lookup(mapping, buf, K_ALIAS, &lk);
if (ret < 0)
return (-1);
if (ret)
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);
+ ret = table_lookup(mapping, buf, K_ALIAS, &lk);
if (ret < 0)
return (-1);
if (ret)
/* Failed ? We lookup for username only */
if (!bsnprintf(buf, sizeof(buf), "%s", user))
return 0;
- ret = table_lookup(mapping, NULL, buf, K_ALIAS, &lk);
+ ret = table_lookup(mapping, buf, K_ALIAS, &lk);
if (ret < 0)
return (-1);
if (ret)
if (!bsnprintf(buf, sizeof(buf), "@%s", domain))
return 0;
/* Failed ? We lookup for catch all for virtual domain */
- ret = table_lookup(mapping, NULL, buf, K_ALIAS, &lk);
+ ret = table_lookup(mapping, buf, K_ALIAS, &lk);
if (ret < 0)
return (-1);
if (ret)
goto expand;
/* Failed ? We lookup for a *global* catch all */
- ret = table_lookup(mapping, NULL, "@", K_ALIAS, &lk);
+ ret = table_lookup(mapping, "@", K_ALIAS, &lk);
if (ret <= 0)
return (ret);
-/* $OpenBSD: lka.c,v 1.229 2018/12/23 16:37:53 eric Exp $ */
+/* $OpenBSD: lka.c,v 1.230 2018/12/26 14:15:12 eric Exp $ */
/*
* Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org>
m_add_int(p, LKA_TEMPFAIL);
}
else {
- ret = table_fetch(table, NULL, K_SOURCE, &lk);
+ ret = table_fetch(table, K_SOURCE, &lk);
if (ret == -1)
m_add_int(p, LKA_TEMPFAIL);
else if (ret == 0)
m_add_int(p, LKA_TEMPFAIL);
}
else {
- ret = table_fetch(table, NULL, K_RELAYHOST, &lk);
+ ret = table_fetch(table, K_RELAYHOST, &lk);
if (ret == -1)
m_add_int(p, LKA_TEMPFAIL);
else if (ret == 0)
return (LKA_TEMPFAIL);
}
- switch (table_lookup(table, NULL, user, K_CREDENTIALS, &lk)) {
+ switch (table_lookup(table, user, K_CREDENTIALS, &lk)) {
case -1:
log_warnx("warn: user credentials lookup fail for %s:%s",
tablename, user);
dst[0] = '\0';
- switch (table_lookup(table, NULL, label, K_CREDENTIALS, &lk)) {
+ switch (table_lookup(table, label, K_CREDENTIALS, &lk)) {
case -1:
log_warnx("warn: credentials lookup fail for %s:%s",
tablename, label);
return (LKA_TEMPFAIL);
}
- switch (table_lookup(table, NULL, username, K_USERINFO, &lk)) {
+ switch (table_lookup(table, username, K_USERINFO, &lk)) {
case -1:
log_warnx("warn: failure during userinfo lookup %s:%s",
tablename, username);
return (LKA_TEMPFAIL);
}
- switch (table_lookup(table, NULL, source, K_ADDRNAME, &lk)) {
+ switch (table_lookup(table, source, K_ADDRNAME, &lk)) {
case -1:
log_warnx("warn: failure during helo lookup %s:%s",
tablename, source);
return (LKA_TEMPFAIL);
}
- switch (table_lookup(table, NULL, username, K_MAILADDRMAP, &lk)) {
+ switch (table_lookup(table, username, K_MAILADDRMAP, &lk)) {
case -1:
log_warnx("warn: failure during mailaddrmap lookup %s:%s",
tablename, username);
-/* $OpenBSD: lka_filter.c,v 1.31 2018/12/23 15:48:16 gilles Exp $ */
+/* $OpenBSD: lka_filter.c,v 1.32 2018/12/26 14:15:12 eric Exp $ */
/*
* Copyright (c) 2018 Gilles Chehade <gilles@poolp.org>
if (filter->config->rdns_table == NULL)
return 0;
- if (table_lookup(filter->config->rdns_table, NULL, key, kind, NULL) > 0)
+ if (table_lookup(filter->config->rdns_table, key, kind, NULL) > 0)
ret = 1;
return filter->config->not_rdns_table < 0 ? !ret : ret;
if (filter->config->rdns_regex == NULL)
return 0;
- if (table_lookup(filter->config->rdns_regex, NULL, key, K_REGEX, NULL) > 0)
+ if (table_lookup(filter->config->rdns_regex, key, K_REGEX, NULL) > 0)
ret = 1;
return filter->config->not_rdns_regex < 0 ? !ret : ret;
}
if (filter->config->src_table == NULL)
return 0;
- if (table_lookup(filter->config->src_table, NULL, key, kind, NULL) > 0)
+ if (table_lookup(filter->config->src_table, key, kind, NULL) > 0)
ret = 1;
return filter->config->not_src_table < 0 ? !ret : ret;
}
if (filter->config->src_regex == NULL)
return 0;
- if (table_lookup(filter->config->src_regex, NULL, key, K_REGEX, NULL) > 0)
+ if (table_lookup(filter->config->src_regex, key, K_REGEX, NULL) > 0)
ret = 1;
return filter->config->not_src_regex < 0 ? !ret : ret;
}
if (filter->config->helo_table == NULL)
return 0;
- if (table_lookup(filter->config->helo_table, NULL, key, kind, NULL) > 0)
+ if (table_lookup(filter->config->helo_table, key, kind, NULL) > 0)
ret = 1;
return filter->config->not_helo_table < 0 ? !ret : ret;
}
if (filter->config->helo_regex == NULL)
return 0;
- if (table_lookup(filter->config->helo_regex, NULL, key, K_REGEX, NULL) > 0)
+ if (table_lookup(filter->config->helo_regex, key, K_REGEX, NULL) > 0)
ret = 1;
return filter->config->not_helo_regex < 0 ? !ret : ret;
}
if (filter->config->mail_from_table == NULL)
return 0;
- if (table_lookup(filter->config->mail_from_table, NULL, key, kind, NULL) > 0)
+ if (table_lookup(filter->config->mail_from_table, key, kind, NULL) > 0)
ret = 1;
return filter->config->not_mail_from_table < 0 ? !ret : ret;
}
if (filter->config->mail_from_regex == NULL)
return 0;
- if (table_lookup(filter->config->mail_from_regex, NULL, key, K_REGEX, NULL) > 0)
+ if (table_lookup(filter->config->mail_from_regex, key, K_REGEX, NULL) > 0)
ret = 1;
return filter->config->not_mail_from_regex < 0 ? !ret : ret;
}
if (filter->config->rcpt_to_table == NULL)
return 0;
- if (table_lookup(filter->config->rcpt_to_table, NULL, key, kind, NULL) > 0)
+ if (table_lookup(filter->config->rcpt_to_table, key, kind, NULL) > 0)
ret = 1;
return filter->config->not_rcpt_to_table < 0 ? !ret : ret;
}
if (filter->config->rcpt_to_regex == NULL)
return 0;
- if (table_lookup(filter->config->rcpt_to_regex, NULL, key, K_REGEX, NULL) > 0)
+ if (table_lookup(filter->config->rcpt_to_regex, key, K_REGEX, NULL) > 0)
ret = 1;
return filter->config->not_rcpt_to_regex < 0 ? !ret : ret;
}
-/* $OpenBSD: lka_session.c,v 1.88 2018/11/01 18:01:51 gilles Exp $ */
+/* $OpenBSD: lka_session.c,v 1.89 2018/12/26 14:15:12 eric Exp $ */
/*
* Copyright (c) 2011 Gilles Chehade <gilles@poolp.org>
*tag++ = '\0';
userbase = table_find(env, dsp->u.local.table_userbase, NULL);
- r = table_lookup(userbase, NULL, xn->u.user, K_USERINFO, &lk);
+ r = table_lookup(userbase, xn->u.user, K_USERINFO, &lk);
if (r == -1) {
log_trace(TRACE_EXPAND, "expand: lka_expand: "
"backend error while searching user");
-/* $OpenBSD: ruleset.c,v 1.38 2018/12/22 08:54:02 gilles Exp $ */
+/* $OpenBSD: ruleset.c,v 1.39 2018/12/26 14:15:12 eric Exp $ */
/*
* Copyright (c) 2009 Gilles Chehade <gilles@poolp.org>
static int
ruleset_match_table_lookup(struct table *table, const char *key, enum table_service service)
{
- switch (table_lookup(table, NULL, key, service, NULL)) {
+ switch (table_lookup(table, key, service, NULL)) {
case 1:
return 1;
case -1:
-/* $OpenBSD: smtpd.h,v 1.604 2018/12/26 11:53:02 eric Exp $ */
+/* $OpenBSD: smtpd.h,v 1.605 2018/12/26 14:15:12 eric Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@poolp.org>
void *(*open)(struct table *);
int (*update)(struct table *);
void (*close)(void *);
- int (*lookup)(void *, struct dict *, const char *, enum table_service, char **);
- int (*fetch)(void *, struct dict *, enum table_service, char **);
+ int (*lookup)(void *, const char *, enum table_service, char **);
+ int (*fetch)(void *, enum table_service, char **);
};
int table_check_use(struct table *, uint32_t, uint32_t);
int table_check_type(struct table *, uint32_t);
int table_check_service(struct table *, uint32_t);
-int table_lookup(struct table *, struct dict *, const char *, enum table_service,
+int table_lookup(struct table *, const char *, enum table_service,
union lookup *);
-int table_fetch(struct table *, struct dict *, enum table_service, union lookup *);
+int table_fetch(struct table *, enum table_service, union lookup *);
void table_destroy(struct smtpd *, struct table *);
void table_add(struct table *, const char *, const char *);
int table_domain_match(const char *, const char *);
-/* $OpenBSD: table.c,v 1.35 2018/12/26 11:53:02 eric Exp $ */
+/* $OpenBSD: table.c,v 1.36 2018/12/26 14:15:13 eric Exp $ */
/*
* Copyright (c) 2013 Eric Faurot <eric@openbsd.org>
}
int
-table_lookup(struct table *table, struct dict *params, const char *key, enum table_service kind,
+table_lookup(struct table *table, const char *key, enum table_service kind,
union lookup *lk)
{
int r;
return -1;
}
- r = table->t_backend->lookup(table->t_handle, params, lkey, kind, lk ? &buf : NULL);
+ r = table->t_backend->lookup(table->t_handle, lkey, kind, lk ? &buf : NULL);
if (r == 1) {
log_trace(TRACE_LOOKUP, "lookup: %s \"%s\" as %s in table %s:%s -> %s%s%s",
}
int
-table_fetch(struct table *table, struct dict *params, enum table_service kind, union lookup *lk)
+table_fetch(struct table *table, enum table_service kind, union lookup *lk)
{
int r;
char *buf = NULL;
if (table->t_backend->fetch == NULL)
return (-1);
- r = table->t_backend->fetch(table->t_handle, params, kind, lk ? &buf : NULL);
+ r = table->t_backend->fetch(table->t_handle, kind, lk ? &buf : NULL);
if (r == 1) {
log_trace(TRACE_LOOKUP, "lookup: fetch %s from table %s:%s -> %s%s%s",
-/* $OpenBSD: table_db.c,v 1.12 2018/12/26 11:53:02 eric Exp $ */
+/* $OpenBSD: table_db.c,v 1.13 2018/12/26 14:15:13 eric Exp $ */
/*
* Copyright (c) 2011 Gilles Chehade <gilles@poolp.org>
static int table_db_config(struct table *);
static int table_db_update(struct table *);
static void *table_db_open(struct table *);
-static int table_db_lookup(void *, struct dict *, const char *, enum table_service, char **);
-static int table_db_fetch(void *, struct dict *, enum table_service, char **);
+static int table_db_lookup(void *, const char *, enum table_service, char **);
+static int table_db_fetch(void *, enum table_service, char **);
static void table_db_close(void *);
static char *table_db_get_entry(void *, const char *, size_t *);
}
static int
-table_db_lookup(void *hdl, struct dict *params, const char *key, enum table_service service,
+table_db_lookup(void *hdl, const char *key, enum table_service service,
char **dst)
{
struct dbhandle *handle = hdl;
}
static int
-table_db_fetch(void *hdl, struct dict *params, enum table_service service, char **dst)
+table_db_fetch(void *hdl, enum table_service service, char **dst)
{
struct dbhandle *handle = hdl;
struct table *table = handle->table;
-/* $OpenBSD: table_getpwnam.c,v 1.6 2018/12/26 11:53:02 eric Exp $ */
+/* $OpenBSD: table_getpwnam.c,v 1.7 2018/12/26 14:15:13 eric Exp $ */
/*
* Copyright (c) 2012 Gilles Chehade <gilles@poolp.org>
static int table_getpwnam_config(struct table *);
static int table_getpwnam_update(struct table *);
static void *table_getpwnam_open(struct table *);
-static int table_getpwnam_lookup(void *, struct dict *, const char *, enum table_service,
+static int table_getpwnam_lookup(void *, const char *, enum table_service,
char **);
static void table_getpwnam_close(void *);
}
static int
-table_getpwnam_lookup(void *hdl, struct dict *params, const char *key, enum table_service kind,
+table_getpwnam_lookup(void *hdl, const char *key, enum table_service kind,
char **dst)
{
struct passwd *pw;
-/* $OpenBSD: table_proc.c,v 1.9 2018/12/26 11:53:02 eric Exp $ */
+/* $OpenBSD: table_proc.c,v 1.10 2018/12/26 14:15:13 eric Exp $ */
/*
* Copyright (c) 2013 Eric Faurot <eric@openbsd.org>
}
static int
-imsg_add_params(struct ibuf *buf, struct dict *params)
+imsg_add_params(struct ibuf *buf)
{
- size_t count;
- const char *key;
- char *value;
- void *iter;
-
- count = 0;
- if (params)
- count = dict_count(params);
+ size_t count = 0;
if (imsg_add(buf, &count, sizeof(count)) == -1)
return (-1);
- if (count == 0)
- return (0);
-
- iter = NULL;
- while (dict_iter(params, &iter, &key, (void **)&value)) {
- if (imsg_add(buf, key, strlen(key) + 1) == -1)
- return (-1);
- if (imsg_add(buf, value, strlen(value) + 1) == -1)
- return (-1);
- }
-
return (0);
}
static int
-table_proc_lookup(void *arg, struct dict *params, const char *k, enum table_service s, char **dst)
+table_proc_lookup(void *arg, const char *k, enum table_service s, char **dst)
{
struct table_proc_priv *priv = arg;
struct ibuf *buf;
return (-1);
if (imsg_add(buf, &s, sizeof(s)) == -1)
return (-1);
- if (imsg_add_params(buf, params) == -1)
+ if (imsg_add_params(buf) == -1)
return (-1);
if (imsg_add(buf, k, strlen(k) + 1) == -1)
return (-1);
}
static int
-table_proc_fetch(void *arg, struct dict *params, enum table_service s, char **dst)
+table_proc_fetch(void *arg, enum table_service s, char **dst)
{
struct table_proc_priv *priv = arg;
struct ibuf *buf;
return (-1);
if (imsg_add(buf, &s, sizeof(s)) == -1)
return (-1);
- if (imsg_add_params(buf, params) == -1)
+ if (imsg_add_params(buf) == -1)
return (-1);
imsg_close(&priv->ibuf, buf);
-/* $OpenBSD: table_static.c,v 1.22 2018/12/26 11:53:02 eric Exp $ */
+/* $OpenBSD: table_static.c,v 1.23 2018/12/26 14:15:13 eric Exp $ */
/*
* Copyright (c) 2013 Eric Faurot <eric@openbsd.org>
static int table_static_config(struct table *);
static int table_static_update(struct table *);
static void *table_static_open(struct table *);
-static int table_static_lookup(void *, struct dict *, const char *,
- enum table_service, char **);
-static int table_static_fetch(void *, struct dict *, enum table_service,
+static int table_static_lookup(void *, const char *, enum table_service,
char **);
+static int table_static_fetch(void *, enum table_service, char **);
static void table_static_close(void *);
struct table_backend table_backend_static = {
}
static int
-table_static_lookup(void *hdl, struct dict *params, const char *key,
+table_static_lookup(void *hdl, const char *key,
enum table_service service, char **dst)
{
struct table *m = hdl;
}
static int
-table_static_fetch(void *hdl, struct dict *params,
- enum table_service service, char **dst)
+table_static_fetch(void *hdl, enum table_service service, char **dst)
{
struct table *t = hdl;
const char *k;