aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGilles Chehade <gilles@poolp.org>2019-10-18 20:53:30 +0200
committerGitHub <noreply@github.com>2019-10-18 20:53:30 +0200
commit36cc59596e7aa7d5dfb404f78e8711dc77277a82 (patch)
tree16d474138a16d6cb05ef2a6f71a2395002141199
parentUpdate README.md (diff)
parentnew parameter added to manpage (diff)
downloadOpenSMTPD-extras-36cc59596e7aa7d5dfb404f78e8711dc77277a82.tar.xz
OpenSMTPD-extras-36cc59596e7aa7d5dfb404f78e8711dc77277a82.zip
Merge pull request #61 from fgma/mysql-update6.6.0
support for mailaddrmap lookups in table-mysql
-rw-r--r--extras/tables/table-mysql/table-mysql.59
-rw-r--r--extras/tables/table-mysql/table_mysql.c3
2 files changed, 12 insertions, 0 deletions
diff --git a/extras/tables/table-mysql/table-mysql.5 b/extras/tables/table-mysql/table-mysql.5
index 157be90..3ed0da5 100644
--- a/extras/tables/table-mysql/table-mysql.5
+++ b/extras/tables/table-mysql/table-mysql.5
@@ -129,6 +129,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-mysql/table_mysql.c b/extras/tables/table-mysql/table_mysql.c
index 2c32060..a58fdf1 100644
--- a/extras/tables/table-mysql/table_mysql.c
+++ b/extras/tables/table-mysql/table_mysql.c
@@ -41,6 +41,7 @@ enum {
SQL_SOURCE,
SQL_MAILADDR,
SQL_ADDRNAME,
+ SQL_MAILADDRMAP,
SQL_MAX
};
@@ -240,6 +241,7 @@ config_connect(struct config *conf)
{ "query_source", 1 },
{ "query_mailaddr", 1 },
{ "query_addrname", 1 },
+ { "query_mailaddrmap", 1 },
};
my_bool reconn;
size_t i;
@@ -435,6 +437,7 @@ table_mysql_lookup(int service, struct dict *params, const char *key, char *dst,
switch(service) {
case K_ALIAS:
+ case K_MAILADDRMAP:
memset(dst, 0, sz);
do {
if (dst[0] && strlcat(dst, ", ", sz) >= sz) {