]> git.ipfire.org Git - thirdparty/postfix.git/commitdiff
postfix-2.2-20041208
authorWietse Venema <wietse@porcupine.org>
Wed, 8 Dec 2004 05:00:00 +0000 (00:00 -0500)
committerViktor Dukhovni <viktor@dukhovni.org>
Tue, 5 Feb 2013 06:30:15 +0000 (06:30 +0000)
40 files changed:
postfix/.indent.pro
postfix/HISTORY
postfix/README_FILES/AAAREADME
postfix/README_FILES/CDB_README [new file with mode: 0644]
postfix/README_FILES/DATABASE_README
postfix/README_FILES/STANDARD_CONFIGURATION_README
postfix/RELEASE_NOTES
postfix/conf/access
postfix/html/CDB_README.html [new file with mode: 0644]
postfix/html/DATABASE_README.html
postfix/html/RESTRICTION_CLASS_README.html
postfix/html/STANDARD_CONFIGURATION_README.html
postfix/html/UUCP_README.html
postfix/html/access.5.html
postfix/html/index.html
postfix/html/postalias.1.html
postfix/html/postmap.1.html
postfix/man/man1/postalias.1
postfix/man/man1/postmap.1
postfix/man/man5/access.5
postfix/proto/CDB_README.html [new file with mode: 0644]
postfix/proto/DATABASE_README.html
postfix/proto/Makefile.in
postfix/proto/RESTRICTION_CLASS_README.html
postfix/proto/STANDARD_CONFIGURATION_README.html
postfix/proto/UUCP_README.html
postfix/proto/access
postfix/proto/stop
postfix/src/global/Makefile.in
postfix/src/global/mail_version.h
postfix/src/global/mkmap.h
postfix/src/global/mkmap_cdb.c [new file with mode: 0644]
postfix/src/global/mkmap_open.c
postfix/src/postalias/postalias.c
postfix/src/postmap/postmap.c
postfix/src/util/Makefile.in
postfix/src/util/dict_cdb.c [new file with mode: 0644]
postfix/src/util/dict_cdb.h [new file with mode: 0644]
postfix/src/util/dict_open.c
postfix/src/util/printable.c

index 42fe93c4d752aa0b5b219d809ce440a5da835882..f84368058041a60b0c27cce00de6ba12791f966f 100644 (file)
@@ -32,6 +32,8 @@
 -TDELIVER_ATTR
 -TDELIVER_REQUEST
 -TDICT
+-TDICT_CDBM
+-TDICT_CDBQ
 -TDICT_CIDR
 -TDICT_CIDR_ENTRY
 -TDICT_DB
index 5b207bc8e847c0bd18ebbc8f0a159c68a529a470..45fbc2d84ff38237f69c11696004bfd3b0fe17fd 100644 (file)
@@ -9889,6 +9889,11 @@ Apologies for any names omitted.
        client sends a message header instead of an SMTP command.
        Magnus Baeck.  File: smtpd/smtpd.c.
 
+20041207
+
+       CDB support by Michael Tokarev, documentation by Victor
+       Duchovni. Files: util/dict_cdb.[hc], global/mkmap_cdb.c.
+
 Open problems:
 
        Med: implement ${name[?:]value} in main.cf or update the
index 19cc9a485479cd2bcf906e54a2108f3f8fd01298..1496a490d5fadeb29180db9f4390182097d9e9df 100644 (file)
@@ -38,6 +38,7 @@ L\bLo\boo\bok\bku\bup\bp t\bta\bab\bbl\ble\bes\bs (\b(d\bda\bat\bta\bab\bba\bas\bse\bes\bs)\b)
 
   * DATABASE_README: Lookup table overview
   * DB_README: Berkeley DB Howto
+  * CDB_README: CDB Howto
   * LDAP_README: LDAP Howto
   * MYSQL_README: MySQL Howto
   * PCRE_README: PCRE Howto
diff --git a/postfix/README_FILES/CDB_README b/postfix/README_FILES/CDB_README
new file mode 100644 (file)
index 0000000..7d0e36b
--- /dev/null
@@ -0,0 +1,58 @@
+P\bPo\bos\bst\btf\bfi\bix\bx C\bCD\bDB\bB H\bHo\bow\bwt\bto\bo
+
+-------------------------------------------------------------------------------
+
+I\bIn\bnt\btr\bro\bod\bdu\buc\bct\bti\bio\bon\bn
+
+CDB (Constant DataBase) is an indexed file format designed by Daniel Bernstein.
+CDB is optimized exclusively for read access and guarantees that each record
+will be read in at most two disk accesses. This is achieved by forgoing support
+for incremental updates: no single-record inserts or deletes are supported. CDB
+databases can be modified only by rebuilding them completely from scratch,
+hence the "constant" qualifier in the name.
+
+Postfix CDB databases are specified as "cdb:name", where name specifies the CDB
+file name without the ".cdb" suffix (another suffix, ".tmp", is used
+temporarily while a CDB file is under construction). CDB databases are
+maintained with the postmap(1) or postalias(1) command. The DATABASE_README
+document has general information about Postfix databases.
+
+CDB support is available with Postfix 2.2 and later releases. This document
+describes how to build Postfix with CDB support.
+
+B\bBu\bui\bil\bld\bdi\bin\bng\bg P\bPo\bos\bst\btf\bfi\bix\bx w\bwi\bit\bth\bh C\bCD\bDB\bB
+
+Postfix is compatible with two CDB implementations:
+
+  * The original cdb library from Daniel Bernstein, available from http://
+    cr.yp.to/cdb.html, and
+
+  * tinycdb (version 0.5 and later) from Michael Tokarev, available from http:/
+    /www.corpit.ru/mjt/tinycdb.html.
+
+Tinycdb is preferred, since it is a bit faster, has additional useful
+functionality and is much simpler to use.
+
+To build Postfix after you have installed CDB, use something like:
+
+    % make tidy
+    % CDB=../../../tinycdb-0.5
+    % make -f Makefile.init makefiles "CCARGS=-DHAS_CDB -I$CDB" \
+        "AUXLIBS=$CDB/libcdb.a"
+    % make
+
+    for tinycdb, or alternatively, for the D.J.B. version:
+
+    % make tidy
+    % CDB=../../../cdb-0.75
+    % make -f Makefile.init makefiles "CCARGS=-DHAS_CDB -I$CDB" \
+        "AUXLIBS=$CDB/cdb.a $CDB/alloc.a $CDB/buffer.a $CDB/unix.a $CDB/byte.a"
+    % make
+
+After postfix has been built with cdb support, you can use "cdb" tables
+wherever you can use read-only "hash", "btree" or "dbm" tables. However, the
+"p\bpo\bos\bst\btm\bma\bap\bp -\b-i\bi" (incremental record insertion) and "p\bpo\bos\bst\btm\bma\bap\bp -\b-d\bd" (incremental
+record deletion) command-line options are not available. For the same reason
+the "cdb" map type cannot be used to store the volatile address verification
+cache for the verify(8) service.
+
index 5d1fb8b9c80fc1194d3be455be83935cc3e4c144..a18c879891114bbca44b67d0ee9225e74e96fd4f 100644 (file)
@@ -123,7 +123,8 @@ Berkeley DB or other local database files, you still have a problem when the
 update fails because the disk is full or because something else happens. This
 is because commands such as postmap(1) or postalias(1) overwrite existing
 files. If the update fails in the middle then you have no usable database, and
-Postfix will stop working.
+Postfix will stop working. This is not an issue with the CDB database type
+available with Postfix 2.2 and later, because CDB database rebuilds are atomic.
 
 With multi-file databases such as DBM, there is no simple solution. With
 Berkeley DB and other "one file" databases, it is possible to add some extra
@@ -169,14 +170,20 @@ Postfix will keep using the existing database file as if nothing happened.
 
 P\bPo\bos\bst\btf\bfi\bix\bx l\blo\boo\bok\bku\bup\bp t\bta\bab\bbl\ble\be t\bty\byp\bpe\bes\bs
 
-To find out what database types your Postfix system supports, use the "postconf
--m" command. Here is a list of database types that are often supported:
+To find out what database types your Postfix system supports, use the "p\bpo\bos\bst\btc\bco\bon\bnf\bf
+-\b-m\bm" command. Here is a list of database types that are often supported:
 
     b\bbt\btr\bre\bee\be
         A sorted, balanced tree structure. This is available only on systems
         with support for Berkeley DB databases. Database files are created with
         the postmap(1) or postalias(1) command. The lookup table name as used
         in "btree:table" is the database file name without the ".db" suffix.
+    c\bcd\bdb\bb
+        A read-optimized structure with no support for incremental updates.
+        Database files are created with the postmap(1) or postalias(1) command.
+        The lookup table name as used in "cdb:table" is the database file name
+        without the ".cdb" suffix. This feature is available with Postfix 2.2
+        and later.
     c\bci\bid\bdr\br
         A table that associates values with Classless Inter-Domain Routing
         (CIDR) patterns. The table format is described in cidr_table(5).
index cdb3434264cd39c5745b28d0cf6ceae998e575f2..b1ca2920ee5337e4918f8f6621953d16e563fbcb 100644 (file)
@@ -33,7 +33,7 @@ Postfix should work out of the box without change on a stand-alone machine that
 has direct Internet access. At least, that is how Postfix installs when you
 download the Postfix source code via http://www.postfix.org/.
 
-You can use the command "postconf -n" to find out what settings are overruled
+You can use the command "p\bpo\bos\bst\btc\bco\bon\bnf\bf -\b-n\bn" to find out what settings are overruled
 by your main.cf. Besides a few pathname settings, few parameters should be set
 on a stand-alone box, beyond what is covered in the BASIC_CONFIGURATION_README
 document:
@@ -174,9 +174,9 @@ to her preferred machine:
         jane:   jane@janes.preferred.machine
 
 On some systems the alias database is not in /etc/aliases. To find out the
-location for your system, execute the command "postconf alias_maps".
+location for your system, execute the command "p\bpo\bos\bst\btc\bco\bon\bnf\bf a\bal\bli\bia\bas\bs_\b_m\bma\bap\bps\bs".
 
-Execute the command "newaliases" whenever you change the aliases file.
+Execute the command "n\bne\bew\bwa\bal\bli\bia\bas\bse\bes\bs" whenever you change the aliases file.
 
 P\bPo\bos\bst\btf\bfi\bix\bx e\bem\bma\bai\bil\bl f\bfi\bir\bre\bew\bwa\bal\bll\bl/\b/g\bga\bat\bte\bew\bwa\bay\by
 
@@ -187,7 +187,7 @@ example.com", the firewall normally also accepts mail for
 "anything.example.com". That would not be right.
 
 Note: this example requires Postfix version 2.0 and later. To find out what
-Postfix version you have, execute the command "postconf mail_version".
+Postfix version you have, execute the command "p\bpo\bos\bst\btc\bco\bon\bnf\bf m\bma\bai\bil\bl_\b_v\bve\ber\brs\bsi\bio\bon\bn".
 
 The solution is presented in multiple parts. This first part gets rid of local
 mail delivery on the firewall, making the firewall harder to break.
@@ -268,13 +268,13 @@ Translation:
   * Lines 10, 17-18: Route mail for "example.com" to the inside gateway
     machine. The [] forces Postfix to do no MX lookup.
 
-Specify dbm instead of hash if your system uses dbm files instead of db. To
-find out what lookup tables Postfix supports, use the command "postconf -m".
+Specify d\bdb\bbm\bm instead of h\bha\bas\bsh\bh if your system uses d\bdb\bbm\bm files instead of d\bdb\bb files.
+To find out what lookup tables Postfix supports, use the command "p\bpo\bos\bst\btc\bco\bon\bnf\bf -\b-m\bm".
 
-Execute the command "postmap /etc/postfix/relay_recipients" whenever you change
+Execute the command "p\bpo\bos\bst\btm\bma\bap\bp /\b/e\bet\btc\bc/\b/p\bpo\bos\bst\btf\bfi\bix\bx/\b/r\bre\bel\bla\bay\by_\b_r\bre\bec\bci\bip\bpi\bie\ben\bnt\bts\bs" whenever you change
 the relay_recipients table.
 
-Execute the command "postmap /etc/postfix/transport" whenever you change the
+Execute the command "p\bpo\bos\bst\btm\bma\bap\bp /\b/e\bet\btc\bc/\b/p\bpo\bos\bst\btf\bfi\bix\bx/\b/t\btr\bra\ban\bns\bsp\bpo\bor\brt\bt" whenever you change the
 transport table.
 
 D\bDe\bel\bli\biv\bve\ber\bri\bin\bng\bg s\bso\bom\bme\be b\bbu\but\bt n\bno\bot\bt a\bal\bll\bl a\bac\bcc\bco\bou\bun\bnt\bts\bs l\blo\boc\bca\bal\bll\bly\by
@@ -324,7 +324,7 @@ mail to the gateway host, and to send intranet mail directly. That's what
 Wietse does at work.
 
 Note: this example requires Postfix version 2.0 and later. To find out what
-Postfix version you have, execute the command "postconf mail_version".
+Postfix version you have, execute the command "p\bpo\bos\bst\btc\bco\bon\bnf\bf m\bma\bai\bil\bl_\b_v\bve\ber\brs\bsi\bio\bon\bn".
 
 The following example presents additional configuration. You need to combine
 this with basic configuration information as discussed the first half of this
@@ -356,10 +356,10 @@ Translation:
     is turned off. Postfix tries to deliver mail directly, and gives
     undeliverable mail to a gateway.
 
-Specify dbm instead of hash if your system uses dbm files instead of db. To
-find out what lookup tables Postfix supports, use the command "postconf -m".
+Specify d\bdb\bbm\bm instead of h\bha\bas\bsh\bh if your system uses d\bdb\bbm\bm files instead of d\bdb\bb files.
+To find out what lookup tables Postfix supports, use the command "p\bpo\bos\bst\btc\bco\bon\bnf\bf -\b-m\bm".
 
-Execute the command "postmap /etc/postfix/transport" whenever you edit the
+Execute the command "p\bpo\bos\bst\btm\bma\bap\bp /\b/e\bet\btc\bc/\b/p\bpo\bos\bst\btf\bfi\bix\bx/\b/t\btr\bra\ban\bns\bsp\bpo\bor\brt\bt" whenever you edit the
 transport table.
 
 C\bCo\bon\bnf\bfi\big\bgu\bur\bri\bin\bng\bg P\bPo\bos\bst\btf\bfi\bix\bx a\bas\bs M\bMX\bX h\bho\bos\bst\bt f\bfo\bor\br a\ba r\bre\bem\bmo\bot\bte\be s\bsi\bit\bte\be
@@ -418,10 +418,10 @@ Important notes:
 
   * Line 22: The [] forces Postfix to do no MX lookup.
 
-Specify dbm instead of hash if your system uses dbm files instead of db files.
-To find out what lookup tables Postfix supports, use the command "postconf -m".
+Specify d\bdb\bbm\bm instead of h\bha\bas\bsh\bh if your system uses d\bdb\bbm\bm files instead of d\bdb\bb files.
+To find out what lookup tables Postfix supports, use the command "p\bpo\bos\bst\btc\bco\bon\bnf\bf -\b-m\bm".
 
-Execute the command "postmap /etc/postfix/transport" whenever you change the
+Execute the command "p\bpo\bos\bst\btm\bma\bap\bp /\b/e\bet\btc\bc/\b/p\bpo\bos\bst\btf\bfi\bix\bx/\b/t\btr\bra\ban\bns\bsp\bpo\bor\brt\bt" whenever you change the
 transport table.
 
 P\bPo\bos\bst\btf\bfi\bix\bx o\bon\bn a\ba d\bdi\bia\bal\blu\bup\bp m\bma\bac\bch\bhi\bin\bne\be
@@ -467,7 +467,7 @@ should also study the section on "Postfix on hosts without a real hostname".
     /usr/sbin/sendmail -q (whenever the Internet link is up)
 
     The exact location of the sendmail command is system-specific. Use the
-    command "postconf sendmail_path" to find out where the Postfix sendmail
+    command "p\bpo\bos\bst\btc\bco\bon\bnf\bf s\bse\ben\bnd\bdm\bma\bai\bil\bl_\b_p\bpa\bat\bth\bh" to find out where the Postfix sendmail
     command is located on your machine.
 
     In order to find out if the mail queue is flushed, use something like:
@@ -487,7 +487,7 @@ should also study the section on "Postfix on hosts without a real hostname".
     done
 
     If you have disabled spontaneous SMTP mail delivery, you also need to run
-    the "sendmail -q" command every now and then while the dialup link is up,
+    the "s\bse\ben\bnd\bdm\bma\bai\bil\bl -\b-q\bq" command every now and then while the dialup link is up,
     so that newly-posted mail is flushed from the queue.
 
 P\bPo\bos\bst\btf\bfi\bix\bx o\bon\bn h\bho\bos\bst\bts\bs w\bwi\bit\bth\bho\bou\but\bt a\ba r\bre\bea\bal\bl h\bho\bos\bst\btn\bna\bam\bme\be
index 784c0de8aa62554cd6ea48da137c45204335a95c..0c6b2bf41cc67ec7a347045cf443de4fc366ef6b 100644 (file)
@@ -7,6 +7,13 @@ snapshot release).  Patches are issued for the official release
 and change the patchlevel and the release date. Patches are never
 issued for snapshot releases.
 
+Major changes with snapshot Postfix-2.2-20041208
+================================================
+
+Support for CDB databases by Michael Tokarev. This supports both
+Michael's tinycdb and Daniel Bernstein's cdb implementations, but
+neither of the two implementations is bundled with Postfix.
+
 Incompatible changes with snapshot Postfix-2.2-20041118
 =======================================================
 
index f8569dc7c975bbed75603838e42d1cbec8b844da..dd10ffd9722e8225c4e09e44ca6c74511bf05cf3 100644 (file)
@@ -23,7 +23,7 @@
 #        that serves as  input  to  the  postmap(1)  command.   The
 #        result,  an  indexed file in dbm or db format, is used for
 #        fast searching by the mail  system.  Execute  the  command
-#        postmap   /etc/postfix/access  in  order  to  rebuild  the
+#        "postmap  /etc/postfix/access"  in  order  to  rebuild the
 #        indexed file after changing the access table.
 # 
 #        When the table is provided via other means  such  as  NIS,
 #        The  following  example  uses an indexed file, so that the
 #        order of table entries does not matter. The  example  per-
 #        mits  access  by the client at address 1.2.3.4 but rejects
-#        all other clients in 1.2.3.0/24. Instead of "hash"  lookup
-#        tables, some systems use "dbm".  Use the command "postconf
+#        all other clients in 1.2.3.0/24. Instead  of  hash  lookup
+#        tables,  some  systems use dbm.  Use the command "postconf
 #        -m" to find out what lookup  tables  Postfix  supports  on
 #        your system.
 # 
diff --git a/postfix/html/CDB_README.html b/postfix/html/CDB_README.html
new file mode 100644 (file)
index 0000000..4506251
--- /dev/null
@@ -0,0 +1,84 @@
+<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"
+        "http://www.w3.org/TR/html4/loose.dtd">
+
+<html>
+
+<head>
+
+<title>Postfix CDB Howto</title>
+
+<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
+
+</head>
+
+<body>
+
+<h1><img src="postfix-logo.jpg" width="203" height="98" ALT="">Postfix CDB Howto</h1>
+
+<hr>
+
+<h2>Introduction</h2>
+
+<p> CDB (Constant DataBase) is an indexed file format designed by
+Daniel Bernstein. CDB is optimized exclusively for read access
+and guarantees that each record will be read in at most two disk
+accesses. This is achieved by forgoing support for incremental
+updates: no single-record inserts or deletes are supported.  CDB
+databases can be modified only by rebuilding them completely from
+scratch, hence the "constant" qualifier in the name.  </p>
+
+<p> Postfix CDB databases are specified as "cdb:<i>name</i>", where
+<i>name</i> specifies the CDB file name without the ".cdb" suffix
+(another suffix, ".tmp", is used temporarily while a CDB file is
+under construction).  CDB databases are maintained with the <a href="postmap.1.html">postmap(1)</a>
+or <a href="postalias.1.html">postalias(1)</a> command. The <a href="DATABASE_README.html">DATABASE_README</a> document has general
+information about Postfix databases.  </p>
+
+<p> CDB support is available with Postfix 2.2 and later releases.
+This document describes how to build Postfix with CDB support. </p>
+
+<h2>Building Postfix with CDB</h2>
+
+<p> Postfix is compatible with two CDB implementations: </p>
+
+<ul>
+
+<li> <p> The original cdb library from Daniel Bernstein, available
+from <a href="http://cr.yp.to/cdb.html">http://cr.yp.to/cdb.html</a>, and </p>
+
+<li> <p> tinycdb (version 0.5 and later) from Michael Tokarev,
+available from <a href="http://www.corpit.ru/mjt/tinycdb.html">http://www.corpit.ru/mjt/tinycdb.html</a>. </p>
+
+</ul>
+
+<p>  Tinycdb is preferred, since it is a bit faster, has additional
+useful functionality and is much simpler to use. </p>
+
+<p>To build Postfix after you have installed CDB, use something
+like: </p>
+
+<blockquote>
+<pre>
+% make tidy
+% CDB=../../../tinycdb-0.5
+% make -f Makefile.init makefiles "CCARGS=-DHAS_CDB -I$CDB" \
+    "AUXLIBS=$CDB/libcdb.a"
+% make
+</pre>
+for tinycdb, or alternatively, for the D.J.B. version:<br>
+<pre>
+% make tidy
+% CDB=../../../cdb-0.75
+% make -f Makefile.init makefiles "CCARGS=-DHAS_CDB -I$CDB" \
+    "AUXLIBS=$CDB/cdb.a $CDB/alloc.a $CDB/buffer.a $CDB/unix.a $CDB/byte.a"
+% make
+</pre>
+</blockquote>
+
+<p> After postfix has been built with cdb support, you can use
+"cdb" tables wherever you can use read-only "hash", "btree" or
+"dbm" tables. However, the "<b>postmap -i</b>" (incremental record
+insertion) and "<b>postmap -d</b>" (incremental record deletion)
+command-line options are not available. For the same reason the
+"cdb" map type cannot be used to store the volatile address
+verification cache for the <a href="verify.8.html">verify(8)</a> service. </p>
index 09f93d7e7d3246e484c394460a79d441f44cc7b6..42dbdabd1821557880e62c5abf93ea3e071deb80 100644 (file)
@@ -188,7 +188,9 @@ have a problem when the update fails because the disk is full or
 because something else happens.  This is because commands such as
 <a href="postmap.1.html">postmap(1)</a> or <a href="postalias.1.html">postalias(1)</a> overwrite existing files. If the update
 fails in the middle then you have no usable database, and Postfix
-will stop working. </p>
+will stop working. This is not an issue with the CDB database type
+available with Postfix 2.2 and later, because <a href="CDB_README.html">CDB</a>
+database rebuilds are atomic. </p>
 
 <p> With multi-file databases such as DBM, there is no simple
 solution. With Berkeley DB and other "one file" databases, it is
@@ -244,7 +246,7 @@ database file as if nothing happened. </p>
 <h2><a name="types">Postfix lookup table types</a> </h2>
 
 <p> To find out what database types your Postfix system supports,
-use the "postconf -m" command.  Here is a list of database types
+use the "<b>postconf -m</b>" command.  Here is a list of database types
 that are often supported: </p>
 
 <blockquote>
@@ -259,6 +261,14 @@ created with the <a href="postmap.1.html">postmap(1)</a> or <a href="postalias.1
 table name as used in "btree:table" is the database file name
 without the ".db" suffix.  </dd>
 
+<dt> <b>cdb</b> </dt>
+
+<dd> A read-optimized structure with no support for incremental updates.
+Database files are created with the <a href="postmap.1.html">postmap(1)</a> or <a href="postalias.1.html">postalias(1)</a> command.
+The lookup table name as used in "cdb:table" is the database file name
+without the ".cdb" suffix.  This feature is available with Postfix 2.2
+and later. </dd>
+
 <dt> <b>cidr</b> </dt>
 
 <dd> A table that associates values with Classless Inter-Domain
index 836ca79c8edbabe806f66f01fa873877ca9e285d..857ef431c1e1480fcfc1ed066cbf9ad784d0a2a0 100644 (file)
@@ -110,7 +110,7 @@ to IP spoofing. </p>
 </pre>
 </blockquote>
 
-<p> Specify <B>dbm</b> instead of <b>hash</b> if your system uses
+<p> Specify <b>dbm</b> instead of <b>hash</b> if your system uses
 <b>dbm</b> files instead of <b>db</b> files. To find out what map
 types Postfix supports, use the command <b>postconf -m</b>. </p>
 
@@ -209,7 +209,7 @@ with LDAP or SQL. </p>
 </pre>
 </blockquote>
 
-<p> Specify <B>dbm</b> instead of <b>hash</b> if your system uses
+<p> Specify <b>dbm</b> instead of <b>hash</b> if your system uses
 <b>dbm</b> files instead of <b>db</b> files. To find out what map
 types Postfix supports, use the command <b>postconf -m</b>. </p>
 
index 2e100cd3544c414231dffd065563f7052ff3338f..ac6caa60c9de15bbb6491216b2d265618130724d 100644 (file)
@@ -67,10 +67,10 @@ machine that has direct Internet access.  At least, that is how
 Postfix installs when you download the Postfix source code via
 <a href="http://www.postfix.org/">http://www.postfix.org/</a>. </p>
 
-<p> You can use the command "postconf -n" to find out what settings
-are overruled by your main.cf. Besides a few pathname settings,
-few parameters should be set on a stand-alone box, beyond what is
-covered in the <a href="BASIC_CONFIGURATION_README.html">BASIC_CONFIGURATION_README</a> document: </p>
+<p> You can use the command "<b>postconf -n</b>" to find out what
+settings are overruled by your main.cf. Besides a few pathname
+settings, few parameters should be set on a stand-alone box, beyond
+what is covered in the <a href="BASIC_CONFIGURATION_README.html">BASIC_CONFIGURATION_README</a> document: </p>
 
 <blockquote>
 <pre>
@@ -253,11 +253,11 @@ forwards mail to her preferred machine: </p>
 </blockquote>
 
 <p> On some systems the alias database is not in /etc/aliases.  To
-find out the location for your system, execute the command "postconf
-<a href="postconf.5.html#alias_maps">alias_maps</a>". </p>
+find out the location for your system, execute the command "<b>postconf
+<a href="postconf.5.html#alias_maps">alias_maps</a></b>". </p>
 
-<p> Execute the command "newaliases" whenever you change the aliases
-file.  </p>
+<p> Execute the command "<b>newaliases</b>" whenever you change
+the aliases file.  </p>
 
 <h2><a name="firewall">Postfix email firewall/gateway</a></h2>
 
@@ -269,8 +269,8 @@ accepts mail for "anything.example.com".  That would not be right.
 </p>
 
 <p> Note: this example requires Postfix version 2.0 and later. To find
-out what Postfix version you have, execute the command "postconf
-<a href="postconf.5.html#mail_version">mail_version</a>". </p>
+out what Postfix version you have, execute the command "<b>postconf
+<a href="postconf.5.html#mail_version">mail_version</a></b>". </p>
 
 <p> The solution is presented in multiple parts. This first part
 gets rid of local mail delivery on the firewall, making the firewall
@@ -381,14 +381,14 @@ gateway machine. The <tt>[]</tt> forces Postfix to do no MX lookup.
 
 </ul>
 
-<p>Specify dbm instead of hash if your system uses
-dbm files instead of db. To find out what lookup tables
-Postfix supports, use the command "postconf -m".  </p>
+<p>Specify <b>dbm</b> instead of <b>hash</b> if your system uses
+<b>dbm</b> files instead of <b>db</b> files. To find out what lookup
+tables Postfix supports, use the command "<b>postconf -m</b>".  </p>
 
-<p> Execute the command "postmap /etc/postfix/relay_recipients"
+<p> Execute the command "<b>postmap /etc/postfix/relay_recipients</b>"
 whenever you change the relay_recipients table. </p>
 
-<p> Execute the command "postmap /etc/postfix/transport"
+<p> Execute the command "<b>postmap /etc/postfix/transport</b>"
 whenever you change the transport table. </p>
 
 <h2><a name="some_local">Delivering some but not all accounts
@@ -449,8 +449,8 @@ mail to the gateway host, and to send intranet mail directly.
 That's what Wietse does at work.  </p>
 
 <p> Note: this example requires Postfix version 2.0 and later. To find
-out what Postfix version you have, execute the command "postconf
-<a href="postconf.5.html#mail_version">mail_version</a>". </p>
+out what Postfix version you have, execute the command "<b>postconf
+<a href="postconf.5.html#mail_version">mail_version</a></b>". </p>
 
 <p> The following example presents additional configuration. You
 need to combine this with basic configuration information as
@@ -492,11 +492,11 @@ directly, and gives undeliverable mail to a gateway.  </p>
 
 </ul>
 
-<p> Specify dbm instead of hash if your system uses dbm files
-instead of db. To find out what lookup tables Postfix supports, use
-the command "postconf -m". </p>
+<p> Specify <b>dbm</b> instead of <b>hash</b> if your system uses
+<b>dbm</b> files instead of <b>db</b> files. To find out what lookup
+tables Postfix supports, use the command "<b>postconf -m</b>". </p>
 
-<p> Execute the command "postmap /etc/postfix/transport" whenever
+<p> Execute the command "<b>postmap /etc/postfix/transport</b>" whenever
 you edit the transport table. </p>
 
 <h2><a name="backup">Configuring Postfix as MX host for a remote site</a></h2>
@@ -573,11 +573,11 @@ table. </p>
 
 </ul>
 
-<p> Specify dbm instead of hash if your system uses dbm files
-instead of db files. To find out what lookup tables Postfix supports,
-use the command "postconf -m". </p>
+<p> Specify <b>dbm</b> instead of <b>hash</b> if your system uses
+<b>dbm</b> files instead of <b>db</b> files. To find out what lookup
+tables Postfix supports, use the command "<b>postconf -m</b>". </p>
 
-<p> Execute the command "postmap /etc/postfix/transport" whenever
+<p> Execute the command "<b>postmap /etc/postfix/transport</b>" whenever
 you change the transport table. </p>
 
 <h2><a name="dialup">Postfix on a dialup machine</a></h2>
@@ -640,7 +640,7 @@ calls from being placed, disable spontaneous SMTP mail deliveries. </p>
 </pre>
 
 <p> The exact location of the sendmail command is system-specific.
-Use the command "postconf <a href="postconf.5.html#sendmail_path">sendmail_path</a>" to find out where the
+Use the command "<b>postconf <a href="postconf.5.html#sendmail_path">sendmail_path</a></b>" to find out where the
 Postfix sendmail command is located on your machine. </p>
 
 <p> In order to find out if the mail queue is flushed, use something
@@ -663,7 +663,7 @@ done
 </pre>
 
 <p> If you have disabled <a href="#spontaneous_smtp">spontaneous
-SMTP mail delivery</a>, you also need to run the "sendmail -q"
+SMTP mail delivery</a>, you also need to run the "<b>sendmail -q</b>"
 command every now and then while the dialup link is up, so that
 newly-posted mail is flushed from the queue. </p>
 
index 70dca6c9b5a7aef6aefb0a68f0e25dc199ba6a69..0a8a69d987d8f51839dd30e5ce0f8f4d419faee2 100644 (file)
@@ -122,7 +122,7 @@ whenever you change the <b>transport</b> file. </p>
     <a href="postconf.5.html#transport_maps">transport_maps</a> = hash:/etc/postfix/transport
 </pre>
 
-<p> Specify <B>dbm</b> instead of <b>hash</b> if your system uses
+<p> Specify <b>dbm</b> instead of <b>hash</b> if your system uses
 <b>dbm</b> files instead of <b>db</b> files. To find out what map
 types Postfix supports, use the command "<b>postconf -m</b>". </p>
 
index 610397949bc9325bfcf7d7a40fb3549bf67662f5..96e15a7f7409aa9055d7ecd982bd01ae747fa3a2 100644 (file)
@@ -29,7 +29,7 @@ ACCESS(5)                                               ACCESS(5)
        that serves as  input  to  the  <a href="postmap.1.html"><b>postmap</b>(1)</a>  command.   The
        result,  an  indexed file in <b>dbm</b> or <b>db</b> format, is used for
        fast searching by the mail  system.  Execute  the  command
-       <b>postmap   /etc/postfix/access</b>  in  order  to  rebuild  the
+       "<b>postmap  /etc/postfix/access</b>"  in  order  to  rebuild the
        indexed file after changing the access table.
 
        When the table is provided via other means  such  as  NIS,
@@ -292,8 +292,8 @@ ACCESS(5)                                               ACCESS(5)
        The  following  example  uses an indexed file, so that the
        order of table entries does not matter. The  example  per-
        mits  access  by the client at address 1.2.3.4 but rejects
-       all other clients in 1.2.3.0/24. Instead of "<b>hash</b>"  lookup
-       tables, some systems use "<b>dbm</b>".  Use the command "<b>postconf</b>
+       all other clients in 1.2.3.0/24. Instead  of  <b>hash</b>  lookup
+       tables,  some  systems use <b>dbm</b>.  Use the command "<b>postconf</b>
        <b>-m</b>" to find out what lookup  tables  Postfix  supports  on
        your system.
 
index d371c2c78f33cf61f707eac391519961e9ab126c..61fe3ba8e355f9cdf537a96c447ad4e727c038f1 100644 (file)
@@ -109,6 +109,8 @@ Per-client/user/etc. access </a>
 
 <li> <a href="DB_README.html"> Berkeley DB Howto  </a>
 
+<li> <a href="CDB_README.html"> CDB Howto  </a>
+
 <li> <a href="LDAP_README.html"> LDAP Howto  </a>
 
 <li> <a href="MYSQL_README.html"> MySQL Howto  </a>
index 90b821025787dc8449e6b0d28682c4c28ea51acc..44e04e3be2471755ffc9ecc0616f8ee078e62641 100644 (file)
@@ -103,9 +103,9 @@ POSTALIAS(1)                                         POSTALIAS(1)
 
        <i>file</i><b>_</b><i>type</i>
               The  database type. To find out what types are sup-
-              ported, use the "<b>postconf -m" command.</b>
+              ported, use the "<b>postconf -m</b>" command.
 
-              <b>The postalias</b> command can query any supported  file
+              The <b>postalias</b> command can query any supported  file
               type,  but  it  can  create only the following file
               types:
 
@@ -122,9 +122,6 @@ POSTALIAS(1)                                         POSTALIAS(1)
                      <i>file</i><b>_</b><i>name</i><b>.db</b>.  This  is  available  only  on
                      systems with support for <b>db</b> databases.
 
-              Use  the command <b>postconf -m</b> to find out what types
-              of database your Postfix installation can  support.
-
               When  no  <i>file</i><b>_</b><i>type</i> is specified, the software uses
               the    database    type    specified    via     the
               <b><a href="postconf.5.html#default_database_type">default_database_type</a></b> configuration parameter.  The
index 1bbe2b48b1c8181ec55c0de045a8ba0f2176f480..52b27cb339776bcab8b892cdf691bc6ab4e1fa37 100644 (file)
@@ -121,9 +121,9 @@ POSTMAP(1)                                             POSTMAP(1)
 
        <i>file</i><b>_</b><i>type</i>
               The  database type. To find out what types are sup-
-              ported, use the "<b>postconf -m" command.</b>
+              ported, use the "<b>postconf -m</b>" command.
 
-              <b>The postmap</b> command can query  any  supported  file
+              The <b>postmap</b> command can query  any  supported  file
               type,  but  it  can  create only the following file
               types:
 
@@ -140,9 +140,6 @@ POSTMAP(1)                                             POSTMAP(1)
                      <i>file</i><b>_</b><i>name</i><b>.db</b>.  This  is  available  only  on
                      systems with support for <b>db</b> databases.
 
-              Use  the command <b>postconf -m</b> to find out what types
-              of database your Postfix installation can  support.
-
               When  no  <i>file</i><b>_</b><i>type</i> is specified, the software uses
               the    database    type    specified    via     the
               <b><a href="postconf.5.html#default_database_type">default_database_type</a></b> configuration parameter.
index 9cc04b80922e807f599bcad34d4a9604b5c9237b..0990d4a29f43be7ec3ccc7f3b314c04bffc9a593 100644 (file)
@@ -87,7 +87,7 @@ existing entries, and ignore those attempts.
 Arguments:
 .IP \fIfile_type\fR
 The database type. To find out what types are supported, use
-the "\fBpostconf -m" command.
+the "\fBpostconf -m\fR" command.
 
 The \fBpostalias\fR command can query any supported file type,
 but it can create only the following file types:
@@ -103,9 +103,6 @@ This is available only on systems with support for \fBdbm\fR databases.
 The output is a hashed file, named \fIfile_name\fB.db\fR.
 This is available only on systems with support for \fBdb\fR databases.
 .PP
-Use the command \fBpostconf -m\fR to find out what types of database
-your Postfix installation can support.
-
 When no \fIfile_type\fR is specified, the software uses the database
 type specified via the \fBdefault_database_type\fR configuration
 parameter.
index c1a8e7bad784d315cfbbab394af0759bc569f93b..b0c88dc3a353c40c81068df5a6f4efb6fcf3ec25 100644 (file)
@@ -112,7 +112,7 @@ existing entries, and ignore those attempts.
 Arguments:
 .IP \fIfile_type\fR
 The database type. To find out what types are supported, use
-the "\fBpostconf -m" command.
+the "\fBpostconf -m\fR" command.
 
 The \fBpostmap\fR command can query any supported file type,
 but it can create only the following file types:
@@ -128,9 +128,6 @@ This is available only on systems with support for \fBdbm\fR databases.
 The output file is a hashed file, named \fIfile_name\fB.db\fR.
 This is available only on systems with support for \fBdb\fR databases.
 .PP
-Use the command \fBpostconf -m\fR to find out what types of database
-your Postfix installation can support.
-
 When no \fIfile_type\fR is specified, the software uses the database
 type specified via the \fBdefault_database_type\fR configuration
 parameter.
index 929411a1ed955ef549f416f118ba1133af84fc04..57e90dcdc32078d79408d9ae1c4d0d84b4c75f26 100644 (file)
@@ -28,7 +28,7 @@ Normally, the \fBaccess\fR table is specified as a text file
 that serves as input to the \fBpostmap\fR(1) command.
 The result, an indexed file in \fBdbm\fR or \fBdb\fR format,
 is used for fast searching by the mail system. Execute the command
-\fBpostmap /etc/postfix/access\fR in order to rebuild the indexed
+"\fBpostmap /etc/postfix/access\fR" in order to rebuild the indexed
 file after changing the access table.
 
 When the table is provided via other means such as NIS, LDAP
@@ -275,8 +275,8 @@ Actions are the same as with indexed file lookups.
 The following example uses an indexed file, so that the
 order of table entries does not matter. The example permits
 access by the client at address 1.2.3.4 but rejects all
-other clients in 1.2.3.0/24. Instead of "\fBhash\fR" lookup
-tables, some systems use "\fBdbm\fR".  Use the command
+other clients in 1.2.3.0/24. Instead of \fBhash\fR lookup
+tables, some systems use \fBdbm\fR.  Use the command
 "\fBpostconf -m\fR" to find out what lookup tables Postfix
 supports on your system.
 
diff --git a/postfix/proto/CDB_README.html b/postfix/proto/CDB_README.html
new file mode 100644 (file)
index 0000000..bc88967
--- /dev/null
@@ -0,0 +1,84 @@
+<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"
+        "http://www.w3.org/TR/html4/loose.dtd">
+
+<html>
+
+<head>
+
+<title>Postfix CDB Howto</title>
+
+<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
+
+</head>
+
+<body>
+
+<h1><img src="postfix-logo.jpg" width="203" height="98" ALT="">Postfix CDB Howto</h1>
+
+<hr>
+
+<h2>Introduction</h2>
+
+<p> CDB (Constant DataBase) is an indexed file format designed by
+Daniel Bernstein. CDB is optimized exclusively for read access
+and guarantees that each record will be read in at most two disk
+accesses. This is achieved by forgoing support for incremental
+updates: no single-record inserts or deletes are supported.  CDB
+databases can be modified only by rebuilding them completely from
+scratch, hence the "constant" qualifier in the name.  </p>
+
+<p> Postfix CDB databases are specified as "cdb:<i>name</i>", where
+<i>name</i> specifies the CDB file name without the ".cdb" suffix
+(another suffix, ".tmp", is used temporarily while a CDB file is
+under construction).  CDB databases are maintained with the postmap(1)
+or postalias(1) command. The DATABASE_README document has general
+information about Postfix databases.  </p>
+
+<p> CDB support is available with Postfix 2.2 and later releases.
+This document describes how to build Postfix with CDB support. </p>
+
+<h2>Building Postfix with CDB</h2>
+
+<p> Postfix is compatible with two CDB implementations: </p>
+
+<ul>
+
+<li> <p> The original cdb library from Daniel Bernstein, available
+from http://cr.yp.to/cdb.html, and </p>
+
+<li> <p> tinycdb (version 0.5 and later) from Michael Tokarev,
+available from http://www.corpit.ru/mjt/tinycdb.html. </p>
+
+</ul>
+
+<p>  Tinycdb is preferred, since it is a bit faster, has additional
+useful functionality and is much simpler to use. </p>
+
+<p>To build Postfix after you have installed CDB, use something
+like: </p>
+
+<blockquote>
+<pre>
+% make tidy
+% CDB=../../../tinycdb-0.5
+% make -f Makefile.init makefiles "CCARGS=-DHAS_CDB -I$CDB" \
+    "AUXLIBS=$CDB/libcdb.a"
+% make
+</pre>
+for tinycdb, or alternatively, for the D.J.B. version:<br>
+<pre>
+% make tidy
+% CDB=../../../cdb-0.75
+% make -f Makefile.init makefiles "CCARGS=-DHAS_CDB -I$CDB" \
+    "AUXLIBS=$CDB/cdb.a $CDB/alloc.a $CDB/buffer.a $CDB/unix.a $CDB/byte.a"
+% make
+</pre>
+</blockquote>
+
+<p> After postfix has been built with cdb support, you can use
+"cdb" tables wherever you can use read-only "hash", "btree" or
+"dbm" tables. However, the "<b>postmap -i</b>" (incremental record
+insertion) and "<b>postmap -d</b>" (incremental record deletion)
+command-line options are not available. For the same reason the
+"cdb" map type cannot be used to store the volatile address
+verification cache for the verify(8) service. </p>
index 5fbd1d8ceb53f6c561764cbc45307add78d28029..d4a25751a671b34a10594eb77cd1690fed8ff9a4 100644 (file)
@@ -188,7 +188,9 @@ have a problem when the update fails because the disk is full or
 because something else happens.  This is because commands such as
 postmap(1) or postalias(1) overwrite existing files. If the update
 fails in the middle then you have no usable database, and Postfix
-will stop working. </p>
+will stop working. This is not an issue with the CDB database type
+available with Postfix 2.2 and later, because <a href="CDB_README.html">CDB</a>
+database rebuilds are atomic. </p>
 
 <p> With multi-file databases such as DBM, there is no simple
 solution. With Berkeley DB and other "one file" databases, it is
@@ -244,7 +246,7 @@ database file as if nothing happened. </p>
 <h2><a name="types">Postfix lookup table types</a> </h2>
 
 <p> To find out what database types your Postfix system supports,
-use the "postconf -m" command.  Here is a list of database types
+use the "<b>postconf -m</b>" command.  Here is a list of database types
 that are often supported: </p>
 
 <blockquote>
@@ -259,6 +261,14 @@ created with the postmap(1) or postalias(1) command. The lookup
 table name as used in "btree:table" is the database file name
 without the ".db" suffix.  </dd>
 
+<dt> <b>cdb</b> </dt>
+
+<dd> A read-optimized structure with no support for incremental updates.
+Database files are created with the postmap(1) or postalias(1) command.
+The lookup table name as used in "cdb:table" is the database file name
+without the ".cdb" suffix.  This feature is available with Postfix 2.2
+and later. </dd>
+
 <dt> <b>cidr</b> </dt>
 
 <dd> A table that associates values with Classless Inter-Domain
index 743dc83b0d3d4ba44572ed4362f57091b107d760..2b8b84007b10512a1eb316f5cecdc9f2b4b8f3e3 100644 (file)
@@ -11,6 +11,7 @@ HTML  = ../html/ADDRESS_CLASS_README.html \
        ../html/BACKSCATTER_README.html \
        ../html/BASIC_CONFIGURATION_README.html \
        ../html/BUILTIN_FILTER_README.html \
+       ../html/CDB_README.html \
        ../html/CONTENT_INSPECTION_README.html \
        ../html/CYRUS_README.html \
        ../html/DATABASE_README.html ../html/DB_README.html \
@@ -41,6 +42,7 @@ README        = ../README_FILES/ADDRESS_CLASS_README \
        ../README_FILES/BACKSCATTER_README \
        ../README_FILES/BASIC_CONFIGURATION_README \
        ../README_FILES/BUILTIN_FILTER_README \
+       ../README_FILES/CDB_README \
        ../README_FILES/CONTENT_INSPECTION_README \
        ../README_FILES/CYRUS_README \
        ../README_FILES/DATABASE_README ../README_FILES/DB_README \
@@ -122,6 +124,9 @@ clobber:
 ../html/BACKSCATTER_README.html: BACKSCATTER_README.html
        $(POSTLINK) $? >$@
 
+../html/CDB_README.html: CDB_README.html
+       $(POSTLINK) $? >$@
+
 ../html/CONTENT_INSPECTION_README.html: CONTENT_INSPECTION_README.html
        $(POSTLINK) $? >$@
 
@@ -251,6 +256,9 @@ clobber:
 ../README_FILES/BUILTIN_FILTER_README: BUILTIN_FILTER_README.html
        $(HT2READ) $? >$@
 
+../README_FILES/CDB_README: CDB_README.html
+       $(HT2READ) $? >$@
+
 ../README_FILES/CONTENT_INSPECTION_README: CONTENT_INSPECTION_README.html
        $(HT2READ) $? >$@
 
index 7d9ad751f8750519a57fa19987d4250711bfde1a..3c5ca182553b6b0dc634133a9357551a60237ee9 100644 (file)
@@ -110,7 +110,7 @@ to IP spoofing. </p>
 </pre>
 </blockquote>
 
-<p> Specify <B>dbm</b> instead of <b>hash</b> if your system uses
+<p> Specify <b>dbm</b> instead of <b>hash</b> if your system uses
 <b>dbm</b> files instead of <b>db</b> files. To find out what map
 types Postfix supports, use the command <b>postconf -m</b>. </p>
 
@@ -209,7 +209,7 @@ with LDAP or SQL. </p>
 </pre>
 </blockquote>
 
-<p> Specify <B>dbm</b> instead of <b>hash</b> if your system uses
+<p> Specify <b>dbm</b> instead of <b>hash</b> if your system uses
 <b>dbm</b> files instead of <b>db</b> files. To find out what map
 types Postfix supports, use the command <b>postconf -m</b>. </p>
 
index 5b0cbc3416143ca2c5d3f299829f51b75a815443..c3999645e7dd4a3ed0052f7f5dda40c8cdb7ce8b 100644 (file)
@@ -67,10 +67,10 @@ machine that has direct Internet access.  At least, that is how
 Postfix installs when you download the Postfix source code via
 http://www.postfix.org/. </p>
 
-<p> You can use the command "postconf -n" to find out what settings
-are overruled by your main.cf. Besides a few pathname settings,
-few parameters should be set on a stand-alone box, beyond what is
-covered in the BASIC_CONFIGURATION_README document: </p>
+<p> You can use the command "<b>postconf -n</b>" to find out what
+settings are overruled by your main.cf. Besides a few pathname
+settings, few parameters should be set on a stand-alone box, beyond
+what is covered in the BASIC_CONFIGURATION_README document: </p>
 
 <blockquote>
 <pre>
@@ -253,11 +253,11 @@ forwards mail to her preferred machine: </p>
 </blockquote>
 
 <p> On some systems the alias database is not in /etc/aliases.  To
-find out the location for your system, execute the command "postconf
-alias_maps". </p>
+find out the location for your system, execute the command "<b>postconf
+alias_maps</b>". </p>
 
-<p> Execute the command "newaliases" whenever you change the aliases
-file.  </p>
+<p> Execute the command "<b>newaliases</b>" whenever you change
+the aliases file.  </p>
 
 <h2><a name="firewall">Postfix email firewall/gateway</a></h2>
 
@@ -269,8 +269,8 @@ accepts mail for "anything.example.com".  That would not be right.
 </p>
 
 <p> Note: this example requires Postfix version 2.0 and later. To find
-out what Postfix version you have, execute the command "postconf
-mail_version". </p>
+out what Postfix version you have, execute the command "<b>postconf
+mail_version</b>". </p>
 
 <p> The solution is presented in multiple parts. This first part
 gets rid of local mail delivery on the firewall, making the firewall
@@ -381,14 +381,14 @@ gateway machine. The <tt>[]</tt> forces Postfix to do no MX lookup.
 
 </ul>
 
-<p>Specify dbm instead of hash if your system uses
-dbm files instead of db. To find out what lookup tables
-Postfix supports, use the command "postconf -m".  </p>
+<p>Specify <b>dbm</b> instead of <b>hash</b> if your system uses
+<b>dbm</b> files instead of <b>db</b> files. To find out what lookup
+tables Postfix supports, use the command "<b>postconf -m</b>".  </p>
 
-<p> Execute the command "postmap /etc/postfix/relay_recipients"
+<p> Execute the command "<b>postmap /etc/postfix/relay_recipients</b>"
 whenever you change the relay_recipients table. </p>
 
-<p> Execute the command "postmap /etc/postfix/transport"
+<p> Execute the command "<b>postmap /etc/postfix/transport</b>"
 whenever you change the transport table. </p>
 
 <h2><a name="some_local">Delivering some but not all accounts
@@ -449,8 +449,8 @@ mail to the gateway host, and to send intranet mail directly.
 That's what Wietse does at work.  </p>
 
 <p> Note: this example requires Postfix version 2.0 and later. To find
-out what Postfix version you have, execute the command "postconf
-mail_version". </p>
+out what Postfix version you have, execute the command "<b>postconf
+mail_version</b>". </p>
 
 <p> The following example presents additional configuration. You
 need to combine this with basic configuration information as
@@ -492,11 +492,11 @@ directly, and gives undeliverable mail to a gateway.  </p>
 
 </ul>
 
-<p> Specify dbm instead of hash if your system uses dbm files
-instead of db. To find out what lookup tables Postfix supports, use
-the command "postconf -m". </p>
+<p> Specify <b>dbm</b> instead of <b>hash</b> if your system uses
+<b>dbm</b> files instead of <b>db</b> files. To find out what lookup
+tables Postfix supports, use the command "<b>postconf -m</b>". </p>
 
-<p> Execute the command "postmap /etc/postfix/transport" whenever
+<p> Execute the command "<b>postmap /etc/postfix/transport</b>" whenever
 you edit the transport table. </p>
 
 <h2><a name="backup">Configuring Postfix as MX host for a remote site</a></h2>
@@ -573,11 +573,11 @@ table. </p>
 
 </ul>
 
-<p> Specify dbm instead of hash if your system uses dbm files
-instead of db files. To find out what lookup tables Postfix supports,
-use the command "postconf -m". </p>
+<p> Specify <b>dbm</b> instead of <b>hash</b> if your system uses
+<b>dbm</b> files instead of <b>db</b> files. To find out what lookup
+tables Postfix supports, use the command "<b>postconf -m</b>". </p>
 
-<p> Execute the command "postmap /etc/postfix/transport" whenever
+<p> Execute the command "<b>postmap /etc/postfix/transport</b>" whenever
 you change the transport table. </p>
 
 <h2><a name="dialup">Postfix on a dialup machine</a></h2>
@@ -640,7 +640,7 @@ calls from being placed, disable spontaneous SMTP mail deliveries. </p>
 </pre>
 
 <p> The exact location of the sendmail command is system-specific.
-Use the command "postconf sendmail_path" to find out where the
+Use the command "<b>postconf sendmail_path</b>" to find out where the
 Postfix sendmail command is located on your machine. </p>
 
 <p> In order to find out if the mail queue is flushed, use something
@@ -663,7 +663,7 @@ done
 </pre>
 
 <p> If you have disabled <a href="#spontaneous_smtp">spontaneous
-SMTP mail delivery</a>, you also need to run the "sendmail -q"
+SMTP mail delivery</a>, you also need to run the "<b>sendmail -q</b>"
 command every now and then while the dialup link is up, so that
 newly-posted mail is flushed from the queue. </p>
 
index e4af2829a64f78c6f277ad891e1d2bef77149750..c614ceeb3ed365d76be06fcb41112e222f16b716 100644 (file)
@@ -122,7 +122,7 @@ whenever you change the <b>transport</b> file. </p>
     transport_maps = hash:/etc/postfix/transport
 </pre>
 
-<p> Specify <B>dbm</b> instead of <b>hash</b> if your system uses
+<p> Specify <b>dbm</b> instead of <b>hash</b> if your system uses
 <b>dbm</b> files instead of <b>db</b> files. To find out what map
 types Postfix supports, use the command "<b>postconf -m</b>". </p>
 
index f5825882ded17287ab8992067fc566fdf51504b9..e4d3efb7a0dd280116e4d14f1a9213c2f02f7070 100644 (file)
@@ -22,7 +22,7 @@
 #      that serves as input to the \fBpostmap\fR(1) command.
 #      The result, an indexed file in \fBdbm\fR or \fBdb\fR format,
 #      is used for fast searching by the mail system. Execute the command
-#      \fBpostmap /etc/postfix/access\fR in order to rebuild the indexed
+#      "\fBpostmap /etc/postfix/access\fR" in order to rebuild the indexed
 #      file after changing the access table.
 #
 #      When the table is provided via other means such as NIS, LDAP
 #      The following example uses an indexed file, so that the
 #      order of table entries does not matter. The example permits
 #      access by the client at address 1.2.3.4 but rejects all
-#      other clients in 1.2.3.0/24. Instead of "\fBhash\fR" lookup
-#      tables, some systems use "\fBdbm\fR".  Use the command
+#      other clients in 1.2.3.0/24. Instead of \fBhash\fR lookup
+#      tables, some systems use \fBdbm\fR.  Use the command
 #      "\fBpostconf -m\fR" to find out what lookup tables Postfix
 #      supports on your system.
 #
index c5cf9688c9ac235a0e3187c7be7a54979eddf381..e7f75c98d87237476f9d6f24b81019d2c721bc37 100644 (file)
@@ -10,6 +10,7 @@ README
 RFC
 Sendmail's
 Wietse
+cdb
 cf
 com
 db
@@ -91,6 +92,7 @@ sysadmin
 userid
 username
 Autoreplies
+CDB
 DBM
 Howto
 MAILDROP
index 09305f61b1116d4fb171947915630169377ce1f2..3d5dd511e1f1928cbcec5d76b8277ee3dd9e0bc0 100644 (file)
@@ -14,7 +14,7 @@ SRCS  = abounce.c anvil_clnt.c been_here.c bounce.c bounce_log.c \
        mail_open_ok.c mail_params.c mail_pathname.c mail_queue.c \
        mail_run.c mail_scan_dir.c mail_stream.c mail_task.c mail_trigger.c \
        maps.c mark_corrupt.c match_parent_style.c mbox_conf.c \
-       mbox_open.c mime_state.c mkmap_db.c mkmap_dbm.c mkmap_open.c \
+       mbox_open.c mime_state.c mkmap_db.c mkmap_cdb.c mkmap_dbm.c mkmap_open.c \
        mynetworks.c mypwd.c namadr_list.c off_cvt.c opened.c \
        own_inet_addr.c pipe_command.c post_mail.c quote_821_local.c \
        quote_822_local.c rec_streamlf.c rec_type.c recipient_list.c \
@@ -39,7 +39,7 @@ OBJS  = abounce.o anvil_clnt.o been_here.o bounce.o bounce_log.o \
        mail_open_ok.o mail_params.o mail_pathname.o mail_queue.o \
        mail_run.o mail_scan_dir.o mail_stream.o mail_task.o mail_trigger.o \
        maps.o mark_corrupt.o match_parent_style.o mbox_conf.o \
-       mbox_open.o mime_state.o mkmap_db.o mkmap_dbm.o mkmap_open.o \
+       mbox_open.o mime_state.o mkmap_db.o mkmap_cdb.o mkmap_dbm.o mkmap_open.o \
        mynetworks.o mypwd.o namadr_list.o off_cvt.o opened.o \
        own_inet_addr.o pipe_command.o post_mail.o quote_821_local.o \
        quote_822_local.o rec_streamlf.o rec_type.o recipient_list.o \
@@ -1031,6 +1031,8 @@ mime_state.o: mail_params.h
 mime_state.o: header_token.h
 mime_state.o: lex_822.h
 mime_state.o: mime_state.h
+mkmap_cdb.o: mkmap_cdb.c
+mkmap_cdb.o: ../../include/sys_defs.h
 mkmap_db.o: mkmap_db.c
 mkmap_db.o: ../../include/sys_defs.h
 mkmap_db.o: ../../include/msg.h
@@ -1066,6 +1068,7 @@ mkmap_open.o: ../../include/vstream.h
 mkmap_open.o: ../../include/vbuf.h
 mkmap_open.o: ../../include/argv.h
 mkmap_open.o: ../../include/dict_db.h
+mkmap_open.o: ../../include/dict_cdb.h
 mkmap_open.o: ../../include/dict_dbm.h
 mkmap_open.o: ../../include/sigdelay.h
 mkmap_open.o: ../../include/mymalloc.h
index 4386c68529b284e7c0ad51b705d978f1c9e9279f..8572c42a91b604a7cbd6f6d3b588b8f4be7b8b97 100644 (file)
@@ -20,7 +20,7 @@
   * Patches change the patchlevel and the release date. Snapshots change the
   * release date only.
   */
-#define MAIL_RELEASE_DATE      "20041207"
+#define MAIL_RELEASE_DATE      "20041208"
 #define MAIL_VERSION_NUMBER    "2.2"
 
 #define VAR_MAIL_VERSION       "mail_version"
index fc23d64d5061f666aa63a1686edd09c77432cddd..848dbc003fdedd0ec9ebbfd8bd0eff29a7f63da2 100644 (file)
@@ -36,6 +36,7 @@ extern void mkmap_close(MKMAP *);
 #define mkmap_append(map, key, val) dict_put((map)->dict, (key), (val))
 
 extern MKMAP *mkmap_dbm_open(const char *);
+extern MKMAP *mkmap_cdb_open(const char *);
 extern MKMAP *mkmap_hash_open(const char *);
 extern MKMAP *mkmap_btree_open(const char *);
 
diff --git a/postfix/src/global/mkmap_cdb.c b/postfix/src/global/mkmap_cdb.c
new file mode 100644 (file)
index 0000000..83bf96d
--- /dev/null
@@ -0,0 +1,65 @@
+/*++
+/* NAME
+/*     mkmap_cdb 3
+/* SUMMARY
+/*     create or open database, CDB style
+/* SYNOPSIS
+/*     #include <mkmap.h>
+/*
+/*     MKMAP   *mkmap_cdb_open(path)
+/*     const char *path;
+/*
+/* DESCRIPTION
+/*     This module implements support for creating DJB's CDB "constant
+/*     databases".
+/*
+/*     mkmap_cdb_open() take a file name, append the ".cdb.tmp" suffix,
+/*     create the named DB database.  On close, this file renamed to
+/*     file name with ".cdb" suffix appended (without ".tmp" part).
+/*     This routine is a CDB-specific helper for the more
+/*     general mkmap_open() interface.
+/*
+/*     All errors are fatal.
+/* SEE ALSO
+/*     dict_cdb(3), CDB dictionary interface.
+/* LICENSE
+/* .ad
+/* .fi
+/*     The Secure Mailer license must be distributed with this software.
+/* AUTHOR(S)
+/*     Written by Michael Tokarev <mjt@tls.msk.ru> based on mkmap_db by
+/*     Wietse Venema
+/*     IBM T.J. Watson Research
+/*     P.O. Box 704
+/*     Yorktown Heights, NY 10598, USA
+/*--*/
+
+/* System library. */
+
+#include <sys_defs.h>
+
+#ifdef HAS_CDB
+
+/* Utility library. */
+
+#include <mymalloc.h>
+#include <dict.h>
+
+/* Application-specific. */
+
+#include "mkmap.h"
+#include <dict_cdb.h>
+
+/* This is a dummy module, since CDB has all the functionality
+ * built-in, as cdb creation requires one global lock anyway. */
+
+MKMAP *mkmap_cdb_open(const char *unused_path)
+{
+    MKMAP  *mkmap = (MKMAP *) mymalloc(sizeof(*mkmap));
+    mkmap->open = dict_cdb_open;
+    mkmap->after_open = 0;
+    mkmap->after_close = 0;
+    return (mkmap);
+}
+
+#endif /* HAS_CDB */
index dd6f6e642521a5769d85a0abdef16c7a0f065d4e..a972f06b0cd865b7ce4559bbbb36e7ccde0034e4 100644 (file)
@@ -63,6 +63,7 @@
 #include <msg.h>
 #include <dict.h>
 #include <dict_db.h>
+#include <dict_cdb.h>
 #include <dict_dbm.h>
 #include <sigdelay.h>
 #include <mymalloc.h>
@@ -81,6 +82,9 @@ typedef struct {
 } MKMAP_OPEN_INFO;
 
 MKMAP_OPEN_INFO mkmap_types[] = {
+#ifdef HAS_CDB
+    DICT_TYPE_CDB, mkmap_cdb_open,
+#endif
 #ifdef HAS_DBM
     DICT_TYPE_DBM, mkmap_dbm_open,
 #endif
index 53c26ee762940df237030db187a0c019cb653cae..ba02e9b3239c552d059fb450f297b01e63d081f2 100644 (file)
@@ -81,7 +81,7 @@
 /*     Arguments:
 /* .IP \fIfile_type\fR
 /*     The database type. To find out what types are supported, use
-/*     the "\fBpostconf -m" command.
+/*     the "\fBpostconf -m\fR" command.
 /*
 /*     The \fBpostalias\fR command can query any supported file type,
 /*     but it can create only the following file types:
@@ -97,9 +97,6 @@
 /*     The output is a hashed file, named \fIfile_name\fB.db\fR.
 /*     This is available only on systems with support for \fBdb\fR databases.
 /* .PP
-/*     Use the command \fBpostconf -m\fR to find out what types of database
-/*     your Postfix installation can support.
-/*
 /*     When no \fIfile_type\fR is specified, the software uses the database
 /*     type specified via the \fBdefault_database_type\fR configuration
 /*     parameter.
index b307721c4f543a8e6addb4914151c105c354cc22..0499b6f0035be7184a9ceca458161c18d1ccf2cf 100644 (file)
 /*     Arguments:
 /* .IP \fIfile_type\fR
 /*     The database type. To find out what types are supported, use
-/*     the "\fBpostconf -m" command.
+/*     the "\fBpostconf -m\fR" command.
 /*
 /*     The \fBpostmap\fR command can query any supported file type,
 /*     but it can create only the following file types:
 /*     The output file is a hashed file, named \fIfile_name\fB.db\fR.
 /*     This is available only on systems with support for \fBdb\fR databases.
 /* .PP
-/*     Use the command \fBpostconf -m\fR to find out what types of database
-/*     your Postfix installation can support.
-/*
 /*     When no \fIfile_type\fR is specified, the software uses the database
 /*     type specified via the \fBdefault_database_type\fR configuration
 /*     parameter.
index 21170ea26a4a21c9071edfec50295864afdb3d07..37d0736f19a62414df6719460fb841a12646a0f2 100644 (file)
@@ -2,7 +2,7 @@ SHELL   = /bin/sh
 SRCS   = alldig.c argv.c argv_split.c attr_print0.c attr_print64.c \
        attr_scan0.c attr_scan64.c base64_code.c basename.c binhash.c \
        chroot_uid.c clean_env.c close_on_exec.c concatenate.c ctable.c \
-       dict.c dict_alloc.c dict_db.c dict_dbm.c dict_debug.c dict_env.c \
+       dict.c dict_alloc.c dict_db.c dict_cdb.c dict_dbm.c dict_debug.c dict_env.c \
        dict_cidr.c dict_ht.c dict_ni.c dict_nis.c \
        dict_nisplus.c dict_open.c dict_pcre.c dict_regexp.c \
        dict_static.c dict_tcp.c dict_unix.c dir_forest.c doze.c \
@@ -32,7 +32,7 @@ SRCS  = alldig.c argv.c argv_split.c attr_print0.c attr_print64.c \
 OBJS   = alldig.o argv.o argv_split.o attr_print0.o attr_print64.o \
        attr_scan0.o attr_scan64.o base64_code.o basename.o binhash.o \
        chroot_uid.o clean_env.o close_on_exec.o concatenate.o ctable.o \
-       dict.o dict_alloc.o dict_db.o dict_dbm.o dict_debug.o dict_env.o \
+       dict.o dict_alloc.o dict_db.o dict_cdb.o dict_dbm.o dict_debug.o dict_env.o \
        dict_cidr.o dict_ht.o dict_ni.o dict_nis.o \
        dict_nisplus.o dict_open.o dict_pcre.o dict_regexp.o \
        dict_static.o dict_tcp.o dict_unix.o dir_forest.o doze.o \
@@ -60,7 +60,7 @@ OBJS  = alldig.o argv.o argv_split.o attr_print0.o attr_print64.o \
        attr_print_plain.o sane_connect.o $(STRCASE) neuter.o name_code.o \
        uppercase.o unix_recv_fd.o stream_recv_fd.o unix_send_fd.o stream_send_fd.o
 HDRS   = argv.h attr.h base64_code.h binhash.h chroot_uid.h clean_env.h \
-       connect.h ctable.h dict.h dict_db.h dict_dbm.h dict_env.h \
+       connect.h ctable.h dict.h dict_db.h dict_cdb.h dict_dbm.h dict_env.h \
        dict_cidr.h dict_ht.h dict_ni.h dict_nis.h \
        dict_nisplus.h dict_pcre.h dict_regexp.h \
        dict_static.h dict_tcp.h dict_unix.h dir_forest.h events.h \
@@ -622,6 +622,8 @@ dict_alloc.o: dict.h
 dict_alloc.o: vstream.h
 dict_alloc.o: vbuf.h
 dict_alloc.o: argv.h
+dict_cdb.o: dict_cdb.c
+dict_cdb.o: sys_defs.h
 dict_cidr.o: dict_cidr.c
 dict_cidr.o: sys_defs.h
 dict_cidr.o: mymalloc.h
@@ -708,6 +710,7 @@ dict_open.o: msg.h
 dict_open.o: dict.h
 dict_open.o: vstream.h
 dict_open.o: vbuf.h
+dict_open.o: dict_cdb.h
 dict_open.o: dict_env.h
 dict_open.o: dict_unix.h
 dict_open.o: dict_tcp.h
diff --git a/postfix/src/util/dict_cdb.c b/postfix/src/util/dict_cdb.c
new file mode 100644 (file)
index 0000000..a66004d
--- /dev/null
@@ -0,0 +1,374 @@
+/*++
+/* NAME
+/*     dict_cdb 3
+/* SUMMARY
+/*     dictionary manager interface to CDB files
+/* SYNOPSIS
+/*     #include <dict_cdb.h>
+/*
+/*     DICT    *dict_cdb_open(path, open_flags, dict_flags)
+/*     const char *path;
+/*     int     open_flags;
+/*     int     dict_flags;
+/*
+/* DESCRIPTION
+/*     dict_cdb_open() opens the specified CDB database.  The result is
+/*     a pointer to a structure that can be used to access the dictionary
+/*     using the generic methods documented in dict_open(3).
+/*
+/*     Arguments:
+/* .IP path
+/*     The database pathname, not including the ".cdb" suffix.
+/* .IP open_flags
+/*     Flags passed to open(). Specify O_RDONLY or O_WRONLY|O_CREAT|O_TRUNC.
+/* .IP dict_flags
+/*     Flags used by the dictionary interface.
+/* SEE ALSO
+/*     dict(3) generic dictionary manager
+/* DIAGNOSTICS
+/*     Fatal errors: cannot open file, write error, out of memory.
+/* LICENSE
+/* .ad
+/* .fi
+/*     The Secure Mailer license must be distributed with this software.
+/* AUTHOR(S)
+/*     Michael Tokarev <mjt@tls.msk.ru> based on dict_db.c by
+/*     Wietse Venema
+/*     IBM T.J. Watson Research
+/*     P.O. Box 704
+/*     Yorktown Heights, NY 10598, USA
+/*--*/
+
+#include "sys_defs.h"
+
+/* System library. */
+
+#include <sys/stat.h>
+#include <limits.h>
+#include <string.h>
+#include <unistd.h>
+#include <stdio.h>
+
+/* Utility library. */
+
+#include "msg.h"
+#include "mymalloc.h"
+#include "vstring.h"
+#include "stringops.h"
+#include "iostuff.h"
+#include "myflock.h"
+#include "dict.h"
+#include "dict_cdb.h"
+
+#ifdef HAS_CDB
+
+#include <cdb.h>
+#ifndef TINYCDB_VERSION
+#include <cdb_make.h>
+#endif
+#ifndef cdb_fileno
+#define cdb_fileno(c) ((c)->fd)
+#endif
+
+#ifndef CDB_SUFFIX
+#define CDB_SUFFIX ".cdb"
+#endif
+#ifndef CDB_TMP_SUFFIX
+#define CDB_TMP_SUFFIX CDB_SUFFIX ".tmp"
+#endif
+
+/* Application-specific. */
+
+typedef struct {
+    DICT    dict;                      /* generic members */
+    struct cdb cdb;                    /* cdb structure */
+} DICT_CDBQ;                           /* query interface */
+
+typedef struct {
+    DICT    dict;                      /* generic members */
+    struct cdb_make cdbm;              /* cdb_make structure */
+    char   *cdb_path;                  /* cdb pathname (.cdb) */
+    char   *tmp_path;                  /* temporary pathname (.tmp) */
+} DICT_CDBM;                           /* rebuild interface */
+
+/* dict_cdbq_lookup - find database entry, query mode */
+
+static const char *dict_cdbq_lookup(DICT *dict, const char *name)
+{
+    DICT_CDBQ *dict_cdbq = (DICT_CDBQ *) dict;
+    unsigned vlen;
+    int     status = 0;
+    static char *buf;
+    static unsigned len;
+    const char *result = 0;
+
+    dict_errno = 0;
+
+    /* CDB is constant, so do not try to acquire a lock. */
+
+    /*
+     * See if this CDB file was written with one null byte appended to key
+     * and value.
+     */
+    if (dict->flags & DICT_FLAG_TRY1NULL) {
+       status = cdb_find(&dict_cdbq->cdb, name, strlen(name) + 1);
+       if (status > 0)
+           dict->flags &= ~DICT_FLAG_TRY0NULL;
+    }
+
+    /*
+     * See if this CDB file was written with no null byte appended to key and
+     * value.
+     */
+    if (status == 0 && (dict->flags & DICT_FLAG_TRY0NULL)) {
+       status = cdb_find(&dict_cdbq->cdb, name, strlen(name));
+       if (status > 0)
+           dict->flags &= ~DICT_FLAG_TRY1NULL;
+    }
+    if (status < 0)
+       msg_fatal("error reading %s: %m", dict->name);
+
+    if (status) {
+       vlen = cdb_datalen(&dict_cdbq->cdb);
+       if (len < vlen) {
+           if (buf == 0)
+               buf = mymalloc(vlen + 1);
+           else
+               buf = myrealloc(buf, vlen + 1);
+           len = vlen;
+       }
+       if (cdb_read(&dict_cdbq->cdb, buf, vlen,
+                    cdb_datapos(&dict_cdbq->cdb)) < 0)
+           msg_fatal("error reading %s: %m", dict->name);
+       buf[vlen] = '\0';
+       result = buf;
+    }
+    /* No locking so not release the lock.  */
+
+    return (result);
+}
+
+/* dict_cdbq_close - close data base, query mode */
+
+static void dict_cdbq_close(DICT *dict)
+{
+    DICT_CDBQ *dict_cdbq = (DICT_CDBQ *) dict;
+
+    cdb_free(&dict_cdbq->cdb);
+    close(dict->stat_fd);
+    dict_free(dict);
+}
+
+/* dict_cdbq_open - open data base, query mode */
+
+static DICT *dict_cdbq_open(const char *path, int dict_flags)
+{
+    DICT_CDBQ *dict_cdbq;
+    struct stat st;
+    char   *cdb_path;
+    int     fd;
+
+    cdb_path = concatenate(path, CDB_SUFFIX, (char *) 0);
+
+    if ((fd = open(cdb_path, O_RDONLY)) < 0)
+       msg_fatal("open database %s: %m", cdb_path);
+
+    dict_cdbq = (DICT_CDBQ *) dict_alloc(DICT_TYPE_CDB,
+                                        cdb_path, sizeof(*dict_cdbq));
+#if defined(TINYCDB_VERSION)
+    if (cdb_init(&(dict_cdbq->cdb), fd) != 0)
+       msg_fatal("dict_cdbq_open: unable to init %s: %m", cdb_path);
+#else
+    cdb_init(&(dict_cdbq->cdb), fd);
+#endif
+    dict_cdbq->dict.lookup = dict_cdbq_lookup;
+    dict_cdbq->dict.close = dict_cdbq_close;
+    dict_cdbq->dict.stat_fd = fd;
+    if (fstat(fd, &st) < 0)
+       msg_fatal("dict_dbq_open: fstat: %m");
+    dict_cdbq->dict.mtime = st.st_mtime;
+    close_on_exec(fd, CLOSE_ON_EXEC);
+
+    /*
+     * If undecided about appending a null byte to key and value, choose to
+     * try both in query mode.
+     */
+    if ((dict_flags & (DICT_FLAG_TRY1NULL | DICT_FLAG_TRY0NULL)) == 0)
+       dict_flags |= DICT_FLAG_TRY0NULL | DICT_FLAG_TRY1NULL;
+    dict_cdbq->dict.flags = dict_flags | DICT_FLAG_FIXED;
+
+    myfree(cdb_path);
+    return (&dict_cdbq->dict);
+}
+
+/* dict_cdbm_update - add database entry, create mode */
+
+static void dict_cdbm_update(DICT *dict, const char *name, const char *value)
+{
+    DICT_CDBM *dict_cdbm = (DICT_CDBM *) dict;
+    unsigned ksize,
+            vsize;
+    int     r;
+
+    ksize = strlen(name);
+    vsize = strlen(value);
+
+    /*
+     * Optionally append a null byte to key and value.
+     */
+    if (dict->flags & DICT_FLAG_TRY1NULL) {
+       ksize++;
+       vsize++;
+    }
+
+    /*
+     * Do the add operation.  No locking is done.
+     */
+#ifdef TINYCDB_VERSION
+#ifndef CDB_PUT_ADD
+#error please upgrate tinycdb to at least 0.5 version
+#endif
+    if (dict->flags & DICT_FLAG_DUP_IGNORE)
+       r = CDB_PUT_ADD;
+    else if (dict->flags & DICT_FLAG_DUP_REPLACE)
+       r = CDB_PUT_REPLACE;
+    else
+       r = CDB_PUT_INSERT;
+    r = cdb_make_put(&dict_cdbm->cdbm, name, ksize, value, vsize, r);
+    if (r < 0)
+       msg_fatal("error writing %s: %m", dict_cdbm->tmp_path);
+    else if (r > 0) {
+       if (dict->flags & (DICT_FLAG_DUP_IGNORE | DICT_FLAG_DUP_REPLACE));
+       else if (dict->flags & DICT_FLAG_DUP_WARN)
+           msg_warn("%s: duplicate entry: \"%s\"",
+                    dict_cdbm->dict.name, name);
+       else
+           msg_fatal("%s: duplicate entry: \"%s\"",
+                     dict_cdbm->dict.name, name);
+    }
+#else
+    if (cdb_make_add(&dict_cdbm->cdbm, name, ksize, value, vsize) < 0)
+       msg_fatal("error writing %s: %m", dict_cdbm->tmp_path);
+#endif
+}
+
+/* dict_cdbm_close - close data base and rename file.tmp to file.cdb */
+
+static void dict_cdbm_close(DICT *dict)
+{
+    DICT_CDBM *dict_cdbm = (DICT_CDBM *) dict;
+    int     fd = cdb_fileno(&dict_cdbm->cdbm);
+
+    /*
+     * Note: if FCNTL locking is used, closing any file descriptor on a
+     * locked file cancels all locks that the process may have on that file.
+     * CDB is FCNTL locking safe, because it uses the same file descriptor
+     * for database I/O and locking.
+     */
+    if (cdb_make_finish(&dict_cdbm->cdbm) < 0)
+       msg_fatal("finish database %s: %m", dict_cdbm->tmp_path);
+    if (rename(dict_cdbm->tmp_path, dict_cdbm->cdb_path) < 0)
+       msg_fatal("rename database from %s to %s: %m",
+                 dict_cdbm->tmp_path, dict_cdbm->cdb_path);
+    if (close(fd) < 0)                         /* releases a lock */
+       msg_fatal("close database %s: %m", dict_cdbm->cdb_path);
+    myfree(dict_cdbm->cdb_path);
+    myfree(dict_cdbm->tmp_path);
+    dict_free(dict);
+}
+
+/* dict_cdbm_open - create database as file.tmp */
+
+static DICT *dict_cdbm_open(const char *path, int dict_flags)
+{
+    DICT_CDBM *dict_cdbm;
+    char   *cdb_path;
+    char   *tmp_path;
+    int     fd;
+    struct stat st0,
+            st1;
+
+    cdb_path = concatenate(path, CDB_SUFFIX, (char *) 0);
+    tmp_path = concatenate(path, CDB_TMP_SUFFIX, (char *) 0);
+
+    /*
+     * Repeat until we have opened *and* locked *existing* file. Since the
+     * new (tmp) file will be renamed to be .cdb file, locking here is
+     * somewhat funny to work around possible race conditions.  Note that we
+     * can't open a file with O_TRUNC as we can't know if another process
+     * isn't creating it at the same time.
+     */
+    for (;;) {
+       if ((fd = open(tmp_path, O_RDWR | O_CREAT, 0644)) < 0
+           || fstat(fd, &st0) < 0)
+           msg_fatal("open database %s: %m", tmp_path);
+
+       /*
+        * Get an exclusive lock - we're going to change the database so we
+        * can't have any spectators.
+        */
+       if (myflock(fd, INTERNAL_LOCK, MYFLOCK_OP_EXCLUSIVE) < 0)
+           msg_fatal("lock %s: %m", tmp_path);
+
+       if (stat(tmp_path, &st1) < 0)
+           msg_fatal("stat(%s): %m", tmp_path);
+
+       /*
+        * Compare file's state before and after lock: should be the same,
+        * and nlinks should be >0, or else we opened non-existing file...
+        */
+       if (st0.st_ino == st1.st_ino && st0.st_dev == st1.st_dev
+           && st0.st_rdev == st1.st_rdev && st0.st_nlink == st1.st_nlink
+           && st0.st_nlink > 0)
+           break;                              /* successefully opened */
+
+       close(fd);
+
+    }
+
+#ifndef NO_FTRUNCATE
+    if (st0.st_size)
+       ftruncate(fd, 0);
+#endif
+
+    dict_cdbm = (DICT_CDBM *) dict_alloc(DICT_TYPE_CDB, path,
+                                        sizeof(*dict_cdbm));
+    if (cdb_make_start(&dict_cdbm->cdbm, fd) < 0)
+       msg_fatal("initialize database %s: %m", tmp_path);
+    dict_cdbm->dict.close = dict_cdbm_close;
+    dict_cdbm->dict.update = dict_cdbm_update;
+    dict_cdbm->cdb_path = cdb_path;
+    dict_cdbm->tmp_path = tmp_path;
+    close_on_exec(fd, CLOSE_ON_EXEC);
+
+    /*
+     * If undecided about appending a null byte to key and value, choose a
+     * default to not append a null byte when creating a cdb.
+     */
+    if ((dict_flags & (DICT_FLAG_TRY1NULL | DICT_FLAG_TRY0NULL)) == 0)
+       dict_flags |= DICT_FLAG_TRY0NULL;
+    else if ((dict_flags & DICT_FLAG_TRY1NULL)
+            && (dict_flags & DICT_FLAG_TRY0NULL))
+       dict_flags &= ~DICT_FLAG_TRY0NULL;
+    dict_cdbm->dict.flags = dict_flags | DICT_FLAG_FIXED;
+
+    return (&dict_cdbm->dict);
+}
+
+/* dict_cdb_open - open data base for query mode or create mode */
+
+DICT   *dict_cdb_open(const char *path, int open_flags, int dict_flags)
+{
+    switch (open_flags & (O_RDONLY | O_RDWR | O_WRONLY | O_CREAT | O_TRUNC)) {
+    case O_RDONLY:                             /* query mode */
+       return dict_cdbq_open(path, dict_flags);
+    case O_WRONLY | O_CREAT | O_TRUNC:         /* create mode */
+    case O_RDWR | O_CREAT | O_TRUNC:           /* sloppiness */
+       return dict_cdbm_open(path, dict_flags);
+    default:
+       msg_fatal("dict_cdb_open: inappropriate open flags for cdb database"
+                 " - specify O_RDONLY or O_WRONLY|O_CREAT|O_TRUNC");
+    }
+}
+
+#endif                                 /* HAS_CDB */
diff --git a/postfix/src/util/dict_cdb.h b/postfix/src/util/dict_cdb.h
new file mode 100644 (file)
index 0000000..e2c13d4
--- /dev/null
@@ -0,0 +1,37 @@
+#ifndef _DICT_CDB_H_INCLUDED_
+#define _DICT_CDB_H_INCLUDED_
+
+/*++
+/* NAME
+/*     dict_cdb 3h
+/* SUMMARY
+/*     dictionary manager interface to CDB files
+/* SYNOPSIS
+/*     #include <dict_cdb.h>
+/* DESCRIPTION
+/* .nf
+
+ /*
+  * Utility library.
+  */
+#include <dict.h>
+
+ /*
+  * External interface.
+  */
+#define DICT_TYPE_CDB "cdb"
+
+extern DICT *dict_cdb_open(const char *, int, int);
+
+/* 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
+/*--*/
+
+#endif /* _DICT_CDB_H_INCLUDED_ */
index 14ccec5723c29f3cf2775a553cc5fde1540e158e..66919c8358b30ea7c9c50a6c0de1f5b67dfafff5 100644 (file)
 #include <mymalloc.h>
 #include <msg.h>
 #include <dict.h>
+#include <dict_cdb.h>
 #include <dict_env.h>
 #include <dict_unix.h>
 #include <dict_tcp.h>
@@ -189,6 +190,9 @@ typedef struct {
 } DICT_OPEN_INFO;
 
 static DICT_OPEN_INFO dict_open_info[] = {
+#ifdef HAS_CDB
+    DICT_TYPE_CDB, dict_cdb_open,
+#endif
     DICT_TYPE_ENVIRON, dict_env_open,
     DICT_TYPE_UNIX, dict_unix_open,
 #ifdef SNAPSHOT
index 85c24897c4ea1c18ded1dc9bca2dd0751256df19..9e27f94d4bfae04a9ed36aaa42aed999e363b43c 100644 (file)
@@ -10,7 +10,7 @@
 /*     char    *buffer;
 /*     int     replacement;
 /* DESCRIPTION
-/*     printable() replaces non-printable characters in its input
+/*     printable() replaces non-ASCII or non-printable characters in its input
 /*     by the given replacement.
 /*
 /*     Arguments:
@@ -45,7 +45,7 @@ char   *printable(char *string, int replacement)
     int     ch;
 
     for (cp = string; (ch = *(unsigned char *) cp) != 0; cp++)
-       if (!ISPRINT(ch))
+       if (!ISASCII(ch) || !ISPRINT(ch))
            *cp = replacement;
     return (string);
 }