]> git.ipfire.org Git - thirdparty/postfix.git/commitdiff
postfix-2.9-20120117
authorWietse Venema <wietse@porcupine.org>
Tue, 17 Jan 2012 05:00:00 +0000 (00:00 -0500)
committerViktor Dukhovni <viktor@dukhovni.org>
Tue, 5 Feb 2013 06:37:57 +0000 (06:37 +0000)
23 files changed:
postfix/.indent.pro
postfix/HISTORY
postfix/README_FILES/DB_README
postfix/README_FILES/INSTALL
postfix/html/DB_README.html
postfix/html/INSTALL.html
postfix/html/memcache_table.5.html
postfix/makedefs
postfix/man/man5/memcache_table.5
postfix/proto/DB_README.html
postfix/proto/INSTALL.html
postfix/proto/memcache_table
postfix/src/global/mail_params.c
postfix/src/global/mail_version.h
postfix/src/postconf/Makefile.in
postfix/src/postconf/postconf.h
postfix/src/postconf/postconf_builtin.c
postfix/src/postconf/postconf_dbms.c [new file with mode: 0644]
postfix/src/postconf/postconf_user.c
postfix/src/postconf/test28.ref [new file with mode: 0644]
postfix/src/postconf/test29.ref [new file with mode: 0644]
postfix/src/util/mac_expand.c
postfix/src/util/sys_defs.h

index e7009d5d405e344b9ec5357992a6e4eec9e4a3a7..74d52d46f6d13896a946d20719088c54e5d357bb 100644 (file)
 -TNAME_CODE
 -TNAME_MASK
 -TNBBIO
+-TPC_DBMS_INFO
 -TPC_MASTER_ENT
 -TPC_PARAM_NODE
 -TPC_SERVICE_DEF
index 56e9bde2972c1aa126efde0d973ae53c637d4ae1..daf7b45750d4c77a11f07ea0fb1ff19c2de9ad4f 100644 (file)
@@ -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.
index 955a60ace125d01205929fb49ca8a8871131fb83..869218e4e4b7b7bb3e7097296548a1e0f747b259 100644 (file)
@@ -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.
+
+ 5. Missing pthread library trouble.
+
+B\bBu\bui\bil\bld\bdi\bin\bng\bg P\bPo\bos\bst\btf\bfi\bix\bx w\bwi\bit\bth\bho\bou\but\bt B\bBe\ber\brk\bke\bel\ble\bey\by D\bDB\bB s\bsu\bup\bpp\bpo\bor\brt\bt e\bev\bve\ben\bn i\bif\bf t\bth\bhe\be s\bsy\bys\bst\bte\bem\bm c\bco\bom\bme\bes\bs w\bwi\bit\bth\bh
+B\bBe\ber\brk\bke\bel\ble\bey\by D\bDB\bB
+
+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
 
- 4. Missing pthread library trouble.
+This will disable support for "hash" and "btree" files.
 
-B\bBu\bui\bil\bld\bdi\bin\bng\bg P\bPo\bos\bst\btf\bfi\bix\bx o\bon\bn s\bsy\bys\bst\bte\bem\bms\bw\bwi\bit\bth\bho\bou\but\bt B\bBe\ber\brk\bke\bel\ble\bey\by D\bDB\bB
+B\bBu\bui\bil\bld\bdi\bin\bng\bg P\bPo\bos\bst\btf\bfi\bix\bx o\bon\bn s\bsy\bys\bst\bte\bem\bms\bt\bth\bha\bat\bt n\bno\bor\brm\bma\bal\bll\bly\by h\bha\bav\bve\be n\bno\bo B\bBe\ber\brk\bke\bel\ble\bey\by D\bDB\bB l\bli\bib\bbr\bra\bar\bry\by
 
 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
 
index ae74b3145bc0e53b3076980ff8b4494d7a4865e9..05c7283ec267f54ca57cff53495cb9a5967716e1 100644 (file)
@@ -246,6 +246,11 @@ The following is an extensive list of names and values.
 |                              |following directives turn off Postfix features|
 |                              |at compile time:                              |
 |_\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b|_\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b |
+||                             |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.                                      |
+|_\b|_\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b|_\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b _\b |
 ||                             |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 |
index 421c7e7d3809974e9c28185d126ff2ec79f39c9d..2064d662c29e3e24cdccb237818f0053878b3d26 100644 (file)
@@ -33,8 +33,11 @@ before 2.0.  </p>
 
 <ol>
 
-<li> <p> How to build Postfix on <a href="#no_db">systems without
-Berkeley DB library</a>. </p>
+<li> <p> How to build Postfix <a href="#disable_db">without Berkeley
+DB support</a> even if the system comes with Berkeley DB. </p>
+
+<li> <p> How to build Postfix on <a href="#no_db">systems that
+normally have no Berkeley DB library</a>. </p>
 
 <li> <p> How to build Postfix on <a href="#bsd">BSD</a> or <a
 href="#linux">Linux</a> systems with multiple Berkeley DB
@@ -46,8 +49,26 @@ versions.  </p>
 
 </ol>
 
-<h2><a name="no_db">Building Postfix on systems without Berkeley
-DB</a></h2>
+<h2><a name="disable_db">Building Postfix without Berkeley
+DB support even if the system comes with Berkeley DB</a></h2>
+
+<p> Note: The following instructions apply to Postfix 2.9 and later. </p>
+
+<p> 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: </p>
+
+<blockquote>
+<pre>
+% make makefiles CCARGS="-DNO_DB"
+% make
+</pre>
+</blockquote>
+
+<p> This will disable support for "hash" and "btree" files. </p>
+
+<h2><a name="no_db">Building Postfix on systems that normally have
+no Berkeley DB library</a></h2>
 
 <p> 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: </p>
 
 <blockquote>
 <pre>
-% 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: </p>
 
 <blockquote>
 <pre>
-% 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: </p>
 
 <blockquote>
 <pre>
-% make tidy
 % make makefiles CCARGS=-I/usr/include/db3 AUXLIBS=-ldb3
 % make
 </pre>
index 8df1259747168ceb9010ec9004670c8cf77212c9..1622829abac44dee4b14f9cf1cd7067c0801a005 100644 (file)
@@ -372,6 +372,10 @@ Specifies non-default compiler arguments, for example, a non-default
 <tt>include</tt> directory.  The following directives turn
 off Postfix features at compile time:</td> </tr>
 
+<tr> <td> </td> <td> -DNO_DB </td> <td> Do not build with Berkeley
+DB support. By default, Berkeley DB support is compiled in on
+platforms that are known to support this feature.  </td> </tr>
+
 <tr> <td> </td> <td> -DNO_DEVPOLL </td> <td> Do not build with
 Solaris <tt>/dev/poll</tt> support. By default, <tt>/dev/poll</tt>
 support is compiled in on Solaris versions that are known to support
index c10aab16ac35098a4c98032cf13d6e492fc60965..c46a4d46c654402b1de63aa8b81ef8adea112088 100644 (file)
@@ -181,11 +181,13 @@ MEMCACHE_TABLE(5)                                            MEMCACHE_TABLE(5)
 
        <b>max_try (default: 2)</b>
               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.
 
        <b>retry_pause (default: 1)</b>
-              The  time  in seconds to wait after a memcache com-
-              mand fails.
+              The  time  in seconds before retrying a failed mem-
+              cache command.
 
        <b>timeout (default: 2)</b>
               The time limit for sending a memcache  command  and
index 329485f9d66fcafc7c765bd451ee255081ae1a30..316d94b483d9ef2cd6f42ab6a9dbefebe0343b1f 100644 (file)
@@ -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
index f8f286e282e468b668d2273c2fe0c33ab7c75c91..2de5980e4fccc685b474423c027b3376522def77 100644 (file)
@@ -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.
index cc6595ca1d0738b44735fa78971959d9f97d1ae3..0d4fa39065ddd16dc9d9561b7cf12187066d7a65 100644 (file)
@@ -33,8 +33,11 @@ before 2.0.  </p>
 
 <ol>
 
-<li> <p> How to build Postfix on <a href="#no_db">systems without
-Berkeley DB library</a>. </p>
+<li> <p> How to build Postfix <a href="#disable_db">without Berkeley
+DB support</a> even if the system comes with Berkeley DB. </p>
+
+<li> <p> How to build Postfix on <a href="#no_db">systems that
+normally have no Berkeley DB library</a>. </p>
 
 <li> <p> How to build Postfix on <a href="#bsd">BSD</a> or <a
 href="#linux">Linux</a> systems with multiple Berkeley DB
@@ -46,8 +49,26 @@ versions.  </p>
 
 </ol>
 
-<h2><a name="no_db">Building Postfix on systems without Berkeley
-DB</a></h2>
+<h2><a name="disable_db">Building Postfix without Berkeley
+DB support even if the system comes with Berkeley DB</a></h2>
+
+<p> Note: The following instructions apply to Postfix 2.9 and later. </p>
+
+<p> 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: </p>
+
+<blockquote>
+<pre>
+% make makefiles CCARGS="-DNO_DB"
+% make
+</pre>
+</blockquote>
+
+<p> This will disable support for "hash" and "btree" files. </p>
+
+<h2><a name="no_db">Building Postfix on systems that normally have
+no Berkeley DB library</a></h2>
 
 <p> 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: </p>
 
 <blockquote>
 <pre>
-% 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: </p>
 
 <blockquote>
 <pre>
-% 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: </p>
 
 <blockquote>
 <pre>
-% make tidy
 % make makefiles CCARGS=-I/usr/include/db3 AUXLIBS=-ldb3
 % make
 </pre>
index bb436a3ae5bcf250ab2c4563d34d41caecb794bf..9df6d4d923556f06067689bf7ced3af7ad02d591 100644 (file)
@@ -372,6 +372,10 @@ Specifies non-default compiler arguments, for example, a non-default
 <tt>include</tt> directory.  The following directives turn
 off Postfix features at compile time:</td> </tr>
 
+<tr> <td> </td> <td> -DNO_DB </td> <td> Do not build with Berkeley
+DB support. By default, Berkeley DB support is compiled in on
+platforms that are known to support this feature.  </td> </tr>
+
 <tr> <td> </td> <td> -DNO_DEVPOLL </td> <td> Do not build with
 Solaris <tt>/dev/poll</tt> support. By default, <tt>/dev/poll</tt>
 support is compiled in on Solaris versions that are known to support
index d4a3658c3bee725c8de6268264a0690efd27753b..f64839fc19c9d1e19a42ad5f597eb157fad8c20b 100644 (file)
 # .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.
index e312f56e56133ee97e2790359d8aa18825b49d6a..0e098b3dbcdc1b3e311a92c77741f44cc2a18332 100644 (file)
 #include <safe.h>
 #include <safe_open.h>
 #include <mymalloc.h>
+#include <dict.h>
 #ifdef HAS_DB
 #include <dict_db.h>
 #endif
index 870efbe8c27d41adfe3e987dfdd1560437f18ca0..5ea54423bdea2903996928a8cd6da9687c4f3835 100644 (file)
@@ -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
index c4e6d86a6372b4d10b2a4c1e4e535f491538a107..e6a720abc4791fd188ab73e105fbc70aedbd639f 100644 (file)
@@ -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
index cb77952bafe151b50187d10e9e2e9de8d024e848..8a3bb8ad9f0241fc2eb6c57553b9300142c1c5da 100644 (file)
@@ -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.
   */
index 8833dc80b6f57d034be3805e64ded51eca5ddc95..1e2fed67433d7a592f4fe86af5af6cce12e7937b 100644 (file)
@@ -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 (file)
index 0000000..6ac07aa
--- /dev/null
@@ -0,0 +1,231 @@
+/*++
+/* NAME
+/*     postconf_dbms 3
+/* SUMMARY
+/*     legacy support for database-defined main.cf parameter names
+/* SYNOPSIS
+/*     #include <postconf.h>
+/*
+/*     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 <sys_defs.h>
+#include <string.h>
+
+/* Utility library. */
+
+#include <stringops.h>
+#include <split_at.h>
+#include <mac_expand.h>
+#include <dict.h>
+
+/* Global library. */
+
+#include <mail_conf.h>
+#include <dict_proxy.h>
+#include <dict_ldap.h>
+#include <dict_mysql.h>
+#include <dict_pgsql.h>
+#include <dict_sqlite.h>
+#include <dict_memcache.h>
+
+/* Application-specific. */
+
+#include <postconf.h>
+
+ /*
+  * 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
index 8e0557f03ef5db6378ad90f48a4f48870f5a03b0..989b7ef3781e6732a91cce1d0f0cddcba512307a 100644 (file)
   */
 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 (file)
index 0000000..a16ae5e
--- /dev/null
@@ -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 (file)
index 0000000..75a2efa
--- /dev/null
@@ -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
index c6974b8794466c303e3ef957a74260db3acdcc57..f9fd2e82a34067d7cbefb928e3f03a9ab31d8c71 100644 (file)
@@ -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
index 7bf81f7c347105edf965ceca4f956fa5c3ff8ec6..b6af7cfea71c1eff8ae5aef7a45d463f86ae1852 100644 (file)
@@ -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