diff --git a/postfix/.indent.pro b/postfix/.indent.pro index e7009d5d4..74d52d46f 100644 --- a/postfix/.indent.pro +++ b/postfix/.indent.pro @@ -192,6 +192,7 @@ -TNAME_CODE -TNAME_MASK -TNBBIO +-TPC_DBMS_INFO -TPC_MASTER_ENT -TPC_PARAM_NODE -TPC_SERVICE_DEF diff --git a/postfix/HISTORY b/postfix/HISTORY index 56e9bde29..daf7b4575 100644 --- a/postfix/HISTORY +++ b/postfix/HISTORY @@ -17557,3 +17557,13 @@ Apologies for any names omitted. Cleanup: tiny memory leaks after surrogate database opens. Files: util/dict_cidr.c, util/dict_db.c. + +20111217 + + Cleanup: support for legacy-style database configuration + where parameter names are generated by appending suffixes + to the database name. Files: postconf/postconf_dbms.c. + + Other: build without Berkeley DB support (make makefiles + "CCARGS=$CCARGS -DNO_DB"). Files: makedefs, util/sys_defs.h, + proto/DB_README.html, proto/INSTALL.html. diff --git a/postfix/README_FILES/DB_README b/postfix/README_FILES/DB_README index 955a60ace..869218e4e 100644 --- a/postfix/README_FILES/DB_README +++ b/postfix/README_FILES/DB_README @@ -14,16 +14,33 @@ Note: Berkeley DB version 4 is not supported by Postfix versions before 2.0. This document describes: - 1. How to build Postfix on systems without Berkeley DB library. + 1. How to build Postfix without Berkeley DB support even if the system comes + with Berkeley DB. - 2. How to build Postfix on BSD or Linux systems with multiple Berkeley DB + 2. How to build Postfix on systems that normally have no Berkeley DB library. + + 3. How to build Postfix on BSD or Linux systems with multiple Berkeley DB versions. - 3. How to tweak performance. + 4. How to tweak performance. - 4. Missing pthread library trouble. + 5. Missing pthread library trouble. -BBuuiillddiinngg PPoossttffiixx oonn ssyysstteemmss wwiitthhoouutt BBeerrkkeelleeyy DDBB +BBuuiillddiinngg PPoossttffiixx wwiitthhoouutt BBeerrkkeelleeyy DDBB ssuuppppoorrtt eevveenn iiff tthhee ssyysstteemm ccoommeess wwiitthh +BBeerrkkeelleeyy DDBB + +Note: The following instructions apply to Postfix 2.9 and later. + +Postfix will normally enable Berkeley DB support if the system is known to have +it. To build Postfix without Berkeley DB support, build the makefiles as +follows: + + % make makefiles CCARGS="-DNO_DB" + % make + +This will disable support for "hash" and "btree" files. + +BBuuiillddiinngg PPoossttffiixx oonn ssyysstteemmss tthhaatt nnoorrmmaallllyy hhaavvee nnoo BBeerrkkeelleeyy DDBB lliibbrraarryy Some UNIXes ship without Berkeley DB support; for historical reasons these use DBM files instead. A problem with DBM files is that they can store only limited @@ -44,14 +61,12 @@ way to keep things from falling apart. To build Postfix after you installed the Berkeley DB from source code, use something like: - % make tidy % make makefiles CCARGS="-DHAS_DB -I/usr/local/BerkeleyDB/include" \ AUXLIBS="-L/usr/local/BerkeleyDB/lib -ldb" % make Solaris needs this: - % make tidy % make makefiles CCARGS="-DHAS_DB -I/usr/local/BerkeleyDB/include" \ AUXLIBS="-R/usr/local/BerkeleyDB/lib -L/usr/local/BerkeleyDB/lib -ldb" % make @@ -78,7 +93,6 @@ Postfix builds with the default DB version that ships with the system. To build Postfix on BSD systems with a non-default DB version, use a variant of the following commands: - % make tidy % make makefiles CCARGS=-I/usr/include/db3 AUXLIBS=-ldb3 % make diff --git a/postfix/README_FILES/INSTALL b/postfix/README_FILES/INSTALL index ae74b3145..05c7283ec 100644 --- a/postfix/README_FILES/INSTALL +++ b/postfix/README_FILES/INSTALL @@ -246,6 +246,11 @@ The following is an extensive list of names and values. | |following directives turn off Postfix features| | |at compile time: | |_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | +|| |Do not build with Berkeley DB support. By | +||-DNO_DB |default, Berkeley DB support is compiled in on| +|| |platforms that are known to support this | +|| |feature. | +|_|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | || |Do not build with Solaris /dev/poll support. | ||-DNO_DEVPOLL |By default, /dev/poll support is compiled in | || |on Solaris versions that are known to support | diff --git a/postfix/html/DB_README.html b/postfix/html/DB_README.html index 421c7e7d3..2064d662c 100644 --- a/postfix/html/DB_README.html +++ b/postfix/html/DB_README.html @@ -33,8 +33,11 @@ before 2.0.

    -
  1. How to build Postfix on systems without -Berkeley DB library.

    +
  2. How to build Postfix without Berkeley +DB support even if the system comes with Berkeley DB.

    + +
  3. How to build Postfix on systems that +normally have no Berkeley DB library.

  4. How to build Postfix on BSD or Linux systems with multiple Berkeley DB @@ -46,8 +49,26 @@ versions.

-

Building Postfix on systems without Berkeley -DB

+

Building Postfix without Berkeley +DB support even if the system comes with Berkeley DB

+ +

Note: The following instructions apply to Postfix 2.9 and later.

+ +

Postfix will normally enable Berkeley DB support if the system +is known to have it. To build Postfix without Berkeley DB support, +build the makefiles as follows:

+ +
+
+% make makefiles CCARGS="-DNO_DB"
+% make
+
+
+ +

This will disable support for "hash" and "btree" files.

+ +

Building Postfix on systems that normally have +no Berkeley DB library

Some UNIXes ship without Berkeley DB support; for historical reasons these use DBM files instead. A problem with DBM files is @@ -73,7 +94,6 @@ source code, use something like:

-% make tidy
 % make makefiles CCARGS="-DHAS_DB -I/usr/local/BerkeleyDB/include" \
     AUXLIBS="-L/usr/local/BerkeleyDB/lib -ldb"
 % make
@@ -84,7 +104,6 @@ source code, use something like: 

-% make tidy
 % make makefiles CCARGS="-DHAS_DB -I/usr/local/BerkeleyDB/include" \
     AUXLIBS="-R/usr/local/BerkeleyDB/lib -L/usr/local/BerkeleyDB/lib -ldb"
 % make
@@ -119,7 +138,6 @@ use a variant of the following commands: 

-% make tidy
 % make makefiles CCARGS=-I/usr/include/db3 AUXLIBS=-ldb3
 % make
 
diff --git a/postfix/html/INSTALL.html b/postfix/html/INSTALL.html index 8df125974..1622829ab 100644 --- a/postfix/html/INSTALL.html +++ b/postfix/html/INSTALL.html @@ -372,6 +372,10 @@ Specifies non-default compiler arguments, for example, a non-default include directory. The following directives turn off Postfix features at compile time: + -DNO_DB Do not build with Berkeley +DB support. By default, Berkeley DB support is compiled in on +platforms that are known to support this feature. + -DNO_DEVPOLL Do not build with Solaris /dev/poll support. By default, /dev/poll support is compiled in on Solaris versions that are known to support diff --git a/postfix/html/memcache_table.5.html b/postfix/html/memcache_table.5.html index c10aab16a..c46a4d46c 100644 --- a/postfix/html/memcache_table.5.html +++ b/postfix/html/memcache_table.5.html @@ -181,11 +181,13 @@ MEMCACHE_TABLE(5) MEMCACHE_TABLE(5) max_try (default: 2) The number of times to try a memcache command - before giving up. + before giving up. The memcache client does not + retry a command when the memcache server accepts no + connection. retry_pause (default: 1) - The time in seconds to wait after a memcache com- - mand fails. + The time in seconds before retrying a failed mem- + cache command. timeout (default: 2) The time limit for sending a memcache command and diff --git a/postfix/makedefs b/postfix/makedefs index 329485f9d..316d94b48 100644 --- a/postfix/makedefs +++ b/postfix/makedefs @@ -25,6 +25,8 @@ # \fIinclude\fR directory. # The following directives are special: # .RS +# .IP \fB-DNO_DB\fR +# Do not build with Berkeley DB support. # .IP \fB-DNO_DEVPOLL\fR # Do not build with Solaris /dev/poll support. # By default, /dev/poll support is compiled in on platforms that diff --git a/postfix/man/man5/memcache_table.5 b/postfix/man/man5/memcache_table.5 index f8f286e28..2de5980e4 100644 --- a/postfix/man/man5/memcache_table.5 +++ b/postfix/man/man5/memcache_table.5 @@ -182,9 +182,11 @@ The maximal memcache reply data length in bytes. .IP "\fBline_size_limit (default: 1024)\fR" The maximal memcache reply line length in bytes. .IP "\fBmax_try (default: 2)\fR" -The number of times to try a memcache command before giving up. +The number of times to try a memcache command before giving +up. The memcache client does not retry a command when the +memcache server accepts no connection. .IP "\fBretry_pause (default: 1)\fR" -The time in seconds to wait after a memcache command fails. +The time in seconds before retrying a failed memcache command. .IP "\fBtimeout (default: 2)\fR" The time limit for sending a memcache command and for receiving a memcache reply. diff --git a/postfix/proto/DB_README.html b/postfix/proto/DB_README.html index cc6595ca1..0d4fa3906 100644 --- a/postfix/proto/DB_README.html +++ b/postfix/proto/DB_README.html @@ -33,8 +33,11 @@ before 2.0.

    -
  1. How to build Postfix on systems without -Berkeley DB library.

    +
  2. How to build Postfix without Berkeley +DB support even if the system comes with Berkeley DB.

    + +
  3. How to build Postfix on systems that +normally have no Berkeley DB library.

  4. How to build Postfix on BSD or Linux systems with multiple Berkeley DB @@ -46,8 +49,26 @@ versions.

-

Building Postfix on systems without Berkeley -DB

+

Building Postfix without Berkeley +DB support even if the system comes with Berkeley DB

+ +

Note: The following instructions apply to Postfix 2.9 and later.

+ +

Postfix will normally enable Berkeley DB support if the system +is known to have it. To build Postfix without Berkeley DB support, +build the makefiles as follows:

+ +
+
+% make makefiles CCARGS="-DNO_DB"
+% make
+
+
+ +

This will disable support for "hash" and "btree" files.

+ +

Building Postfix on systems that normally have +no Berkeley DB library

Some UNIXes ship without Berkeley DB support; for historical reasons these use DBM files instead. A problem with DBM files is @@ -73,7 +94,6 @@ source code, use something like:

-% make tidy
 % make makefiles CCARGS="-DHAS_DB -I/usr/local/BerkeleyDB/include" \
     AUXLIBS="-L/usr/local/BerkeleyDB/lib -ldb"
 % make
@@ -84,7 +104,6 @@ source code, use something like: 

-% make tidy
 % make makefiles CCARGS="-DHAS_DB -I/usr/local/BerkeleyDB/include" \
     AUXLIBS="-R/usr/local/BerkeleyDB/lib -L/usr/local/BerkeleyDB/lib -ldb"
 % make
@@ -119,7 +138,6 @@ use a variant of the following commands: 

-% make tidy
 % make makefiles CCARGS=-I/usr/include/db3 AUXLIBS=-ldb3
 % make
 
diff --git a/postfix/proto/INSTALL.html b/postfix/proto/INSTALL.html index bb436a3ae..9df6d4d92 100644 --- a/postfix/proto/INSTALL.html +++ b/postfix/proto/INSTALL.html @@ -372,6 +372,10 @@ Specifies non-default compiler arguments, for example, a non-default include directory. The following directives turn off Postfix features at compile time: + -DNO_DB Do not build with Berkeley +DB support. By default, Berkeley DB support is compiled in on +platforms that are known to support this feature. + -DNO_DEVPOLL Do not build with Solaris /dev/poll support. By default, /dev/poll support is compiled in on Solaris versions that are known to support diff --git a/postfix/proto/memcache_table b/postfix/proto/memcache_table index d4a3658c3..f64839fc1 100644 --- a/postfix/proto/memcache_table +++ b/postfix/proto/memcache_table @@ -170,9 +170,11 @@ # .IP "\fBline_size_limit (default: 1024)\fR" # The maximal memcache reply line length in bytes. # .IP "\fBmax_try (default: 2)\fR" -# The number of times to try a memcache command before giving up. +# The number of times to try a memcache command before giving +# up. The memcache client does not retry a command when the +# memcache server accepts no connection. # .IP "\fBretry_pause (default: 1)\fR" -# The time in seconds to wait after a memcache command fails. +# The time in seconds before retrying a failed memcache command. # .IP "\fBtimeout (default: 2)\fR" # The time limit for sending a memcache command and for # receiving a memcache reply. diff --git a/postfix/src/global/mail_params.c b/postfix/src/global/mail_params.c index e312f56e5..0e098b3db 100644 --- a/postfix/src/global/mail_params.c +++ b/postfix/src/global/mail_params.c @@ -173,6 +173,7 @@ #include #include #include +#include #ifdef HAS_DB #include #endif diff --git a/postfix/src/global/mail_version.h b/postfix/src/global/mail_version.h index 870efbe8c..5ea54423b 100644 --- a/postfix/src/global/mail_version.h +++ b/postfix/src/global/mail_version.h @@ -20,7 +20,7 @@ * Patches change both the patchlevel and the release date. Snapshots have no * patchlevel; they change the release date only. */ -#define MAIL_RELEASE_DATE "20120115" +#define MAIL_RELEASE_DATE "20120117" #define MAIL_VERSION_NUMBER "2.9" #ifdef SNAPSHOT diff --git a/postfix/src/postconf/Makefile.in b/postfix/src/postconf/Makefile.in index c4e6d86a6..e6a720abc 100644 --- a/postfix/src/postconf/Makefile.in +++ b/postfix/src/postconf/Makefile.in @@ -1,14 +1,14 @@ SHELL = /bin/sh SRCS = postconf.c postconf_builtin.c postconf_edit.c postconf_main.c \ postconf_master.c postconf_misc.c postconf_node.c postconf_other.c \ - postconf_service.c postconf_unused.c postconf_user.c + postconf_service.c postconf_unused.c postconf_user.c postconf_dbms.c OBJS = postconf.o postconf_builtin.o postconf_edit.o postconf_main.o \ postconf_master.o postconf_misc.o postconf_node.o postconf_other.o \ - postconf_service.o postconf_unused.o postconf_user.o + postconf_service.o postconf_unused.o postconf_user.o postconf_dbms.o HDRS = postconf.h TESTSRC = DEFS = -I. -I$(INC_DIR) -D$(SYSTYPE) -CFLAGS = $(DEBUG) $(OPT) $(DEFS) +CFLAGS = $(DEBUG) $(OPT) $(DEFS) -DLEGACY_DBMS_SUPPORT TESTPROG= MAKES = bool_table.h bool_vars.h int_table.h int_vars.h str_table.h \ str_vars.h time_table.h time_vars.h raw_table.h raw_vars.h \ @@ -42,7 +42,7 @@ test: $(TESTPROG) tests: test1 test2 test3 test4 test5 test6 test7 test8 test9 test10 test11 \ test12 test13 test14 test15 test16 test17 test18 test19 test20 test21 \ - test22 test23 test24 test25 test26 test27 + test22 test23 test24 test25 test26 test27 test28 test29 root_tests: @@ -354,6 +354,50 @@ test27: $(PROG) test27.ref diff test27.ref test27.tmp rm -f main.cf master.cf test27.tmp +# Test macro expansion, type:table parsing and scoping. + +test28: $(PROG) test28.ref + rm -f main.cf master.cf + touch main.cf master.cf + echo 'xx = proxy:ldap:foo' >> main.cf + echo 'foo_domain = bar' >> main.cf + echo 'header_checks = ldap:hh' >> main.cf + echo 'hh_domain = whatever' >> main.cf + echo 'zz = $$yy' >> main.cf + echo 'yy = aap' >> main.cf + echo 'db = memcache' >> main.cf + echo whatevershebrings unix - n n - 0 other >> master.cf + echo ' -o body_checks=$$db:zz' >> master.cf + echo 'zz_domain = whatever' >> main.cf + echo 'aa_domain = whatever' >> main.cf + ./$(PROG) -nc . >test28.tmp 2>&1 + diff test28.ref test28.tmp + rm -f main.cf master.cf test28.tmp + +# Test the handling of known and unknown database-defined suffixes. + +test29: $(PROG) test29.ref + rm -f main.cf master.cf + touch main.cf master.cf + echo 'ldapxx = proxy:ldap:ldapfoo' >> main.cf + echo 'ldapfoo_domain = bar' >> main.cf + echo 'ldapfoo_domainx = bar' >> main.cf + echo 'mysqlxx = proxy:mysql:mysqlfoo' >> main.cf + echo 'mysqlfoo_domain = bar' >> main.cf + echo 'mysqlfoo_domainx = bar' >> main.cf + echo 'pgsqlxx = proxy:pgsql:pgsqlfoo' >> main.cf + echo 'pgsqlfoo_domain = bar' >> main.cf + echo 'pgsqlfoo_domainx = bar' >> main.cf + echo 'sqlitexx = proxy:sqlite:sqlitefoo' >> main.cf + echo 'sqlitefoo_domain = bar' >> main.cf + echo 'sqlitefoo_domainx = bar' >> main.cf + echo 'memcachexx = proxy:memcache:memcachefoo' >> main.cf + echo 'memcachefoo_domain = bar' >> main.cf + echo 'memcachefoo_domainx = bar' >> main.cf + ./$(PROG) -nc . >test29.tmp 2>&1 + diff test29.ref test29.tmp + rm -f main.cf master.cf test29.tmp + printfck: $(OBJS) $(PROG) rm -rf printfck mkdir printfck @@ -441,6 +485,26 @@ postconf_builtin.o: str_table.h postconf_builtin.o: str_vars.h postconf_builtin.o: time_table.h postconf_builtin.o: time_vars.h +postconf_dbms.o: ../../include/argv.h +postconf_dbms.o: ../../include/dict.h +postconf_dbms.o: ../../include/dict_ldap.h +postconf_dbms.o: ../../include/dict_memcache.h +postconf_dbms.o: ../../include/dict_mysql.h +postconf_dbms.o: ../../include/dict_pgsql.h +postconf_dbms.o: ../../include/dict_proxy.h +postconf_dbms.o: ../../include/dict_sqlite.h +postconf_dbms.o: ../../include/htable.h +postconf_dbms.o: ../../include/mac_expand.h +postconf_dbms.o: ../../include/mac_parse.h +postconf_dbms.o: ../../include/mail_conf.h +postconf_dbms.o: ../../include/split_at.h +postconf_dbms.o: ../../include/stringops.h +postconf_dbms.o: ../../include/sys_defs.h +postconf_dbms.o: ../../include/vbuf.h +postconf_dbms.o: ../../include/vstream.h +postconf_dbms.o: ../../include/vstring.h +postconf_dbms.o: postconf.h +postconf_dbms.o: postconf_dbms.c postconf_edit.o: ../../include/argv.h postconf_edit.o: ../../include/dict.h postconf_edit.o: ../../include/edit_file.h diff --git a/postfix/src/postconf/postconf.h b/postfix/src/postconf/postconf.h index cb77952ba..8a3bb8ad9 100644 --- a/postfix/src/postconf/postconf.h +++ b/postfix/src/postconf/postconf.h @@ -161,6 +161,13 @@ extern void register_service_parameters(void); */ extern void register_user_parameters(void); + /* + * postconf_dbms.c + */ +extern void register_dbms_parameters(const char *, + const char *(*) (const char *, int, char *), + PC_MASTER_ENT *); + /* * postconf_unused.c. */ diff --git a/postfix/src/postconf/postconf_builtin.c b/postfix/src/postconf/postconf_builtin.c index 8833dc80b..1e2fed674 100644 --- a/postfix/src/postconf/postconf_builtin.c +++ b/postfix/src/postconf/postconf_builtin.c @@ -335,7 +335,7 @@ void register_builtin_parameters(void) /* * Add the built-in parameters to the global name space. The class - * (built-i) is tentative; some parameters are actually service-defined, + * (built-in) is tentative; some parameters are actually service-defined, * but they have their own default value. */ for (ctt = time_table; ctt->name; ctt++) diff --git a/postfix/src/postconf/postconf_dbms.c b/postfix/src/postconf/postconf_dbms.c new file mode 100644 index 000000000..6ac07aa26 --- /dev/null +++ b/postfix/src/postconf/postconf_dbms.c @@ -0,0 +1,231 @@ +/*++ +/* NAME +/* postconf_dbms 3 +/* SUMMARY +/* legacy support for database-defined main.cf parameter names +/* SYNOPSIS +/* #include +/* +/* void register_dbms_parameters(param_value, flag_parameter, +/* local_scope) +/* const char *param_value; +/* const char *(flag_parameter) (const char *, int, char *); +/* PC_MASTER_ENT *local_scope; +/* DESCRIPTION +/* This module implements legacy support for database configuration +/* where main.cf parameter names are generated by prepending +/* the database name to a database-defined suffix. +/* +/* Arguments: +/* .IP param_value +/* A parameter value to be searched for "type:table" strings. +/* When a database type is found that supports legacy-style +/* configuration, the table name is combined with each of the +/* database-defined suffixes to generate candidate parameter +/* names for that database type. +/* .IP flag_parameter +/* A function that takes as arguments a candidate parameter +/* name, an unused value, and a local namespace pointer. The +/* function will flag the parameter as "used" if it has a +/* "name=value" entry in the local or global namespace. +/* .IP local_scope +/* The local namespace. +/* DIAGNOSTICS +/* No explicit diagnostics. +/* LICENSE +/* .ad +/* .fi +/* The Secure Mailer license must be distributed with this software. +/* AUTHOR(S) +/* Wietse Venema +/* IBM T.J. Watson Research +/* P.O. Box 704 +/* Yorktown Heights, NY 10598, USA +/*--*/ + +/* System library. */ + +#include +#include + +/* Utility library. */ + +#include +#include +#include +#include + +/* Global library. */ + +#include +#include +#include +#include +#include +#include +#include + +/* Application-specific. */ + +#include + + /* + * SLMs. + */ +#define STR(x) vstring_str(x) + +#ifdef LEGACY_DBMS_SUPPORT + + /* + * The legacy database interface automagically instantiates a list of + * parameters by prepending the table name to database-specific suffixes. + */ + +/* See ldap_table(5). */ + +static const char *ldap_suffixes[] = { + "bind", "bind_dn", "bind_pw", "cache", "cache_expiry", "cache_size", + "chase_referrals", "debuglevel", "dereference", "domain", + "expansion_limit", "leaf_result_attribute", "query_filter", + "recursion_limit", "result_attribute", "result_format", "scope", + "search_base", "server_host", "server_port", "size_limit", + "special_result_attribute", "terminal_result_attribute", + "timeout", "version", 0, +}; + +/* See mysql_table(5). */ + +static const char *mysql_suffixes[] = { + "additional_conditions", "dbname", "domain", "expansion_limit", + "hosts", "password", "query", "result_format", "select_field", + "table", "user", "where_field", 0, +}; + +/* See pgsql_table(5). */ + +static const char *pgsql_suffixes[] = { + "additional_conditions", "dbname", "domain", "expansion_limit", + "hosts", "password", "query", "result_format", "select_field", + "select_function", "table", "user", "where_field", 0, +}; + +/* See sqlite_table(5). */ + +static const char *sqlite_suffixes[] = { + "additional_conditions", "dbpath", "domain", "expansion_limit", + "query", "result_format", "select_field", "table", "where_field", + 0, +}; + +/* See memcache_table(5). */ + +static const char *memcache_suffixes[] = { + "backup", "data_size_limit", "domain", "flags", "key_format", + "line_size_limit", "max_try", "memcache", "retry_pause", + "timeout", "ttl", 0, +}; + + /* + * Bundle up the database types and their suffix lists. + */ +typedef struct { + const char *db_type; + const char **db_suffixes; +} PC_DBMS_INFO; + +static const PC_DBMS_INFO dbms_info[] = { + DICT_TYPE_LDAP, ldap_suffixes, + DICT_TYPE_MYSQL, mysql_suffixes, + DICT_TYPE_PGSQL, pgsql_suffixes, + DICT_TYPE_SQLITE, sqlite_suffixes, + DICT_TYPE_MEMCACHE, memcache_suffixes, + 0, +}; + +/* register_dbms_parameters_cb - mac_expand() call-back */ + +static const char *register_dbms_parameters_cb(const char *mac_name, + int unused_mode, + char *context) +{ + PC_MASTER_ENT *local_scope = (PC_MASTER_ENT *) context; + const char *mac_val; + + /* + * Local namespace "name=value" settings are always explicit. They have + * precedence over global namespace "name=value" settings which are + * either explicit or defined by their default value. + */ + if (local_scope == 0 + || (mac_val = dict_get(local_scope->all_params, mac_name)) == 0) + mac_val = mail_conf_lookup(mac_name); + return (mac_val); +} + +/* register_dbms_parameters - look for database_type:prefix_name */ + +void register_dbms_parameters(const char *param_value, + const char *(flag_parameter) (const char *, int, char *), + PC_MASTER_ENT *local_scope) +{ + const PC_DBMS_INFO *dp; + char *bufp; + char *db_type; + char *prefix; + static VSTRING *buffer = 0; + static VSTRING *candidate = 0; + const char **cpp; + + /* + * Emulate Postfix parameter value expansion, prepending the appropriate + * local (master.cf "-o name-value") namespace to the global (main.cf + * "name=value") namespace. + * + * XXX This does not examine both sides of conditional macro expansion, and + * may expand the "wrong" conditional macros. This is the best we can do + * for legacy database configuration support. + */ +#define NO_SCAN_FILTER ((char *) 0) + + (void) mac_expand(buffer ? buffer : (buffer = vstring_alloc(100)), + param_value, MAC_EXP_FLAG_RECURSE, NO_SCAN_FILTER, + register_dbms_parameters_cb, (char *) local_scope); + + /* + * Naive parsing. We don't really know if the parameter specifies free + * text or a list of databases. + */ + bufp = STR(buffer); + while ((db_type = mystrtok(&bufp, " ,\t\r\n")) != 0) { + + /* + * Skip over "proxy:" indirections. + */ + while ((prefix = split_at(db_type, ':')) != 0 + && strcmp(db_type, DICT_TYPE_PROXY) == 0) + db_type = prefix; + + /* + * Look for database:prefix where the prefix is not a pathname and + * the database is a known type. Synthesize candidate parameter names + * from the user-defined prefix and from the database-defined suffix + * list, and see if those parameters have a "name=value" entry in the + * local or global namespace. + */ + if (prefix != 0 && *prefix != '/' && *prefix != '.') { + for (dp = dbms_info; dp->db_type != 0; dp++) { + if (strcmp(db_type, dp->db_type) == 0) { + for (cpp = dp->db_suffixes; *cpp; cpp++) { + vstring_sprintf(candidate ? candidate : + (candidate = vstring_alloc(30)), + "%s_%s", prefix, *cpp); + flag_parameter(STR(candidate), 0, (char *) local_scope); + } + break; + } + } + } + } +} + +#endif diff --git a/postfix/src/postconf/postconf_user.c b/postfix/src/postconf/postconf_user.c index 8e0557f03..989b7ef37 100644 --- a/postfix/src/postconf/postconf_user.c +++ b/postfix/src/postconf/postconf_user.c @@ -77,6 +77,11 @@ */ static HTABLE *rest_class_table; + /* + * SLMs. + */ +#define STR(x) vstring_str(x) + /* * Macros to make code with obscure constants more readable. */ @@ -196,16 +201,20 @@ static void scan_user_parameter_namespace(const char *dict_name, dict->sequence(dict, how, &cparam_name, &cparam_value) == 0; how = DICT_SEQ_FUN_NEXT) { if (local_scope != 0 - && PC_PARAM_TABLE_LOCATE(local_scope->valid_names, cparam_name) == 0 + && PC_PARAM_TABLE_LOCATE(local_scope->valid_names, cparam_name) == 0 && htable_locate(rest_class_table, cparam_name) != 0) PC_PARAM_TABLE_ENTER(local_scope->valid_names, cparam_name, - PC_PARAM_FLAG_USER, PC_PARAM_NO_DATA, - convert_user_parameter); + PC_PARAM_FLAG_USER, PC_PARAM_NO_DATA, + convert_user_parameter); /* Skip "do not expand" parameters. */ if ((node = PC_PARAM_TABLE_FIND(param_table, cparam_name)) != 0 && PC_RAW_PARAMETER(node)) continue; SCAN_USER_PARAMETER_VALUE(cparam_value, local_scope); +#ifdef LEGACY_DBMS_SUPPORT + register_dbms_parameters(cparam_value, flag_user_parameter, + local_scope); +#endif } } @@ -229,10 +238,11 @@ static void scan_default_parameter_values(HTABLE *valid_params, if (dict_lookup(dict_name, PC_PARAM_INFO_NAME(*ht))) continue; if ((param_value = convert_param_node(SHOW_DEFS, PC_PARAM_INFO_NAME(*ht), - PC_PARAM_INFO_NODE(*ht))) == 0) + PC_PARAM_INFO_NODE(*ht))) == 0) msg_panic("%s: parameter %s has no default value", myname, PC_PARAM_INFO_NAME(*ht)); SCAN_USER_PARAMETER_VALUE(param_value, local_scope); + /* No need to scan default values for legacy DBMS configuration. */ } myfree((char *) list); } diff --git a/postfix/src/postconf/test28.ref b/postfix/src/postconf/test28.ref new file mode 100644 index 000000000..a16ae5e02 --- /dev/null +++ b/postfix/src/postconf/test28.ref @@ -0,0 +1,10 @@ +config_directory = . +db = memcache +foo_domain = bar +header_checks = ldap:hh +hh_domain = whatever +yy = aap +zz_domain = whatever +./postconf: warning: ./main.cf: unused parameter: zz=$yy +./postconf: warning: ./main.cf: unused parameter: aa_domain=whatever +./postconf: warning: ./main.cf: unused parameter: xx=proxy:ldap:foo diff --git a/postfix/src/postconf/test29.ref b/postfix/src/postconf/test29.ref new file mode 100644 index 000000000..75a2efafd --- /dev/null +++ b/postfix/src/postconf/test29.ref @@ -0,0 +1,16 @@ +config_directory = . +ldapfoo_domain = bar +memcachefoo_domain = bar +mysqlfoo_domain = bar +pgsqlfoo_domain = bar +sqlitefoo_domain = bar +./postconf: warning: ./main.cf: unused parameter: sqlitexx=proxy:sqlite:sqlitefoo +./postconf: warning: ./main.cf: unused parameter: pgsqlxx=proxy:pgsql:pgsqlfoo +./postconf: warning: ./main.cf: unused parameter: memcachefoo_domainx=bar +./postconf: warning: ./main.cf: unused parameter: sqlitefoo_domainx=bar +./postconf: warning: ./main.cf: unused parameter: memcachexx=proxy:memcache:memcachefoo +./postconf: warning: ./main.cf: unused parameter: mysqlxx=proxy:mysql:mysqlfoo +./postconf: warning: ./main.cf: unused parameter: ldapxx=proxy:ldap:ldapfoo +./postconf: warning: ./main.cf: unused parameter: ldapfoo_domainx=bar +./postconf: warning: ./main.cf: unused parameter: pgsqlfoo_domainx=bar +./postconf: warning: ./main.cf: unused parameter: mysqlfoo_domainx=bar diff --git a/postfix/src/util/mac_expand.c b/postfix/src/util/mac_expand.c index c6974b879..f9fd2e82a 100644 --- a/postfix/src/util/mac_expand.c +++ b/postfix/src/util/mac_expand.c @@ -48,7 +48,7 @@ /* Expand macros in lookup results. This should never be done with /* data whose origin is untrusted. /* .IP MAC_EXP_FLAG_APPEND -/* Append text to the result buffer. +/* Append text to the result buffer without truncating it. /* .IP MAC_EXP_FLAG_SCAN /* Invoke the call-back function each macro name in the input /* string, including macro names in the values of conditional diff --git a/postfix/src/util/sys_defs.h b/postfix/src/util/sys_defs.h index 7bf81f7c3..b6af7cfea 100644 --- a/postfix/src/util/sys_defs.h +++ b/postfix/src/util/sys_defs.h @@ -1432,6 +1432,10 @@ typedef int WAIT_STATUS_T; #undef HAVE_POSIX_GETPW_R #endif +#ifdef NO_DB +#undef HAS_DB +#endif + #ifndef OCTAL_TO_UNSIGNED #define OCTAL_TO_UNSIGNED(res, str) ((res) = strtoul((str), (char **) 0, 8)) #endif