diff options
author | Gilles Chehade <gilles@poolp.org> | 2019-10-17 13:11:50 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-17 13:11:50 +0200 |
commit | 5d1580b93daa1f18d2a4994c6f20380917d47fff (patch) | |
tree | a623188c8899f5df720a1b4538f7b0cfbf42c21f | |
parent | Merge pull request #57 from jdelic/upstream-pr/automake-16 (diff) | |
parent | new parameter added to manpage (diff) | |
download | OpenSMTPD-extras-5d1580b93daa1f18d2a4994c6f20380917d47fff.tar.xz OpenSMTPD-extras-5d1580b93daa1f18d2a4994c6f20380917d47fff.zip |
Merge pull request #59 from fgma/postgres-update
support for mailaddrmap lookups in table-postgres
-rw-r--r-- | extras/tables/table-postgres/table-postgres.5 | 9 | ||||
-rw-r--r-- | extras/tables/table-postgres/table_postgres.c | 3 |
2 files changed, 12 insertions, 0 deletions
diff --git a/extras/tables/table-postgres/table-postgres.5 b/extras/tables/table-postgres/table-postgres.5 index 705bd39..968d4cc 100644 --- a/extras/tables/table-postgres/table-postgres.5 +++ b/extras/tables/table-postgres/table-postgres.5 @@ -104,6 +104,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 to look up 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-postgres/table_postgres.c b/extras/tables/table-postgres/table_postgres.c index 9385c5b..e1aa613 100644 --- a/extras/tables/table-postgres/table_postgres.c +++ b/extras/tables/table-postgres/table_postgres.c @@ -40,6 +40,7 @@ enum { SQL_SOURCE, SQL_MAILADDR, SQL_ADDRNAME, + SQL_MAILADDRMAP, SQL_MAX }; @@ -234,6 +235,7 @@ config_connect(struct config *conf) { "query_source", 1 }, { "query_mailaddr", 1 }, { "query_addrname", 1 }, + { "query_mailaddrmap", 1 }, }; size_t i; char *conninfo, *q; @@ -381,6 +383,7 @@ table_postgres_lookup(int service, struct dict *params, const char *key, char *d r = 1; switch(service) { case K_ALIAS: + case K_MAILADDRMAP: memset(dst, 0, sz); for (i = 0; i < PQntuples(res); i++) { if (dst[0] && strlcat(dst, ", ", sz) >= sz) { |