From fef3bc167b2e9f22011f874a61bac7f89cf857bd Mon Sep 17 00:00:00 2001
From: Wietse Venema Once you have local files working properly you can follow the
-instructions in ldap_table(5), mysql_table(5) or pgsql_table(5)
+instructions in ldap_table(5), mysql_table(5), pgsql_table(5)
+or sqlite_table(5)
and replace local file lookups with LDAP or SQL lookups. When you
do this, you should use the postmap(1) command again, to verify
that database lookups still produce the exact same results as local
@@ -358,6 +359,11 @@ created with the postmap(1) or
+ The Postfix sqlite map type allows you to hook up Postfix to a
+SQLite database. This implementation allows for multiple sqlite
+databases: you can use one for a virtual(5) table, one for an
+access(5) table, and one for an aliases(5) table if you want. The Postfix SQLite client utilizes the sqlite3 library,
+which can be obtained from: In order to build Postfix with sqlite map support, you will need to add
+-DHAS_SQLITE and -I for the directory containing the sqlite headers, and
+the sqlite3 library to AUXLIBS, for example: Then, just run 'make'. Once Postfix is built with sqlite support, you can specify a
+map type in main.cf like this: The file /etc/postfix/sqlite-aliases.cf specifies lots of
+information telling Postfix how to reference the sqlite database.
+For a complete description, see the sqlite_table(5) manual page. The SQLite configuration interface setup allows for multiple
+sqlite databases: you can use one for a virtual table, one for an
+access table, and one for an aliases table if you want. Mailing list support
+ SASL authentication SASL_README
Postfix 1.0
+
SQLite database SQLITE_README Postfix
+2.8
diff --git a/postfix/html/Makefile.in b/postfix/html/Makefile.in
index e1d73f93a..cf439d3b6 100644
--- a/postfix/html/Makefile.in
+++ b/postfix/html/Makefile.in
@@ -21,7 +21,7 @@ CONFIG = access.5.html aliases.5.html canonical.5.html relocated.5.html \
cidr_table.5.html tcp_table.5.html header_checks.5.html \
ldap_table.5.html mysql_table.5.html pgsql_table.5.html \
master.5.html nisplus_table.5.html generic.5.html bounce.5.html \
- postfix-wrapper.5.html
+ postfix-wrapper.5.html sqlite_table.5.html
OTHER = postfix-manuals.html
AWK = awk '{ print; if (NR == 2) print ".pl 9999\n.ll 65" }'
MAN2HTML = man2html -t "Postfix manual - `IFS=.; set \`echo $@\`; echo \"$$1($$2)\"`"
@@ -272,6 +272,10 @@ mysql_table.5.html: ../proto/mysql_table
PATH=../mantools:$$PATH; \
srctoman - $? | $(AWK) | nroff -man | uniq | $(MAN2HTML) | postlink >$@
+sqlite_table.5.html: ../proto/sqlite_table
+ PATH=../mantools:$$PATH; \
+ srctoman - $? | $(AWK) | nroff -man | uniq | $(MAN2HTML) | postlink >$@
+
nisplus_table.5.html: ../proto/nisplus_table
PATH=../mantools:$$PATH; \
srctoman - $? | $(AWK) | nroff -man | uniq | $(MAN2HTML) | postlink >$@
diff --git a/postfix/html/SQLITE_README.html b/postfix/html/SQLITE_README.html
new file mode 100644
index 000000000..c9147cef0
--- /dev/null
+++ b/postfix/html/SQLITE_README.html
@@ -0,0 +1,96 @@
+
+
+
+
+
+
+ STARTTLS session encryption TLS_README
Postfix 2.2
+
+Postfix SQLite Howto
+
+Introduction
+
+Building Postfix with SQLite support
+
+
+
+
+
+
+
+
+
+make -f Makefile.init makefiles \
+ 'CCARGS=-DHAS_SQLITE -I/usr/local/include' \
+ 'AUXLIBS=-L/usr/local/lib -lsqlite3 -lpthread'
+
+Using SQLite tables
+
+
+
+
+
+alias_maps = sqlite:/etc/postfix/sqlite-aliases.cf
+
+Example: local aliases
+
+
+#
+# sqlite config file for local(8) aliases(5) lookups
+#
+
+# Path to database
+dbpath = /some/path/to/sqlite_database
+
+# See sqlite_table(5) for details.
+query = SELECT forw_addr FROM mxaliases WHERE alias='%s' AND status='paid'
+
+
+Additional notes
+
+Credits
+
+
+
+
+
+
+
+
diff --git a/postfix/html/index.html b/postfix/html/index.html
index 0cd7f6d66..d17f762cd 100644
--- a/postfix/html/index.html
+++ b/postfix/html/index.html
@@ -136,6 +136,8 @@ Per-client/user/etc. access
This feature is available in Postfix 2.4.15, 2.6.8, 2.7.2 and -later versions. Specify "tls_append_default_CA = yes" for backwards -compatibility, to avoid breaking certificate verification with sites -that don't use permit_tls_all_clientcerts.
+This feature is available in Postfix 2.4.15, 2.5.11, 2.6.8, +2.7.2 and later versions. Specify "tls_append_default_CA = yes" for +backwards compatibility, to avoid breaking certificate verification +with sites that don't use permit_tls_all_clientcerts.
diff --git a/postfix/html/postfix-manuals.html b/postfix/html/postfix-manuals.html index 655bc7db6..fd6dca77f 100644 --- a/postfix/html/postfix-manuals.html +++ b/postfix/html/postfix-manuals.html @@ -165,6 +165,8 @@ the following convention:+SQLITE_TABLE(5) SQLITE_TABLE(5) + +NAME + sqlite_table - Postfix SQLite configuration + +SYNOPSIS + postmap -q "string" sqlite:/etc/postfix/filename + + postmap -q - sqlite:/etc/postfix/filename <inputfile + +DESCRIPTION + The Postfix mail system uses optional tables for address + rewriting or mail routing. These tables are usually in dbm + or db format. + + Alternatively, lookup tables can be specified as SQLite + databases. In order to use SQLite lookups, define a + SQLite source as a lookup table in main.cf, for example: + alias_maps = sqlite:/etc/sqlite-aliases.cf + + The file /etc/postfix/sqlite-aliases.cf has the same for- + mat as the Postfix main.cf file, and can specify the + parameters described below. + +BACKWARDS COMPATIBILITY + For compatibility with other Postfix lookup tables, SQLite + parameters can also be defined in main.cf. In order to do + that, specify as SQLite source a name that doesn't begin + with a slash or a dot. The SQLite parameters will then be + accessible as the name you've given the source in its def- + inition, an underscore, and the name of the parameter. + For example, if the map is specified as "sqlite:sqlite- + name", the parameter "query" below would be defined in + main.cf as "sqlitename_query". + + Normally, the SQL query is specified via a single query + parameter (described in more detail below). When this + parameter is not specified in the map definition, Postfix + reverts to an older interface, with the SQL query con- + structed from the select_field, table, where_field and + additional_conditions parameters. The old interface will + be gradually phased out. To migrate to the new interface + set: + + query = SELECT [select_field] + FROM [table] + WHERE [where_field] = '%s' + [additional_conditions] + + Insert the value, not the name, of each legacy parameter. + Note that the additional_conditions parameter is optional + and if not empty, will always start with AND. + +LIST MEMBERSHIP + When using SQL to store lists such as $mynetworks, $mydes- + tination, $relay_domains, $local_recipient_maps, etc., it + is important to understand that the table must store each + list member as a separate key. The table lookup verifies + the *existence* of the key. See "Postfix lists versus + tables" in the DATABASE_README document for a discussion. + + Do NOT create tables that return the full list of domains + in $mydestination or $relay_domains etc., or IP addresses + in $mynetworks. + + DO create tables with each matching item as a key and with + an arbitrary value. With SQL databases it is not uncommon + to return the key itself or a constant value. + +SQLITE PARAMETERS + dbpath The SQLite database file location. Example: + dbpath = customer_database + + query The SQL query template used to search the database, + where %s is a substitute for the address Postfix is + trying to resolve, e.g. + query = SELECT replacement FROM aliases WHERE mailbox = '%s' + + This parameter supports the following '%' expan- + sions: + + %% This is replaced by a literal '%' character. + + %s This is replaced by the input key. SQL + quoting is used to make sure that the input + key does not add unexpected metacharacters. + + %u When the input key is an address of the form + user@domain, %u is replaced by the SQL + quoted local part of the address. Other- + wise, %u is replaced by the entire search + string. If the localpart is empty, the + query is suppressed and returns no results. + + %d When the input key is an address of the form + user@domain, %d is replaced by the SQL + quoted domain part of the address. Other- + wise, the query is suppressed and returns no + results. + + %[SUD] The upper-case equivalents of the above + expansions behave in the query parameter + identically to their lower-case counter- + parts. With the result_format parameter + (see below), they expand the input key + rather than the result value. + + %[1-9] The patterns %1, %2, ... %9 are replaced by + the corresponding most significant component + of the input key's domain. If the input key + is user@mail.example.com, then %1 is com, %2 + is example and %3 is mail. If the input key + is unqualified or does not have enough + domain components to satisfy all the speci- + fied patterns, the query is suppressed and + returns no results. + + The domain parameter described below limits the + input keys to addresses in matching domains. When + the domain parameter is non-empty, SQL queries for + unqualified addresses or addresses in non-matching + domains are suppressed and return no results. + + This parameter is available with Postfix 2.2. In + prior releases the SQL query was built from the + separate parameters: select_field, table, + where_field and additional_conditions. The mapping + from the old parameters to the equivalent query is: + + SELECT [select_field] + FROM [table] + WHERE [where_field] = '%s' + [additional_conditions] + + The '%s' in the WHERE clause expands to the escaped + search string. With Postfix 2.2 these legacy + parameters are used if the query parameter is not + specified. + + NOTE: DO NOT put quotes around the query parameter. + + result_format (default: %s) + Format template applied to result attributes. Most + commonly used to append (or prepend) text to the + result. This parameter supports the following '%' + expansions: + + %% This is replaced by a literal '%' character. + + %s This is replaced by the value of the result + attribute. When result is empty it is + skipped. + + %u When the result attribute value is an + address of the form user@domain, %u is + replaced by the local part of the address. + When the result has an empty localpart it is + skipped. + + %d When a result attribute value is an address + of the form user@domain, %d is replaced by + the domain part of the attribute value. When + the result is unqualified it is skipped. + + %[SUD1-9] + The upper-case and decimal digit expansions + interpolate the parts of the input key + rather than the result. Their behavior is + identical to that described with query, and + in fact because the input key is known in + advance, queries whose key does not contain + all the information specified in the result + template are suppressed and return no + results. + + For example, using "result_format = smtp:[%s]" + allows one to use a mailHost attribute as the basis + of a transport(5) table. After applying the result + format, multiple values are concatenated as comma + separated strings. The expansion_limit and parame- + ter explained below allows one to restrict the num- + ber of values in the result, which is especially + useful for maps that must return at most one value. + + The default value %s specifies that each result + value should be used as is. + + This parameter is available with Postfix 2.2 and + later. + + NOTE: DO NOT put quotes around the result format! + + domain (default: no domain list) + This is a list of domain names, paths to files, or + dictionaries. When specified, only fully qualified + search keys with a *non-empty* localpart and a + matching domain are eligible for lookup: 'user' + lookups, bare domain lookups and "@domain" lookups + are not performed. This can significantly reduce + the query load on the SQLite server. + domain = postfix.org, hash:/etc/postfix/searchdomains + + It is best not to use SQL to store the domains eli- + gible for SQL lookups. + + This parameter is available with Postfix 2.2 and + later. + + NOTE: DO NOT define this parameter for local(8) + aliases, because the input keys are always unquali- + fied. + + expansion_limit (default: 0) + A limit on the total number of result elements + returned (as a comma separated list) by a lookup + against the map. A setting of zero disables the + limit. Lookups fail with a temporary error if the + limit is exceeded. Setting the limit to 1 ensures + that lookups do not return multiple values. + +OBSOLETE QUERY INTERFACE + This section describes an interface that is deprecated as + of Postfix 2.2. It is replaced by the more general query + interface described above. If the query parameter is + defined, the legacy parameters described here ignored. + Please migrate to the new interface as the legacy inter- + face may be removed in a future release. + + The following parameters can be used to fill in a SELECT + template statement of the form: + + SELECT [select_field] + FROM [table] + WHERE [where_field] = '%s' + [additional_conditions] + + The specifier %s is replaced by the search string, and is + escaped so if it contains single quotes or other odd char- + acters, it will not cause a parse error, or worse, a secu- + rity problem. + + select_field + The SQL "select" parameter. Example: + select_field = forw_addr + + table The SQL "select .. from" table name. Example: + table = mxaliases + + where_field + The SQL "select .. where" parameter. Example: + where_field = alias + + additional_conditions + Additional conditions to the SQL query. Example: + additional_conditions = AND status = 'paid' + +SEE ALSO + postmap(1), Postfix lookup table maintenance + postconf(5), configuration parameters + ldap_table(5), LDAP lookup tables + mysql_table(5), MySQL lookup tables + pgsql_table(5), PostgreSQL lookup tables + +README FILES + DATABASE_README, Postfix lookup table overview + SQLITE_README, Postfix SQLITE driver + +LICENSE + The Secure Mailer license must be distributed with this + software. + +HISTORY + SQLite support was introduced with Postfix version 2.8. + +AUTHOR(S) + Original implementation by: + Axel Steiner + + SQLITE_TABLE(5) +diff --git a/postfix/man/Makefile.in b/postfix/man/Makefile.in index 1e359ea51..4ab5008da 100644 --- a/postfix/man/Makefile.in +++ b/postfix/man/Makefile.in @@ -18,7 +18,8 @@ CONFIG = man5/access.5 man5/aliases.5 man5/canonical.5 man5/relocated.5 \ man5/cidr_table.5 man5/tcp_table.5 man5/header_checks.5 \ man5/body_checks.5 man5/ldap_table.5 man5/mysql_table.5 \ man5/pgsql_table.5 man5/master.5 man5/nisplus_table.5 \ - man5/generic.5 man5/bounce.5 man5/postfix-wrapper.5 + man5/generic.5 man5/bounce.5 man5/postfix-wrapper.5 \ + man5/sqlite_table.5 TOOLS = man1/smtp-sink.1 man1/smtp-source.1 man1/qmqp-sink.1 \ man1/qmqp-source.1 man1/qshape.1 @@ -273,6 +274,9 @@ man5/master.5: ../proto/master man5/mysql_table.5: ../proto/mysql_table ../mantools/srctoman - $? >$@ +man5/sqlite_table.5: ../proto/sqlite_table + ../mantools/srctoman - $? >$@ + man5/nisplus_table.5: ../proto/nisplus_table ../mantools/srctoman - $? >$@ diff --git a/postfix/man/man1/postconf.1 b/postfix/man/man1/postconf.1 index 530aa0677..dfc4780f1 100644 --- a/postfix/man/man1/postconf.1 +++ b/postfix/man/man1/postconf.1 @@ -152,6 +152,9 @@ described in \fBregexp_table\fR(5). .IP \fBsdbm\fR An indexed file type based on hashing. This is available on systems with support for SDBM databases. +.IP "\fBsqlite\fR (read-only)" +Perform lookups from SQLite database files. This is described +in \fBsqlite_table\fR(5). .IP "\fBstatic\fR (read-only)" A table that always returns its name as lookup result. For example, \fBstatic:foobar\fR always returns the string \fBfoobar\fR as lookup diff --git a/postfix/man/man1/postfix.1 b/postfix/man/man1/postfix.1 index c8d601941..2ad778586 100644 --- a/postfix/man/man1/postfix.1 +++ b/postfix/man/man1/postfix.1 @@ -259,6 +259,7 @@ nisplus_table(5), Postfix NIS+ client pcre_table(5), Associate PCRE pattern with value pgsql_table(5), Postfix PostgreSQL client regexp_table(5), Associate POSIX regexp pattern with value +slite_table(5), Postfix SQLite database driver tcp_table(5), Postfix client-server table lookup Daemon processes: diff --git a/postfix/man/man5/ldap_table.5 b/postfix/man/man5/ldap_table.5 index b81421d52..b9169bb5f 100644 --- a/postfix/man/man5/ldap_table.5 +++ b/postfix/man/man5/ldap_table.5 @@ -56,14 +56,8 @@ Note: with this form, the passwords for the LDAP sources are written in main.cf, which is normally world-readable. Support for this form will be removed in a future Postfix version. -Postfix 2.2 has enhanced query interfaces for MySQL and PostgreSQL. -These include features that were previously available only in the -Postfix LDAP client. This work also created an opportunity for -improvements in the LDAP interface. The primary compatibility -issue is that \fBresult_filter\fR (a name that has caused some -confusion as to its meaning in the past) has been renamed to -\fBresult_format\fR. For backwards compatibility with the pre -2.2 LDAP client, \fBresult_filter\fR can for now be used instead +For backwards compatibility with the pre +2.2 LDAP clients, \fBresult_filter\fR can for now be used instead of \fBresult_format\fR, when the latter parameter is not also set. The new name better reflects the function of the parameter. This compatibility interface may be removed in a future release. diff --git a/postfix/man/man5/mysql_table.5 b/postfix/man/man5/mysql_table.5 index 1a4b97d3f..b6f6caf7d 100644 --- a/postfix/man/man5/mysql_table.5 +++ b/postfix/man/man5/mysql_table.5 @@ -46,16 +46,14 @@ Note: with this form, the passwords for the MySQL sources are written in main.cf, which is normally world-readable. Support for this form will be removed in a future Postfix version. -Postfix 2.2 has enhanced query interfaces for MySQL and PostgreSQL; -these include features previously available only in the Postfix -LDAP client. In the new interface the SQL query is specified via -a single \fBquery\fR parameter (described in more detail below). -When the new \fBquery\fR parameter is not specified in the map -definition, Postfix reverts to the old interface, with the SQL -query constructed from the \fBselect_field\fR, \fBtable\fR, -\fBwhere_field\fR and \fBadditional_conditions\fR parameters. -The old interface will be gradually phased out. To migrate to -the new interface set: +Normally, the SQL query is specified via a single \fBquery\fR +parameter (described in more detail below). When this +parameter is not specified in the map definition, Postfix +reverts to an older interface, with the SQL query constructed +from the \fBselect_field\fR, \fBtable\fR, \fBwhere_field\fR +and \fBadditional_conditions\fR parameters. The old interface +will be gradually phased out. To migrate to the new interface +set: .nf \fBquery\fR = SELECT [\fIselect_field\fR] @@ -310,6 +308,7 @@ postmap(1), Postfix lookup table maintenance postconf(5), configuration parameters ldap_table(5), LDAP lookup tables pgsql_table(5), PostgreSQL lookup tables +sqlite_table(5), SQLite lookup tables .SH "README FILES" .na .nf diff --git a/postfix/man/man5/pgsql_table.5 b/postfix/man/man5/pgsql_table.5 index 3ee3b7d80..3c99dc7e6 100644 --- a/postfix/man/man5/pgsql_table.5 +++ b/postfix/man/man5/pgsql_table.5 @@ -48,18 +48,14 @@ are written in main.cf, which is normally world-readable. Support for this form will be removed in a future Postfix version. -Postfix 2.2 has enhanced query interfaces for MySQL and PostgreSQL, -these include features previously available only in the Postfix -LDAP client. In the new interface the SQL query is specified via -a single \fBquery\fR parameter (described in more detail below). -In Postfix 2.1 the parameter precedence was, from highest to lowest, -\fBselect_function\fR, \fBquery\fR and finally \fBselect_field\fR, ... - -With Postfix 2.2 the \fBquery\fR parameter has highest precedence, -and is used in preference to the still supported, but slated to be -phased out, \fBselect_function\fR, \fBselect_field\fR, \fBtable\fR, -\fBwhere_field\fR and \fBadditional_conditions\fR parameters. To -migrate to the new interface set: +Normally, the SQL query is specified via a single \fBquery\fR +parameter (described in more detail below). When this +parameter is not specified in the map definition, Postfix +reverts to an older interface, with the SQL query +constructed from the \fBselect_function\fR, \fBselect_field\fR, +\fBtable\fR, \fBwhere_field\fR and \fBadditional_conditions\fR +parameters. The old interface will be gradually phased +out. To migrate to the new interface set: .nf \fBquery\fR = SELECT \fIselect_function\fR('%s') @@ -334,6 +330,7 @@ postmap(1), Postfix lookup table manager postconf(5), configuration parameters ldap_table(5), LDAP lookup tables mysql_table(5), MySQL lookup tables +sqlite_table(5), SQLite lookup tables .SH "README FILES" .na .nf diff --git a/postfix/man/man5/postconf.5 b/postfix/man/man5/postconf.5 index 24850ce39..a8f09df44 100644 --- a/postfix/man/man5/postconf.5 +++ b/postfix/man/man5/postconf.5 @@ -8948,10 +8948,10 @@ The default is "no"; this prevents Postfix from trusting third-party certificates and giving them relay permission with permit_tls_all_clientcerts. .PP -This feature is available in Postfix 2.4.15, 2.6.8, 2.7.2 and -later versions. Specify "tls_append_default_CA = yes" for backwards -compatibility, to avoid breaking certificate verification with sites -that don't use permit_tls_all_clientcerts. +This feature is available in Postfix 2.4.15, 2.5.11, 2.6.8, +2.7.2 and later versions. Specify "tls_append_default_CA = yes" for +backwards compatibility, to avoid breaking certificate verification +with sites that don't use permit_tls_all_clientcerts. .SH tls_daemon_random_bytes (default: 32) The number of pseudo-random bytes that an \fBsmtp\fR(8) or \fBsmtpd\fR(8) process requests from the \fBtlsmgr\fR(8) server in order to seed its diff --git a/postfix/man/man5/sqlite_table.5 b/postfix/man/man5/sqlite_table.5 new file mode 100644 index 000000000..8133f6d51 --- /dev/null +++ b/postfix/man/man5/sqlite_table.5 @@ -0,0 +1,304 @@ +.TH SQLITE_TABLE 5 +.ad +.fi +.SH NAME +sqlite_table +\- +Postfix SQLite configuration +.SH "SYNOPSIS" +.na +.nf +\fBpostmap -q "\fIstring\fB" sqlite:/etc/postfix/filename\fR + +\fBpostmap -q - sqlite:/etc/postfix/\fIfilename\fR <\fIinputfile\fR +.SH DESCRIPTION +.ad +.fi +The Postfix mail system uses optional tables for address +rewriting or mail routing. These tables are usually in +\fBdbm\fR or \fBdb\fR format. + +Alternatively, lookup tables can be specified as SQLite databases. +In order to use SQLite lookups, define a SQLite source as a lookup +table in main.cf, for example: +.nf + alias_maps = sqlite:/etc/sqlite-aliases.cf +.fi + +The file /etc/postfix/sqlite-aliases.cf has the same format as +the Postfix main.cf file, and can specify the parameters +described below. +.SH "BACKWARDS COMPATIBILITY" +.na +.nf +.ad +.fi +For compatibility with other Postfix lookup tables, SQLite +parameters can also be defined in main.cf. In order to do that, +specify as SQLite source a name that doesn't begin with a slash +or a dot. The SQLite parameters will then be accessible as the +name you've given the source in its definition, an underscore, +and the name of the parameter. For example, if the map is +specified as "sqlite:\fIsqlitename\fR", the parameter "query" +below would be defined in main.cf as "\fIsqlitename\fR_query". + +Normally, the SQL query is specified via a single \fBquery\fR +parameter (described in more detail below). When this +parameter is not specified in the map definition, Postfix +reverts to an older interface, with the SQL query constructed +from the \fBselect_field\fR, \fBtable\fR, \fBwhere_field\fR +and \fBadditional_conditions\fR parameters. The old interface +will be gradually phased out. To migrate to the new interface +set: + +.nf + \fBquery\fR = SELECT [\fIselect_field\fR] + FROM [\fItable\fR] + WHERE [\fIwhere_field\fR] = '%s' + [\fIadditional_conditions\fR] +.fi + +Insert the value, not the name, of each legacy parameter. Note +that the \fBadditional_conditions\fR parameter is optional +and if not empty, will always start with \fBAND\fR. +.SH "LIST MEMBERSHIP" +.na +.nf +.ad +.fi +When using SQL to store lists such as $mynetworks, +$mydestination, $relay_domains, $local_recipient_maps, +etc., it is important to understand that the table must +store each list member as a separate key. The table lookup +verifies the *existence* of the key. See "Postfix lists +versus tables" in the DATABASE_README document for a +discussion. + +Do NOT create tables that return the full list of domains +in $mydestination or $relay_domains etc., or IP addresses +in $mynetworks. + +DO create tables with each matching item as a key and with +an arbitrary value. With SQL databases it is not uncommon to +return the key itself or a constant value. +.SH "SQLITE PARAMETERS" +.na +.nf +.ad +.fi +.IP "\fBdbpath\fR" +The SQLite database file location. Example: +.nf + dbpath = customer_database +.fi +.IP "\fBquery\fR" +The SQL query template used to search the database, where \fB%s\fR +is a substitute for the address Postfix is trying to resolve, +e.g. +.nf + query = SELECT replacement FROM aliases WHERE mailbox = '%s' +.fi + +This parameter supports the following '%' expansions: +.RS +.IP "\fB\fB%%\fR\fR" +This is replaced by a literal '%' character. +.IP "\fB\fB%s\fR\fR" +This is replaced by the input key. +SQL quoting is used to make sure that the input key does not +add unexpected metacharacters. +.IP "\fB\fB%u\fR\fR" +When the input key is an address of the form user@domain, \fB%u\fR +is replaced by the SQL quoted local part of the address. +Otherwise, \fB%u\fR is replaced by the entire search string. +If the localpart is empty, the query is suppressed and returns +no results. +.IP "\fB\fB%d\fR\fR" +When the input key is an address of the form user@domain, \fB%d\fR +is replaced by the SQL quoted domain part of the address. +Otherwise, the query is suppressed and returns no results. +.IP "\fB\fB%[SUD]\fR\fR" +The upper-case equivalents of the above expansions behave in the +\fBquery\fR parameter identically to their lower-case counter-parts. +With the \fBresult_format\fR parameter (see below), they expand the +input key rather than the result value. +.IP "\fB\fB%[1-9]\fR\fR" +The patterns %1, %2, ... %9 are replaced by the corresponding +most significant component of the input key's domain. If the +input key is \fIuser@mail.example.com\fR, then %1 is \fBcom\fR, +%2 is \fBexample\fR and %3 is \fBmail\fR. If the input key is +unqualified or does not have enough domain components to satisfy +all the specified patterns, the query is suppressed and returns +no results. +.RE +.IP +The \fBdomain\fR parameter described below limits the input +keys to addresses in matching domains. When the \fBdomain\fR +parameter is non-empty, SQL queries for unqualified addresses +or addresses in non-matching domains are suppressed +and return no results. + +This parameter is available with Postfix 2.2. In prior releases +the SQL query was built from the separate parameters: +\fBselect_field\fR, \fBtable\fR, \fBwhere_field\fR and +\fBadditional_conditions\fR. The mapping from the old parameters +to the equivalent query is: + +.nf + SELECT [\fBselect_field\fR] + FROM [\fBtable\fR] + WHERE [\fBwhere_field\fR] = '%s' + [\fBadditional_conditions\fR] +.fi + +The '%s' in the \fBWHERE\fR clause expands to the escaped search string. +With Postfix 2.2 these legacy parameters are used if the \fBquery\fR +parameter is not specified. + +NOTE: DO NOT put quotes around the query parameter. +.IP "\fBresult_format (default: \fB%s\fR)\fR" +Format template applied to result attributes. Most commonly used +to append (or prepend) text to the result. This parameter supports +the following '%' expansions: +.RS +.IP "\fB\fB%%\fR\fR" +This is replaced by a literal '%' character. +.IP "\fB\fB%s\fR\fR" +This is replaced by the value of the result attribute. When +result is empty it is skipped. +.IP "\fB%u\fR +When the result attribute value is an address of the form +user@domain, \fB%u\fR is replaced by the local part of the +address. When the result has an empty localpart it is skipped. +.IP "\fB\fB%d\fR\fR" +When a result attribute value is an address of the form +user@domain, \fB%d\fR is replaced by the domain part of +the attribute value. When the result is unqualified it +is skipped. +.IP "\fB\fB%[SUD1-9]\fR\fB" +The upper-case and decimal digit expansions interpolate +the parts of the input key rather than the result. Their +behavior is identical to that described with \fBquery\fR, +and in fact because the input key is known in advance, queries +whose key does not contain all the information specified in +the result template are suppressed and return no results. +.RE +.IP +For example, using "result_format = smtp:[%s]" allows one +to use a mailHost attribute as the basis of a transport(5) +table. After applying the result format, multiple values +are concatenated as comma separated strings. The expansion_limit +and parameter explained below allows one to restrict the number +of values in the result, which is especially useful for maps that +must return at most one value. + +The default value \fB%s\fR specifies that each result value should +be used as is. + +This parameter is available with Postfix 2.2 and later. + +NOTE: DO NOT put quotes around the result format! +.IP "\fBdomain (default: no domain list)\fR" +This is a list of domain names, paths to files, or +dictionaries. When specified, only fully qualified search +keys with a *non-empty* localpart and a matching domain +are eligible for lookup: 'user' lookups, bare domain lookups +and "@domain" lookups are not performed. This can significantly +reduce the query load on the SQLite server. +.nf + domain = postfix.org, hash:/etc/postfix/searchdomains +.fi + +It is best not to use SQL to store the domains eligible +for SQL lookups. + +This parameter is available with Postfix 2.2 and later. + +NOTE: DO NOT define this parameter for local(8) aliases, +because the input keys are always unqualified. +.IP "\fBexpansion_limit (default: 0)\fR" +A limit on the total number of result elements returned +(as a comma separated list) by a lookup against the map. +A setting of zero disables the limit. Lookups fail with a +temporary error if the limit is exceeded. Setting the +limit to 1 ensures that lookups do not return multiple +values. +.SH "OBSOLETE QUERY INTERFACE" +.na +.nf +.ad +.fi +This section describes an interface that is deprecated as +of Postfix 2.2. It is replaced by the more general \fBquery\fR +interface described above. If the \fBquery\fR parameter +is defined, the legacy parameters described here ignored. +Please migrate to the new interface as the legacy interface +may be removed in a future release. + +The following parameters can be used to fill in a +SELECT template statement of the form: + +.nf + SELECT [\fBselect_field\fR] + FROM [\fBtable\fR] + WHERE [\fBwhere_field\fR] = '%s' + [\fBadditional_conditions\fR] +.fi + +The specifier %s is replaced by the search string, and is +escaped so if it contains single quotes or other odd characters, +it will not cause a parse error, or worse, a security problem. +.IP "\fBselect_field\fR" +The SQL "select" parameter. Example: +.nf + \fBselect_field\fR = forw_addr +.fi +.IP "\fBtable\fR" +The SQL "select .. from" table name. Example: +.nf + \fBtable\fR = mxaliases +.fi +.IP "\fBwhere_field\fR +The SQL "select .. where" parameter. Example: +.nf + \fBwhere_field\fR = alias +.fi +.IP "\fBadditional_conditions\fR +Additional conditions to the SQL query. Example: +.nf + \fBadditional_conditions\fR = AND status = 'paid' +.fi +.SH "SEE ALSO" +.na +.nf +postmap(1), Postfix lookup table maintenance +postconf(5), configuration parameters +ldap_table(5), LDAP lookup tables +mysql_table(5), MySQL lookup tables +pgsql_table(5), PostgreSQL lookup tables +.SH "README FILES" +.na +.nf +.ad +.fi +Use "\fBpostconf readme_directory\fR" or +"\fBpostconf html_directory\fR" to locate this information. +.na +.nf +DATABASE_README, Postfix lookup table overview +SQLITE_README, Postfix SQLITE driver +.SH "LICENSE" +.na +.nf +.ad +.fi +The Secure Mailer license must be distributed with this software. +.SH "HISTORY" +.na +.nf +SQLite support was introduced with Postfix version 2.8. +.SH "AUTHOR(S)" +.na +.nf +Original implementation by: +Axel Steiner diff --git a/postfix/mantools/postlink b/postfix/mantools/postlink index f7ba92184..587af90e6 100755 --- a/postfix/mantools/postlink +++ b/postfix/mantools/postlink @@ -772,6 +772,7 @@ while (<>) { s/[
Once you have local files working properly you can follow the -instructions in ldap_table(5), mysql_table(5) or pgsql_table(5) +instructions in ldap_table(5), mysql_table(5), pgsql_table(5) +or sqlite_table(5) and replace local file lookups with LDAP or SQL lookups. When you do this, you should use the postmap(1) command again, to verify that database lookups still produce the exact same results as local @@ -358,6 +359,11 @@ created with the postmap(1) or postalias(1) command. The lookup table name as used in "sdbm:table" is the database file name without the ".dir" or ".pag" suffix. +
The Postfix sqlite map type allows you to hook up Postfix to a +SQLite database. This implementation allows for multiple sqlite +databases: you can use one for a virtual(5) table, one for an +access(5) table, and one for an aliases(5) table if you want.
+ +The Postfix SQLite client utilizes the sqlite3 library, +which can be obtained from:
+ +++ +http://www.sqlite.org/
+
In order to build Postfix with sqlite map support, you will need to add +-DHAS_SQLITE and -I for the directory containing the sqlite headers, and +the sqlite3 library to AUXLIBS, for example:
+ +++ ++make -f Makefile.init makefiles \ + 'CCARGS=-DHAS_SQLITE -I/usr/local/include' \ + 'AUXLIBS=-L/usr/local/lib -lsqlite3 -lpthread' ++
Then, just run 'make'.
+ +Once Postfix is built with sqlite support, you can specify a +map type in main.cf like this:
+ +++ ++alias_maps = sqlite:/etc/postfix/sqlite-aliases.cf ++
The file /etc/postfix/sqlite-aliases.cf specifies lots of +information telling Postfix how to reference the sqlite database. +For a complete description, see the sqlite_table(5) manual page.
+ ++# +# sqlite config file for local(8) aliases(5) lookups +# + +# Path to database +dbpath = /some/path/to/sqlite_database + +# See sqlite_table(5) for details. +query = SELECT forw_addr FROM mxaliases WHERE alias='%s' AND status='paid' ++ +
The SQLite configuration interface setup allows for multiple +sqlite databases: you can use one for a virtual table, one for an +access table, and one for an aliases table if you want.
+ +This feature is available in Postfix 2.4.15, 2.6.8, 2.7.2 and -later versions. Specify "tls_append_default_CA = yes" for backwards -compatibility, to avoid breaking certificate verification with sites -that don't use permit_tls_all_clientcerts.
+This feature is available in Postfix 2.4.15, 2.5.11, 2.6.8, +2.7.2 and later versions. Specify "tls_append_default_CA = yes" for +backwards compatibility, to avoid breaking certificate verification +with sites that don't use permit_tls_all_clientcerts.
%PARAM tls_random_exchange_name see "postconf -d" output diff --git a/postfix/proto/sqlite_table b/postfix/proto/sqlite_table new file mode 100644 index 000000000..f9934d207 --- /dev/null +++ b/postfix/proto/sqlite_table @@ -0,0 +1,281 @@ +#++ +# NAME +# sqlite_table 5 +# SUMMARY +# Postfix SQLite configuration +# SYNOPSIS +# \fBpostmap -q "\fIstring\fB" sqlite:/etc/postfix/filename\fR +# +# \fBpostmap -q - sqlite:/etc/postfix/\fIfilename\fR <\fIinputfile\fR +# DESCRIPTION +# The Postfix mail system uses optional tables for address +# rewriting or mail routing. These tables are usually in +# \fBdbm\fR or \fBdb\fR format. +# +# Alternatively, lookup tables can be specified as SQLite databases. +# In order to use SQLite lookups, define a SQLite source as a lookup +# table in main.cf, for example: +# .nf +# alias_maps = sqlite:/etc/sqlite-aliases.cf +# .fi +# +# The file /etc/postfix/sqlite-aliases.cf has the same format as +# the Postfix main.cf file, and can specify the parameters +# described below. +# BACKWARDS COMPATIBILITY +# .ad +# .fi +# For compatibility with other Postfix lookup tables, SQLite +# parameters can also be defined in main.cf. In order to do that, +# specify as SQLite source a name that doesn't begin with a slash +# or a dot. The SQLite parameters will then be accessible as the +# name you've given the source in its definition, an underscore, +# and the name of the parameter. For example, if the map is +# specified as "sqlite:\fIsqlitename\fR", the parameter "query" +# below would be defined in main.cf as "\fIsqlitename\fR_query". +# +# Normally, the SQL query is specified via a single \fBquery\fR +# parameter (described in more detail below). When this +# parameter is not specified in the map definition, Postfix +# reverts to an older interface, with the SQL query constructed +# from the \fBselect_field\fR, \fBtable\fR, \fBwhere_field\fR +# and \fBadditional_conditions\fR parameters. The old interface +# will be gradually phased out. To migrate to the new interface +# set: +# +# .nf +# \fBquery\fR = SELECT [\fIselect_field\fR] +# FROM [\fItable\fR] +# WHERE [\fIwhere_field\fR] = '%s' +# [\fIadditional_conditions\fR] +# .fi +# +# Insert the value, not the name, of each legacy parameter. Note +# that the \fBadditional_conditions\fR parameter is optional +# and if not empty, will always start with \fBAND\fR. +# LIST MEMBERSHIP +# .ad +# .fi +# When using SQL to store lists such as $mynetworks, +# $mydestination, $relay_domains, $local_recipient_maps, +# etc., it is important to understand that the table must +# store each list member as a separate key. The table lookup +# verifies the *existence* of the key. See "Postfix lists +# versus tables" in the DATABASE_README document for a +# discussion. +# +# Do NOT create tables that return the full list of domains +# in $mydestination or $relay_domains etc., or IP addresses +# in $mynetworks. +# +# DO create tables with each matching item as a key and with +# an arbitrary value. With SQL databases it is not uncommon to +# return the key itself or a constant value. +# SQLITE PARAMETERS +# .ad +# .fi +# .IP "\fBdbpath\fR" +# The SQLite database file location. Example: +# .nf +# dbpath = customer_database +# .fi +# .IP "\fBquery\fR" +# The SQL query template used to search the database, where \fB%s\fR +# is a substitute for the address Postfix is trying to resolve, +# e.g. +# .nf +# query = SELECT replacement FROM aliases WHERE mailbox = '%s' +# .fi +# +# This parameter supports the following '%' expansions: +# .RS +# .IP "\fB\fB%%\fR\fR" +# This is replaced by a literal '%' character. +# .IP "\fB\fB%s\fR\fR" +# This is replaced by the input key. +# SQL quoting is used to make sure that the input key does not +# add unexpected metacharacters. +# .IP "\fB\fB%u\fR\fR" +# When the input key is an address of the form user@domain, \fB%u\fR +# is replaced by the SQL quoted local part of the address. +# Otherwise, \fB%u\fR is replaced by the entire search string. +# If the localpart is empty, the query is suppressed and returns +# no results. +# .IP "\fB\fB%d\fR\fR" +# When the input key is an address of the form user@domain, \fB%d\fR +# is replaced by the SQL quoted domain part of the address. +# Otherwise, the query is suppressed and returns no results. +# .IP "\fB\fB%[SUD]\fR\fR" +# The upper-case equivalents of the above expansions behave in the +# \fBquery\fR parameter identically to their lower-case counter-parts. +# With the \fBresult_format\fR parameter (see below), they expand the +# input key rather than the result value. +# .IP "\fB\fB%[1-9]\fR\fR" +# The patterns %1, %2, ... %9 are replaced by the corresponding +# most significant component of the input key's domain. If the +# input key is \fIuser@mail.example.com\fR, then %1 is \fBcom\fR, +# %2 is \fBexample\fR and %3 is \fBmail\fR. If the input key is +# unqualified or does not have enough domain components to satisfy +# all the specified patterns, the query is suppressed and returns +# no results. +# .RE +# .IP +# The \fBdomain\fR parameter described below limits the input +# keys to addresses in matching domains. When the \fBdomain\fR +# parameter is non-empty, SQL queries for unqualified addresses +# or addresses in non-matching domains are suppressed +# and return no results. +# +# This parameter is available with Postfix 2.2. In prior releases +# the SQL query was built from the separate parameters: +# \fBselect_field\fR, \fBtable\fR, \fBwhere_field\fR and +# \fBadditional_conditions\fR. The mapping from the old parameters +# to the equivalent query is: +# +# .nf +# SELECT [\fBselect_field\fR] +# FROM [\fBtable\fR] +# WHERE [\fBwhere_field\fR] = '%s' +# [\fBadditional_conditions\fR] +# .fi +# +# The '%s' in the \fBWHERE\fR clause expands to the escaped search string. +# With Postfix 2.2 these legacy parameters are used if the \fBquery\fR +# parameter is not specified. +# +# NOTE: DO NOT put quotes around the query parameter. +# .IP "\fBresult_format (default: \fB%s\fR)\fR" +# Format template applied to result attributes. Most commonly used +# to append (or prepend) text to the result. This parameter supports +# the following '%' expansions: +# .RS +# .IP "\fB\fB%%\fR\fR" +# This is replaced by a literal '%' character. +# .IP "\fB\fB%s\fR\fR" +# This is replaced by the value of the result attribute. When +# result is empty it is skipped. +# .IP "\fB%u\fR +# When the result attribute value is an address of the form +# user@domain, \fB%u\fR is replaced by the local part of the +# address. When the result has an empty localpart it is skipped. +# .IP "\fB\fB%d\fR\fR" +# When a result attribute value is an address of the form +# user@domain, \fB%d\fR is replaced by the domain part of +# the attribute value. When the result is unqualified it +# is skipped. +# .IP "\fB\fB%[SUD1-9]\fR\fB" +# The upper-case and decimal digit expansions interpolate +# the parts of the input key rather than the result. Their +# behavior is identical to that described with \fBquery\fR, +# and in fact because the input key is known in advance, queries +# whose key does not contain all the information specified in +# the result template are suppressed and return no results. +# .RE +# .IP +# For example, using "result_format = smtp:[%s]" allows one +# to use a mailHost attribute as the basis of a transport(5) +# table. After applying the result format, multiple values +# are concatenated as comma separated strings. The expansion_limit +# and parameter explained below allows one to restrict the number +# of values in the result, which is especially useful for maps that +# must return at most one value. +# +# The default value \fB%s\fR specifies that each result value should +# be used as is. +# +# This parameter is available with Postfix 2.2 and later. +# +# NOTE: DO NOT put quotes around the result format! +# .IP "\fBdomain (default: no domain list)\fR" +# This is a list of domain names, paths to files, or +# dictionaries. When specified, only fully qualified search +# keys with a *non-empty* localpart and a matching domain +# are eligible for lookup: 'user' lookups, bare domain lookups +# and "@domain" lookups are not performed. This can significantly +# reduce the query load on the SQLite server. +# .nf +# domain = postfix.org, hash:/etc/postfix/searchdomains +# .fi +# +# It is best not to use SQL to store the domains eligible +# for SQL lookups. +# +# This parameter is available with Postfix 2.2 and later. +# +# NOTE: DO NOT define this parameter for local(8) aliases, +# because the input keys are always unqualified. +# .IP "\fBexpansion_limit (default: 0)\fR" +# A limit on the total number of result elements returned +# (as a comma separated list) by a lookup against the map. +# A setting of zero disables the limit. Lookups fail with a +# temporary error if the limit is exceeded. Setting the +# limit to 1 ensures that lookups do not return multiple +# values. +# OBSOLETE QUERY INTERFACE +# .ad +# .fi +# This section describes an interface that is deprecated as +# of Postfix 2.2. It is replaced by the more general \fBquery\fR +# interface described above. If the \fBquery\fR parameter +# is defined, the legacy parameters described here ignored. +# Please migrate to the new interface as the legacy interface +# may be removed in a future release. +# +# The following parameters can be used to fill in a +# SELECT template statement of the form: +# +# .nf +# SELECT [\fBselect_field\fR] +# FROM [\fBtable\fR] +# WHERE [\fBwhere_field\fR] = '%s' +# [\fBadditional_conditions\fR] +# .fi +# +# The specifier %s is replaced by the search string, and is +# escaped so if it contains single quotes or other odd characters, +# it will not cause a parse error, or worse, a security problem. +# .IP "\fBselect_field\fR" +# The SQL "select" parameter. Example: +# .nf +# \fBselect_field\fR = forw_addr +# .fi +# .IP "\fBtable\fR" +# The SQL "select .. from" table name. Example: +# .nf +# \fBtable\fR = mxaliases +# .fi +# .IP "\fBwhere_field\fR +# The SQL "select .. where" parameter. Example: +# .nf +# \fBwhere_field\fR = alias +# .fi +# .IP "\fBadditional_conditions\fR +# Additional conditions to the SQL query. Example: +# .nf +# \fBadditional_conditions\fR = AND status = 'paid' +# .fi +# SEE ALSO +# postmap(1), Postfix lookup table maintenance +# postconf(5), configuration parameters +# ldap_table(5), LDAP lookup tables +# mysql_table(5), MySQL lookup tables +# pgsql_table(5), PostgreSQL lookup tables +# README FILES +# .ad +# .fi +# Use "\fBpostconf readme_directory\fR" or +# "\fBpostconf html_directory\fR" to locate this information. +# .na +# .nf +# DATABASE_README, Postfix lookup table overview +# SQLITE_README, Postfix SQLITE driver +# LICENSE +# .ad +# .fi +# The Secure Mailer license must be distributed with this software. +# HISTORY +# SQLite support was introduced with Postfix version 2.8. +# AUTHOR(S) +# Original implementation by: +# Axel Steiner +#-- diff --git a/postfix/src/global/Makefile.in b/postfix/src/global/Makefile.in index 56c9b6ced..7acea1162 100644 --- a/postfix/src/global/Makefile.in +++ b/postfix/src/global/Makefile.in @@ -4,7 +4,7 @@ SRCS = abounce.c anvil_clnt.c been_here.c bounce.c bounce_log.c \ clnt_stream.c conv_time.c db_common.c debug_peer.c debug_process.c \ defer.c deliver_completed.c deliver_flock.c deliver_pass.c \ deliver_request.c dict_ldap.c dict_mysql.c dict_pgsql.c \ - dict_proxy.c domain_list.c dot_lockfile.c dot_lockfile_as.c \ + dict_proxy.c dict_sqlite.c domain_list.c dot_lockfile.c dot_lockfile_as.c \ dsb_scan.c dsn.c dsn_buf.c dsn_mask.c dsn_print.c dsn_util.c \ ehlo_mask.c ext_prop.c file_id.c flush_clnt.c header_opts.c \ header_token.c input_transp.c int_filt.c is_header.c log_adhoc.c \ @@ -35,7 +35,7 @@ OBJS = abounce.o anvil_clnt.o been_here.o bounce.o bounce_log.o \ clnt_stream.o conv_time.o db_common.o debug_peer.o debug_process.o \ defer.o deliver_completed.o deliver_flock.o deliver_pass.o \ deliver_request.o dict_ldap.o dict_mysql.o dict_pgsql.o \ - dict_proxy.o domain_list.o dot_lockfile.o dot_lockfile_as.o \ + dict_proxy.o dict_sqlite.o domain_list.o dot_lockfile.o dot_lockfile_as.o \ dsb_scan.o dsn.o dsn_buf.o dsn_mask.o dsn_print.o dsn_util.o \ ehlo_mask.o ext_prop.o file_id.o flush_clnt.o header_opts.o \ header_token.o input_transp.o int_filt.o is_header.o log_adhoc.o \ @@ -65,7 +65,7 @@ HDRS = abounce.h anvil_clnt.h been_here.h bounce.h bounce_log.h \ canon_addr.h cfg_parser.h cleanup_user.h clnt_stream.h config.h \ conv_time.h db_common.h debug_peer.h debug_process.h defer.h \ deliver_completed.h deliver_flock.h deliver_pass.h deliver_request.h \ - dict_ldap.h dict_mysql.h dict_pgsql.h dict_proxy.h domain_list.h \ + dict_ldap.h dict_mysql.h dict_pgsql.h dict_proxy.h dict_sqlite.h domain_list.h \ dot_lockfile.h dot_lockfile_as.h dsb_scan.h dsn.h dsn_buf.h \ dsn_mask.h dsn_print.h dsn_util.h ehlo_mask.h ext_prop.h \ file_id.h flush_clnt.h header_opts.h header_token.h input_transp.h \ @@ -832,6 +832,13 @@ dict_mysql.o: db_common.h dict_mysql.o: dict_mysql.c dict_mysql.o: dict_mysql.h dict_mysql.o: string_list.h +dict_sqlite.o: ../../include/dict.h +dict_sqlite.o: ../../include/msg.h +dict_sqlite.o: ../../include/sys_defs.h +dict_sqlite.o: cfg_parser.h +dict_sqlite.o: db_common.h +dict_sqlite.o: dict_sqlite.c +dict_sqlite.o: dict_sqlite.h dict_pgsql.o: ../../include/argv.h dict_pgsql.o: ../../include/dict.h dict_pgsql.o: ../../include/events.h @@ -1239,6 +1246,7 @@ mail_dict.o: dict_ldap.h mail_dict.o: dict_mysql.h mail_dict.o: dict_pgsql.h mail_dict.o: dict_proxy.h +mail_dict.o: dict_sqlite.h mail_dict.o: mail_dict.c mail_dict.o: mail_dict.h mail_error.o: ../../include/name_mask.h diff --git a/postfix/src/global/db_common.c b/postfix/src/global/db_common.c index 887ceacd4..6a2fa4bec 100644 --- a/postfix/src/global/db_common.c +++ b/postfix/src/global/db_common.c @@ -161,13 +161,13 @@ typedef struct { STRING_LIST *domain; int flags; int nparts; -} DB_COMMON_CTX; +} DB_COMMON_CTX; /* db_common_parse - validate query or result template */ int db_common_parse(DICT *dict, void **ctxPtr, const char *format, int query) { - DB_COMMON_CTX *ctx = (DB_COMMON_CTX *) * ctxPtr; + DB_COMMON_CTX *ctx = (DB_COMMON_CTX *) *ctxPtr; const char *cp; int dynamic = 0; diff --git a/postfix/src/global/dict_mysql.c b/postfix/src/global/dict_mysql.c index 92db68d13..5bbc1c31b 100644 --- a/postfix/src/global/dict_mysql.c +++ b/postfix/src/global/dict_mysql.c @@ -31,7 +31,7 @@ /* main.cf configuration parameters for this search. /* /* In the first case, the configuration parameters below are -/* specified in the file as \fIname\fR=\fBvalue\fR pairs. +/* specified in the file as \fIname\fR=\fIvalue\fR pairs. /* /* In the second case, the configuration parameters are /* prefixed with the value of \fIname\fR and an underscore, @@ -47,29 +47,25 @@ /* See dict_open(3). /* .PP /* Configuration parameters: -/* -/* The parameters encodes a number of pieces of information: -/* username, password, databasename, table, select_field, -/* where_field, and hosts: -/* .IP \fIuser\fR +/* .IP user /* Username for connecting to the database. -/* .IP \fIpassword\fR +/* .IP password /* Password for the above. -/* .IP \fIdbname\fR +/* .IP dbname /* Name of the database. -/* .IP \fIdomain\fR +/* .IP domain /* List of domains the queries should be restricted to. If /* specified, only FQDN addresses whose domain parts matching this /* list will be queried against the SQL database. Lookups for /* partial addresses are also supressed. This can significantly /* reduce the query load on the server. -/* .IP \fIquery\fR +/* .IP query /* Query template, before the query is actually issued, variable /* substitutions are performed. See mysql_table(5) for details. If /* No query is specified, the legacy variables \fItable\fR, /* \fIselect_field\fR, \fIwhere_field\fR and \fIadditional_conditions\fR /* are used to construct the query template. -/* .IP \fIresult_format\fR +/* .IP result_format /* The format used to expand results from queries. Substitutions /* are performed as described in mysql_table(5). Defaults to returning /* the lookup result unchanged. @@ -78,22 +74,22 @@ /* exceed the limit fail with dict_errno=DICT_ERR_RETRY. Note that each /* non-empty (and non-NULL) column of a multi-column result row counts as /* one result. -/* .IP \fItable\fR +/* .IP table /* When \fIquery\fR is not set, name of the table used to construct the /* query string. This provides compatibility with older releases. -/* .IP \fIselect_field\fR +/* .IP select_field /* When \fIquery\fR is not set, name of the result field used to /* construct the query string. This provides compatibility with older /* releases. -/* .IP \fIwhere_field\fR +/* .IP where_field /* When \fIquery\fR is not set, name of the where clause field used to /* construct the query string. This provides compatibility with older /* releases. -/* .IP \fIadditional_conditions\fR +/* .IP additional_conditions /* When \fIquery\fR is not set, additional where clause conditions used /* to construct the query string. This provides compatibility with older /* releases. -/* .IP \fIhosts\fR +/* .IP hosts /* List of hosts to connect to. /* .PP /* For example, if you want the map to reference databases of @@ -117,10 +113,10 @@ /* \fIwhere_field\fR = \fBalias\fR /* .br /* \fIhosts\fR = \fBhost1.some.domain\fR \fBhost2.some.domain\fR -/* .IP \fIadditional_conditions\fR +/* .IP additional_conditions /* Backward compatibility when \fIquery\fR is not set, additional /* conditions to the WHERE clause. -/* .IP \fIhosts\fR +/* .IP hosts /* List of hosts to connect to. /* .PP /* For example, if you want the map to reference databases of diff --git a/postfix/src/global/dict_pgsql.c b/postfix/src/global/dict_pgsql.c index bedc568e3..c01c01097 100644 --- a/postfix/src/global/dict_pgsql.c +++ b/postfix/src/global/dict_pgsql.c @@ -32,7 +32,7 @@ /* obtain main.cf configuration parameters for this search. /* /* In the first case, the configuration parameters below are -/* specified in the file as \fIname\fR=\fBvalue\fR pairs. +/* specified in the file as \fIname\fR=\fIvalue\fR pairs. /* /* In the second case, the configuration parameters are /* prefixed with the value of \fIname\fR and an underscore, @@ -48,29 +48,25 @@ /* /* .PP /* Configuration parameters: -/* -/* The parameters encode a number of pieces of information: -/* username, password, databasename, table, select_field, -/* where_field, and hosts: -/* .IP \fIuser\fR +/* .IP user /* Username for connecting to the database. -/* .IP \fIpassword\fR +/* .IP password /* Password for the above. -/* .IP \fIdbname\fR +/* .IP dbname /* Name of the database. -/* .IP \fIquery\fR +/* .IP query /* Query template. If not defined a default query template is constructed /* from the legacy \fIselect_function\fR or failing that the \fItable\fR, /* \fIselect_field\fR, \fIwhere_field\fR, and \fIadditional_conditions\fR /* parameters. Before the query is issues, variable substitutions are /* performed. See pgsql_table(5). -/* .IP \fIdomain\fR +/* .IP domain /* List of domains the queries should be restricted to. If /* specified, only FQDN addresses whose domain parts matching this /* list will be queried against the SQL database. Lookups for /* partial addresses are also supressed. This can significantly /* reduce the query load on the server. -/* .IP \fIresult_format\fR +/* .IP result_format /* The format used to expand results from queries. Substitutions /* are performed as described in pgsql_table(5). Defaults to returning /* the lookup result unchanged. @@ -79,24 +75,24 @@ /* exceed the limit fail with dict_errno=DICT_ERR_RETRY. Note that each /* non-empty (and non-NULL) column of a multi-column result row counts as /* one result. -/* .IP \fIselect_function\fR +/* .IP select_function /* When \fIquery\fR is not defined, the function to be used instead of /* the default query based on the legacy \fItable\fR, \fIselect_field\fR, /* \fIwhere_field\fR, and \fIadditional_conditions\fR parameters. -/* .IP \fItable\fR +/* .IP table /* When \fIquery\fR and \fIselect_function\fR are not defined, the name of the /* FROM table used to construct the default query template, see pgsql_table(5). -/* .IP \fIselect_field\fR +/* .IP select_field /* When \fIquery\fR and \fIselect_function\fR are not defined, the name of the /* SELECT field used to construct the default query template, see pgsql_table(5). -/* .IP \fIwhere_field\fR +/* .IP where_field /* When \fIquery\fR and \fIselect_function\fR are not defined, the name of the /* WHERE field used to construct the default query template, see pgsql_table(5). -/* .IP \fIadditional_conditions\fR +/* .IP additional_conditions /* When \fIquery\fR and \fIselect_function\fR are not defined, the name of the /* additional text to add to the WHERE field in the default query template (this /* usually begins with "and") see pgsql_table(5). -/* .IP \fIhosts\fR +/* .IP hosts /* List of hosts to connect to. /* .PP /* For example, if you want the map to reference databases of diff --git a/postfix/src/global/dict_sqlite.c b/postfix/src/global/dict_sqlite.c new file mode 100644 index 000000000..1314107c1 --- /dev/null +++ b/postfix/src/global/dict_sqlite.c @@ -0,0 +1,303 @@ +/*++ +/* NAME +/* dict_sqlite 3 +/* SUMMARY +/* dictionary manager interface to SQLite3 databases +/* SYNOPSIS +/* #include