mirror of
https://github.com/vdukhovni/postfix
synced 2025-08-30 05:38:06 +00:00
postfix-2.2-20041208
This commit is contained in:
parent
4d6d3d8e1b
commit
39ce366fdb
2
postfix/.indent.pro
vendored
2
postfix/.indent.pro
vendored
@ -32,6 +32,8 @@
|
||||
-TDELIVER_ATTR
|
||||
-TDELIVER_REQUEST
|
||||
-TDICT
|
||||
-TDICT_CDBM
|
||||
-TDICT_CDBQ
|
||||
-TDICT_CIDR
|
||||
-TDICT_CIDR_ENTRY
|
||||
-TDICT_DB
|
||||
|
@ -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
|
||||
|
@ -38,6 +38,7 @@ LLooookkuupp ttaabblleess ((ddaattaabbaasseess))
|
||||
|
||||
* 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
|
||||
|
58
postfix/README_FILES/CDB_README
Normal file
58
postfix/README_FILES/CDB_README
Normal file
@ -0,0 +1,58 @@
|
||||
PPoossttffiixx CCDDBB HHoowwttoo
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
IInnttrroodduuccttiioonn
|
||||
|
||||
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.
|
||||
|
||||
BBuuiillddiinngg PPoossttffiixx wwiitthh CCDDBB
|
||||
|
||||
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
|
||||
"ppoossttmmaapp --ii" (incremental record insertion) and "ppoossttmmaapp --dd" (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.
|
||||
|
@ -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.
|
||||
|
||||
PPoossttffiixx llooookkuupp ttaabbllee ttyyppeess
|
||||
|
||||
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 "ppoossttccoonnff
|
||||
--mm" command. Here is a list of database types that are often supported:
|
||||
|
||||
bbttrreeee
|
||||
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.
|
||||
ccddbb
|
||||
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.
|
||||
cciiddrr
|
||||
A table that associates values with Classless Inter-Domain Routing
|
||||
(CIDR) patterns. The table format is described in cidr_table(5).
|
||||
|
@ -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 "ppoossttccoonnff --nn" 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 "ppoossttccoonnff aalliiaass__mmaappss".
|
||||
|
||||
Execute the command "newaliases" whenever you change the aliases file.
|
||||
Execute the command "nneewwaalliiaasseess" whenever you change the aliases file.
|
||||
|
||||
PPoossttffiixx eemmaaiill ffiirreewwaallll//ggaatteewwaayy
|
||||
|
||||
@ -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 "ppoossttccoonnff mmaaiill__vveerrssiioonn".
|
||||
|
||||
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 ddbbmm instead of hhaasshh if your system uses ddbbmm files instead of ddbb files.
|
||||
To find out what lookup tables Postfix supports, use the command "ppoossttccoonnff --mm".
|
||||
|
||||
Execute the command "postmap /etc/postfix/relay_recipients" whenever you change
|
||||
Execute the command "ppoossttmmaapp //eettcc//ppoossttffiixx//rreellaayy__rreecciippiieennttss" whenever you change
|
||||
the relay_recipients table.
|
||||
|
||||
Execute the command "postmap /etc/postfix/transport" whenever you change the
|
||||
Execute the command "ppoossttmmaapp //eettcc//ppoossttffiixx//ttrraannssppoorrtt" whenever you change the
|
||||
transport table.
|
||||
|
||||
DDeelliivveerriinngg ssoommee bbuutt nnoott aallll aaccccoouunnttss llooccaallllyy
|
||||
@ -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 "ppoossttccoonnff mmaaiill__vveerrssiioonn".
|
||||
|
||||
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 ddbbmm instead of hhaasshh if your system uses ddbbmm files instead of ddbb files.
|
||||
To find out what lookup tables Postfix supports, use the command "ppoossttccoonnff --mm".
|
||||
|
||||
Execute the command "postmap /etc/postfix/transport" whenever you edit the
|
||||
Execute the command "ppoossttmmaapp //eettcc//ppoossttffiixx//ttrraannssppoorrtt" whenever you edit the
|
||||
transport table.
|
||||
|
||||
CCoonnffiigguurriinngg PPoossttffiixx aass MMXX hhoosstt ffoorr aa rreemmoottee ssiittee
|
||||
@ -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 ddbbmm instead of hhaasshh if your system uses ddbbmm files instead of ddbb files.
|
||||
To find out what lookup tables Postfix supports, use the command "ppoossttccoonnff --mm".
|
||||
|
||||
Execute the command "postmap /etc/postfix/transport" whenever you change the
|
||||
Execute the command "ppoossttmmaapp //eettcc//ppoossttffiixx//ttrraannssppoorrtt" whenever you change the
|
||||
transport table.
|
||||
|
||||
PPoossttffiixx oonn aa ddiiaalluupp mmaacchhiinnee
|
||||
@ -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 "ppoossttccoonnff sseennddmmaaiill__ppaatthh" 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 "sseennddmmaaiill --qq" command every now and then while the dialup link is up,
|
||||
so that newly-posted mail is flushed from the queue.
|
||||
|
||||
PPoossttffiixx oonn hhoossttss wwiitthhoouutt aa rreeaall hhoossttnnaammee
|
||||
|
@ -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
|
||||
=======================================================
|
||||
|
||||
|
@ -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,
|
||||
@ -286,8 +286,8 @@
|
||||
# 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.
|
||||
#
|
||||
|
84
postfix/html/CDB_README.html
Normal file
84
postfix/html/CDB_README.html
Normal file
@ -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>
|
@ -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
|
||||
|
@ -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>
|
||||
|
||||
|
@ -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>
|
||||
|
||||
|
@ -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>
|
||||
|
||||
|
@ -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.
|
||||
|
||||
|
@ -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>
|
||||
|
@ -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
|
||||
|
@ -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.
|
||||
|
@ -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.
|
||||
|
@ -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.
|
||||
|
@ -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.
|
||||
|
||||
|
84
postfix/proto/CDB_README.html
Normal file
84
postfix/proto/CDB_README.html
Normal file
@ -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>
|
@ -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
|
||||
|
@ -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) $? >$@
|
||||
|
||||
|
@ -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>
|
||||
|
||||
|
@ -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>
|
||||
|
||||
|
@ -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>
|
||||
|
||||
|
@ -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
|
||||
@ -249,8 +249,8 @@
|
||||
# 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.
|
||||
#
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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"
|
||||
|
@ -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 *);
|
||||
|
||||
|
65
postfix/src/global/mkmap_cdb.c
Normal file
65
postfix/src/global/mkmap_cdb.c
Normal file
@ -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 */
|
@ -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
|
||||
|
@ -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.
|
||||
|
@ -102,7 +102,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 \fBpostmap\fR command can query any supported file type,
|
||||
/* but it can create only the following file types:
|
||||
@ -118,9 +118,6 @@
|
||||
/* 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.
|
||||
|
@ -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
|
||||
|
374
postfix/src/util/dict_cdb.c
Normal file
374
postfix/src/util/dict_cdb.c
Normal file
@ -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 */
|
37
postfix/src/util/dict_cdb.h
Normal file
37
postfix/src/util/dict_cdb.h
Normal file
@ -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_ */
|
@ -164,6 +164,7 @@
|
||||
#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
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user