aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGilles Chehade <gilles@poolp.org>2019-10-18 17:53:36 +0200
committerGitHub <noreply@github.com>2019-10-18 17:53:36 +0200
commit584e929f2ab75c2f5cf0215a16b1e6eeb1520b78 (patch)
tree61f71afc6e15aa8ea59b92d5fc7cc8d2a7323d2e
parentMerge pull request #59 from fgma/postgres-update (diff)
parentnew parameter added to manpage (diff)
downloadOpenSMTPD-extras-584e929f2ab75c2f5cf0215a16b1e6eeb1520b78.tar.xz
OpenSMTPD-extras-584e929f2ab75c2f5cf0215a16b1e6eeb1520b78.zip
Merge pull request #60 from fgma/sqlite-update
Sqlite update
-rw-r--r--extras/tables/table-sqlite/table-sqlite.59
-rw-r--r--extras/tables/table-sqlite/table_sqlite.c3
2 files changed, 12 insertions, 0 deletions
diff --git a/extras/tables/table-sqlite/table-sqlite.5 b/extras/tables/table-sqlite/table-sqlite.5
index d0963a6..8452aa8 100644
--- a/extras/tables/table-sqlite/table-sqlite.5
+++ b/extras/tables/table-sqlite/table-sqlite.5
@@ -98,6 +98,15 @@ This is used to provide a query for looking up a domain. The question mark
is replaced with the appropriate data. For the domain it would be the
right hand side of the SMTP address. This expects one VARCHAR to be returned
with a matching domain name.
+.Pp
+
+.It Xo
+.Ic query_mailaddrmap
+.Ar SQL statement
+.Xc
+This is used to provide a query for looking up a senders. The question mark
+is replaced with the appropriate data. This expects one VARCHAR to be returned
+with the address the sender is allowed to send mails from.
.El
A generic SQL statement would be something like:
diff --git a/extras/tables/table-sqlite/table_sqlite.c b/extras/tables/table-sqlite/table_sqlite.c
index 4da84f3..d5ec28b 100644
--- a/extras/tables/table-sqlite/table_sqlite.c
+++ b/extras/tables/table-sqlite/table_sqlite.c
@@ -39,6 +39,7 @@ enum {
SQL_SOURCE,
SQL_MAILADDR,
SQL_ADDRNAME,
+ SQL_MAILADDRMAP,
SQL_MAX
};
@@ -105,6 +106,7 @@ table_sqlite_update(void)
{ "query_source", 1 },
{ "query_mailaddr", 1 },
{ "query_addrname", 1 },
+ { "query_mailaddrmap", 1 },
};
sqlite3 *_db;
sqlite3_stmt *_statements[SQL_MAX];
@@ -346,6 +348,7 @@ table_sqlite_lookup(int service, struct dict *params, const char *key, char *dst
switch(service) {
case K_ALIAS:
+ case K_MAILADDRMAP:
memset(dst, 0, sz);
do {
value = sqlite3_column_text(stmt, 0);