From 8cae9ae6dbe7b68c295e5c4a2b1340de843af79e Mon Sep 17 00:00:00 2001 From: Wietse Venema Date: Sun, 5 May 2002 00:00:00 -0500 Subject: [PATCH] postfix-1.1.8-20020505 --- postfix/HISTORY | 25 +++++- postfix/README_FILES/DB_README | 27 ++++++- postfix/RELEASE_NOTES | 54 +++++++++++++ postfix/conf/sample-misc.cf | 2 +- postfix/conf/transport | 100 +++++++++++++----------- postfix/html/faq.html | 19 +++-- postfix/html/postalias.1.html | 8 ++ postfix/html/postmap.1.html | 8 ++ postfix/html/transport.5.html | 87 +++++++++++++-------- postfix/man/man1/postalias.1 | 6 ++ postfix/man/man1/postmap.1 | 6 ++ postfix/man/man5/transport.5 | 66 ++++++++++------ postfix/proto/transport | 68 ++++++++++------ postfix/src/global/mail_params.c | 12 +++ postfix/src/global/mail_params.h | 11 +++ postfix/src/global/mail_version.h | 4 +- postfix/src/global/mkmap_db.c | 45 ++++++----- postfix/src/pipe/pipe.c | 12 +-- postfix/src/postalias/postalias.c | 6 ++ postfix/src/postmap/postmap.c | 6 ++ postfix/src/postqueue/postqueue.c | 2 +- postfix/src/trivial-rewrite/resolve.c | 24 +++--- postfix/src/trivial-rewrite/transport.c | 59 +++++++------- postfix/src/util/dict_db.c | 74 ++++++++---------- postfix/src/util/dict_db.h | 5 ++ 25 files changed, 481 insertions(+), 255 deletions(-) diff --git a/postfix/HISTORY b/postfix/HISTORY index 9efee19b0..563e47bd1 100644 --- a/postfix/HISTORY +++ b/postfix/HISTORY @@ -6294,8 +6294,10 @@ Apologies for any names omitted. developed with Lamont Jones, HP. Feature: more efficient use of cache memory when a process - opens multiple Berkeley DB tables. Files: util/dict_db.c, - global/mkmap_db.c. Victor Duchovni, Morgan Stanley. + opens multiple Berkeley DB tables; and faster performance + creating large tables by using more buffer memory. Files: + util/dict_db.[hc], global/mkmap_db.c. Victor Duchovni, + Morgan Stanley. 20020503 @@ -6320,9 +6322,28 @@ Apologies for any names omitted. permissions from the source file when it creates a new table for the first time. File: postalias/postalias.c. +20020504 + Portability: run-time test to avoid GDBM trouble. File: util/dict_dbm.c. +20020505 + + Cleanup: revised and simplified the transport map semantics. + Null transport or nexhop fields now mean: "do not change": + use what would be used if the transport map did not exist. + This change eliminated a lot of code. The incompatibility + is that a null transport field no longer defaults to + $default_transport, but to $local_transport or $default_transport + depending on the destination, and that a transport map only + overrides relayhost when the table specifies explicit + nexthop information. Files: trivial-rewrite/transport.c, + trivial-rewrite/resolve.c. + + Cleanup: revised the user interface for controlling the + Berkeley DB create and read buffer size controls. Files: + util/dict_db.[hc], global/mail_params.[hc], global/mkmap_db.c. + Open problems: Low: sendmail does not store null command-line recipients. diff --git a/postfix/README_FILES/DB_README b/postfix/README_FILES/DB_README index 6d1bb797c..43ec7e603 100644 --- a/postfix/README_FILES/DB_README +++ b/postfix/README_FILES/DB_README @@ -1,9 +1,13 @@ Purpose of this document ======================== -This document describes how to build Postfix with third-party -Berkeley DB from www.sleepycat.com, or how to choose a specific -Berkeley DB version when your system provides multiple implementations. +This document describes + +1 - How to build Postfix with third-party Berkeley DB from +www.sleepycat.com, or how to choose a specific Berkeley DB version +when your system provides multiple implementations. + +2 - How to tweak performance. Building Postfix with Sleepycat Berkeley DB =========================================== @@ -84,3 +88,20 @@ DB 1.85 compatibility mode. Doing so would break fcntl file locking. Warning: if you use PERL to manipulate Postfix .db files, then you need to use the same Berkeley DB version in PERL as in Postfix. + +Tweaking performance +==================== + +Postfix provides two configuration parameters that control how much +buffering memory Berkeley DB will use. + +- berkeley_db_create_buffer_size (default: 16 MBytes). This setting +is used by the postalias and postmap commands. For "hash" files +performance degrades rapidly unless the memory pool is O(file size). +For "btree" files peformance is good with sorted input even for +small memory pools, but with random input degrades rapidly unless +the memory pool is O(file size). + +- berkeley_db_read_buffer_size (default: 256 kBytes). This setting +is used by all other Postfix programs. The buffer size is adequate +for reading. diff --git a/postfix/RELEASE_NOTES b/postfix/RELEASE_NOTES index 8f2f93457..8964d11bd 100644 --- a/postfix/RELEASE_NOTES +++ b/postfix/RELEASE_NOTES @@ -12,6 +12,60 @@ snapshot release). Patches change the patchlevel and the release date. Snapshots change only the release date, unless they include the same bugfixes as a patch release. +Incompatible changes with Postfix snapshot 1.1.8-20020505 +========================================================= + +In the Postfix transport table, the meaning of null delivery +transport and nexhop information fields has changed. As of now, a +null delivery transport or nexthop information field means "do not +modify": use the delivery transport or nexthop information that +would be used if no transport table did not exist. This change +results in the following incompatible changes in behavior: + +- A null delivery transport field no longer defaults to +$default_transport. It now defaults to $local_transport or +$default_transport depending on the destination. + +- A null nexthop information field no longer overrides the main.cf +relayhost setting. To override the relayhost, specify explicit +nexthop information in the Postfix transport table. + +The postalias command now copies the source file read permissions +to the result file when creating a table for the first time. Until +now, the result file was created with default read permissions. +This change makes postalias more similar to postmap. + +The postalias and postmap commands now drop super-user privileges +when processing a non-root source file. The file is now processed +as the source file owner, and the owner must therefore have permission +to update the result file. Specify the "-o" flag to get the old +behavior (process non-root files with root privileges). + +The read buffer size for Berkeley DB lookup tables was decreased +from 1MByte to 256kByte. Specify "berkeley_db_read_buffer_size = +1048576" to get the old read buffer size. + +Major changes with Postfix snapshot 1.1.8-20020505 +================================================== + +Friendlier behavior of Postfix transport tables. There is a new +"*" wildcard pattern that matches any domain. The meaning of a null +delivery transport or nexhop information field has changed to "do +not modify": use the information that would be used if the transport +table did not exist. This change makes it easier to route internal +mail (everything under my.domain) directly: you no longer need to +specify explicit "local" transport table entries for the local +machine. For more information, including examples, see the updated +transport(5) manual page. + +Finer control over Berkeley DB memory usage, and more efficient +usage of memory in applications that open lots of tables. The +parameter "berkeley_db_create_buffer_size" (default: 16 MBytes) +specifies the buffer size for the postmap and postalias commands. +The parameter "berkeley_db_read_buffer_size" (default: 256 kBytes) +speficies the buffer size for all other applications. For more +information, see the last paragraphs of the DB_README file. + Major changes with Postfix snapshot 1.1.7-20020331 ================================================== diff --git a/postfix/conf/sample-misc.cf b/postfix/conf/sample-misc.cf index 900d11c73..49cb460c7 100644 --- a/postfix/conf/sample-misc.cf +++ b/postfix/conf/sample-misc.cf @@ -267,7 +267,7 @@ myorigin = $myhostname # policy: Send the postmaster a transcript of the entire SMTP session # when a client request was rejected because of (UCE) policy. # protocol: Send the postmaster a transcript of the entire SMTP -# session in case of client or server protocol errors. +# session in case of client or server protocol errors. # resource: Inform the postmaster of mail not delivered due to # resource problems. # software: Inform the postmaster of mail not delivered due to diff --git a/postfix/conf/transport b/postfix/conf/transport index 453617c65..273fee08b 100644 --- a/postfix/conf/transport +++ b/postfix/conf/transport @@ -1,4 +1,3 @@ -# # TRANSPORT(5) TRANSPORT(5) # # NAME @@ -34,8 +33,7 @@ # # pattern result # When pattern matches the domain, use the corre- -# sponding result. A pattern of `*' matches all -# entries. +# sponding result. # # blank lines and comments # Empty lines and whitespace-only lines are ignored, @@ -47,6 +45,22 @@ # line that starts with whitespace continues a logi- # cal line. # +# In an indexed file, a pattern of `*' matches everything. +# +# The result is of the form transport:nexthop. The trans- +# port field specifies a mail delivery transport such as +# smtp or local. The nexthop field specifies where and how +# to deliver mail. A null transport or nexthop field means +# "do not change": use the delivery transport and nexthop +# information that would be used if no match were found. +# +# The interpretation of the nexthop field is transport +# dependent. In the case of SMTP, specify host:service for a +# non-default server port, and use [host] or [host]:port in +# order to disable MX (mail exchanger) DNS lookups. The [] +# form can also be used with IP addresses instead of host- +# names. +# # With lookups from indexed files such as DB or DBM, or from # networked tables such as NIS, LDAP or SQL, patterns are # tried in the order as listed below: @@ -62,53 +76,40 @@ # parent_domain_matches_subdomains configuration set- # ting. Otherwise, a domain name matches itself and # its subdomains. -# -# An empty result (`:' - default transport, default nexthop) -# behaves as though the transport map did not exist. When -# combined with a wildcard (`*') entry, this can be used to -# route internal mail directly, while using a relay for all -# outbound traffic. (Note that you should _NOT_ set -# relayhost in this case.) -# -# * smtp:outbound-relay.my.domain -# .my.domain : -# -# Note: transport map entries take precedence over domains -# specified in the mydestination parameter. If you use the -# optional transport map, it may be safer to specify -# explicit entries for all domains specified in mydestina- -# tion, for example: -# -# hostname.my.domain local: -# localhost.my.domain local: -# -# The interpretation of the nexthop field is transport -# dependent. In the case of SMTP, specify host:service for a -# non-default server port, and use [host] or [host]:port in -# order to disable MX (mail exchanger) DNS lookups. The [] -# form can also be used with IP addresses instead of host- -# names. # # EXAMPLES -# In order to send mail for foo.org and its subdomains via +# In order to deliver internal mail directly, while using a +# mail relay for all other mail, specify a null entry for +# internal destinations (do not change the delivery trans- +# port or the nexthop information) and specify a wildcard +# for all other destinations. Note that for this trick to +# work you should not specify a relayhost in the main.cf +# file. +# +# my.domain : +# .my.domain : +# * smtp:outbound-relay.my.domain +# +# In order to send mail for foo.org and its subdomains via # the uucp transport to the UUCP host named foo: # # foo.org uucp:foo # .foo.org uucp:foo # -# When no nexthop host name is specified, the destination -# domain name is used instead. For example, the following -# directs mail for user@foo.org via the slow transport to a -# mail exchanger for foo.org. The slow transport could be -# something that runs at most one delivery process at a +# When no nexthop host name is specified, the destination +# domain name is used instead. For example, the following +# directs mail for user@foo.org via the slow transport to a +# mail exchanger for foo.org. The slow transport could be +# something that runs at most one delivery process at a # time: # # foo.org slow: # -# When no transport is specified, the default transport is -# used, as specified via the default_transport configuration -# parameter. The following sends all mail for foo.org and -# its subdomains to host gateway.foo.org: +# When no transport is specified, Postfix uses either +# $local_transport or $default_transport, depending on +# whether the destination matches $mydestination. The fol- +# lowing sends all mail for foo.org and its subdomains to +# host gateway.foo.org: # # foo.org :[gateway.foo.org] # .foo.org :[gateway.foo.org] @@ -169,13 +170,23 @@ # # Other parameters of interest: # +# local_transport +# The mail delivery transport to use when no trans- +# port is explicitly specified, and the destination +# matches $mydestination. +# # default_transport -# The transport to use when no transport is explic- -# itly specified. +# The mail delivery transport to use when no trans- +# port is explicitly specified, and the destination +# does not match $mydestination. +# +# mydestination +# The destinations that are given to $local_transport +# by default. # # relayhost -# The default host to send to when no transport table -# entry matches. +# The default host for destinations that do not match +# $mydestination. # # SEE ALSO # postmap(1) create mapping table @@ -193,5 +204,4 @@ # P.O. Box 704 # Yorktown Heights, NY 10598, USA # -# 1 -# +# TRANSPORT(5) diff --git a/postfix/html/faq.html b/postfix/html/faq.html index 85f8cb644..52520d1f8 100644 --- a/postfix/html/faq.html +++ b/postfix/html/faq.html @@ -584,24 +584,23 @@ DNS lookups as well:

-

  • In addition to the above you can configure Postfix to deliver +
  • Instead of the above you can configure Postfix to deliver intranet mail directly instead of sending it via the intranet -mail gateway. +mail gateway. In this case, do not specify a relayhost!!

    -Specify routing information for the internal domain in the transport table, and enable transport table, and enable transport table lookups.

         /etc/postfix/transport:
    -        my.domain               smtp:
    -        .my.domain              smtp:
    -        thishost.my.domain      local:        !!!important!!!
    -        localhost.my.domain     local:        !!!important!!!
    +        my.domain               :
    +        .my.domain              :
    +	*			smtp:gateway.my.domain
     
         /etc/postfix/main.cf:
             transport_maps = hash:/etc/postfix/transport
    @@ -609,8 +608,8 @@ href="transport.5.html">transport table lookups.
     
     

    -Important: do not omit the entries that deliver mail locally, or -else mail will bounce with a "mail loops to myself" condition. +Important: do not specify a relayhost entry, or else mail for +internal destinations will still be given to the relayhost.

    diff --git a/postfix/html/postalias.1.html b/postfix/html/postalias.1.html index 0b402dc57..52d2c78c4 100644 --- a/postfix/html/postalias.1.html +++ b/postfix/html/postalias.1.html @@ -136,6 +136,14 @@ POSTALIAS(1) POSTALIAS(1) Default alias database type. On many UNIX systems, the default type is either dbm or hash. + berkeley_db_create_buffer_size + Amount of buffer memory to be used when creating a + Berkeley DB hash or btree lookup table. + + berkeley_db_read_buffer_size + Amount of buffer memory to be used when reading a + Berkeley DB hash or btree lookup table. + STANDARDS RFC 822 (ARPA Internet Text Messages) diff --git a/postfix/html/postmap.1.html b/postfix/html/postmap.1.html index 6c1eee82e..b67ff1880 100644 --- a/postfix/html/postmap.1.html +++ b/postfix/html/postmap.1.html @@ -153,6 +153,14 @@ POSTMAP(1) POSTMAP(1) tems, the default database type is either hash or dbm. + berkeley_db_create_buffer_size + Amount of buffer memory to be used when creating a + Berkeley DB hash or btree lookup table. + + berkeley_db_read_buffer_size + Amount of buffer memory to be used when reading a + Berkeley DB hash or btree lookup table. + LICENSE The Secure Mailer license must be distributed with this software. diff --git a/postfix/html/transport.5.html b/postfix/html/transport.5.html index 737c09c1e..14692cb4c 100644 --- a/postfix/html/transport.5.html +++ b/postfix/html/transport.5.html @@ -1,5 +1,4 @@

    -
     TRANSPORT(5)                                         TRANSPORT(5)
     
     NAME
    @@ -47,6 +46,22 @@ TRANSPORT(5)                                         TRANSPORT(5)
                   line that starts with whitespace continues a  logi-
                   cal line.
     
    +       In an indexed file, a pattern of `*' matches everything.
    +
    +       The  result  is of the form transport:nexthop.  The trans-
    +       port field specifies a mail  delivery  transport  such  as
    +       smtp  or  local. The nexthop field specifies where and how
    +       to deliver mail. A null transport or nexthop  field  means
    +       "do  not  change":  use the delivery transport and nexthop
    +       information that would be used if no match were found.
    +
    +       The interpretation  of  the  nexthop  field  is  transport
    +       dependent. In the case of SMTP, specify host:service for a
    +       non-default server port, and use [host] or [host]:port  in
    +       order  to  disable MX (mail exchanger) DNS lookups. The []
    +       form can also be used with IP addresses instead  of  host-
    +       names.
    +
            With lookups from indexed files such as DB or DBM, or from
            networked tables such as NIS, LDAP or  SQL,  patterns  are
            tried in the order as listed below:
    @@ -63,42 +78,39 @@ TRANSPORT(5)                                         TRANSPORT(5)
                   ting.  Otherwise, a domain name matches itself  and
                   its subdomains.
     
    -       Note:  transport  map entries take precedence over domains
    -       specified in the mydestination parameter. If you  use  the
    -       optional  transport  map,  it  may  be  safer  to  specify
    -       explicit entries for all domains specified  in  mydestina-
    -       tion, for example:
    -
    -            hostname.my.domain   local:
    -            localhost.my.domain      local:
    -
    -       The  interpretation  of  the  nexthop  field  is transport
    -       dependent. In the case of SMTP, specify host:service for a
    -       non-default  server port, and use [host] or [host]:port in
    -       order to disable MX (mail exchanger) DNS lookups.  The  []
    -       form  can  also be used with IP addresses instead of host-
    -       names.
    -
     EXAMPLES
    -       In order to send mail for foo.org and its  subdomains  via
    +       In  order to deliver internal mail directly, while using a
    +       mail relay for all other mail, specify a  null  entry  for
    +       internal  destinations  (do not change the delivery trans-
    +       port or the nexthop information) and  specify  a  wildcard
    +       for  all  other  destinations. Note that for this trick to
    +       work you should not specify a  relayhost  in  the  main.cf
    +       file.
    +
    +            my.domain    :
    +            .my.domain   :
    +            *            smtp:outbound-relay.my.domain
    +
    +       In  order  to send mail for foo.org and its subdomains via
            the uucp transport to the UUCP host named foo:
     
                 foo.org      uucp:foo
                 .foo.org     uucp:foo
     
    -       When  no  nexthop  host name is specified, the destination
    -       domain name is used instead. For  example,  the  following
    -       directs  mail for user@foo.org via the slow transport to a
    -       mail exchanger for foo.org.  The slow transport  could  be
    -       something  that  runs  at  most  one delivery process at a
    +       When no nexthop host name is  specified,  the  destination
    +       domain  name  is  used instead. For example, the following
    +       directs mail for user@foo.org via the slow transport to  a
    +       mail  exchanger  for foo.org.  The slow transport could be
    +       something that runs at most  one  delivery  process  at  a
            time:
     
                 foo.org      slow:
     
    -       When no transport is specified, the default  transport  is
    -       used, as specified via the default_transport configuration
    -       parameter. The following sends all mail  for  foo.org  and
    -       its subdomains to host gateway.foo.org:
    +       When  no  transport  is  specified,  Postfix  uses  either
    +       $local_transport  or  $default_transport,   depending   on
    +       whether  the destination matches $mydestination.  The fol-
    +       lowing sends all mail for foo.org and  its  subdomains  to
    +       host gateway.foo.org:
     
                 foo.org      :[gateway.foo.org]
                 .foo.org     :[gateway.foo.org]
    @@ -159,13 +171,23 @@ TRANSPORT(5)                                         TRANSPORT(5)
     
            Other parameters of interest:
     
    +       local_transport
    +              The  mail  delivery transport to use when no trans-
    +              port is explicitly specified, and  the  destination
    +              matches $mydestination.
    +
            default_transport
    -              The  transport  to use when no transport is explic-
    -              itly specified.
    +              The  mail  delivery transport to use when no trans-
    +              port is explicitly specified, and  the  destination
    +              does not match $mydestination.
    +
    +       mydestination
    +              The destinations that are given to $local_transport
    +              by default.
     
            relayhost
    -              The default host to send to when no transport table
    -              entry matches.
    +              The default host for destinations that do not match
    +              $mydestination.
     
     SEE ALSO
            postmap(1) create mapping table
    @@ -183,6 +205,5 @@ TRANSPORT(5)                                         TRANSPORT(5)
            P.O. Box 704
            Yorktown Heights, NY 10598, USA
     
    -                                                                1
    -
    +                                                     TRANSPORT(5)
     
    diff --git a/postfix/man/man1/postalias.1 b/postfix/man/man1/postalias.1 index f461d29a3..eb1cf4533 100644 --- a/postfix/man/man1/postalias.1 +++ b/postfix/man/man1/postalias.1 @@ -128,6 +128,12 @@ and for default values. .IP \fBdatabase_type\fR Default alias database type. On many UNIX systems, the default type is either \fBdbm\fR or \fBhash\fR. +.IP \fBberkeley_db_create_buffer_size\fR +Amount of buffer memory to be used when creating a Berkeley DB +\fBhash\fR or \fBbtree\fR lookup table. +.IP \fBberkeley_db_read_buffer_size\fR +Amount of buffer memory to be used when reading a Berkeley DB +\fBhash\fR or \fBbtree\fR lookup table. .SH STANDARDS .na .nf diff --git a/postfix/man/man1/postmap.1 b/postfix/man/man1/postmap.1 index da50c768d..a87aa1160 100644 --- a/postfix/man/man1/postmap.1 +++ b/postfix/man/man1/postmap.1 @@ -146,6 +146,12 @@ Enable verbose logging for debugging purposes. Default output database type. On many UNIX systems, the default database type is either \fBhash\fR or \fBdbm\fR. +.IP \fBberkeley_db_create_buffer_size\fR +Amount of buffer memory to be used when creating a Berkeley DB +\fBhash\fR or \fBbtree\fR lookup table. +.IP \fBberkeley_db_read_buffer_size\fR +Amount of buffer memory to be used when reading a Berkeley DB +\fBhash\fR or \fBbtree\fR lookup table. .SH LICENSE .na .nf diff --git a/postfix/man/man5/transport.5 b/postfix/man/man5/transport.5 index d292c2916..c2363f9a1 100644 --- a/postfix/man/man5/transport.5 +++ b/postfix/man/man5/transport.5 @@ -45,6 +45,22 @@ are lines whose first non-whitespace character is a `#'. A logical line starts with non-whitespace text. A line that starts with whitespace continues a logical line. .PP +In an indexed file, a pattern of `\fB*\fR' matches everything. +.PP +The \fIresult\fR is of the form \fItransport\fB:\fInexthop\fR. +The \fItransport\fR field specifies a mail delivery transport +such as \fBsmtp\fR or \fBlocal\fR. The \fInexthop\fR field +specifies where and how to deliver mail. A null \fItransport\fR +or \fInexthop\fR field means "do not change": use the delivery +transport and nexthop information that would be used if no +match were found. +.PP +The interpretation of the \fInexthop\fR field is transport +dependent. In the case of SMTP, specify \fIhost\fR:\fIservice\fR for a +non-default server port, and use [\fIhost\fR] or [\fIhost\fR]:\fIport\fR +in order to disable MX (mail exchanger) DNS lookups. The [] form +can also be used with IP addresses instead of hostnames. +.PP With lookups from indexed files such as DB or DBM, or from networked tables such as NIS, LDAP or SQL, patterns are tried in the order as listed below: @@ -57,28 +73,25 @@ Mail for any subdomain of \fIdomain\fR is delivered through string \fBtransport_maps\fR is not listed in the \fBparent_domain_matches_subdomains\fR configuration setting. Otherwise, a domain name matches itself and its subdomains. -.PP -Note: transport map entries take precedence over domains -specified in the \fBmydestination\fR parameter. If you use -the optional transport map, it may be safer to specify explicit -entries for all domains specified in \fBmydestination\fR, -for example: - -.ti +5 -\fBhostname.my.domain local:\fR -.ti +5 -\fBlocalhost.my.domain local:\fR - -The interpretation of the \fInexthop\fR field is transport -dependent. In the case of SMTP, specify \fIhost\fR:\fIservice\fR for a -non-default server port, and use [\fIhost\fR] or [\fIhost\fR]:\fIport\fR -in order to disable MX (mail exchanger) DNS lookups. The [] form -can also be used with IP addresses instead of hostnames. .SH EXAMPLES .na .nf .ad .fi +In order to deliver internal mail directly, while using a +mail relay for all other mail, specify a null entry for +internal destinations (do not change the delivery transport or +the nexthop information) and specify a wildcard for all other +destinations. Note that for this trick to work you should +not specify a \fBrelayhost\fR in the \fBmain.cf\fR file. + +.ti +5 +\fB\&my.domain :\fR +.ti +5 +\fB\&.my.domain :\fR +.ti +5 +\fB* smtp:outbound-relay.my.domain\fR + In order to send mail for \fBfoo.org\fR and its subdomains via the \fBuucp\fR transport to the UUCP host named \fBfoo\fR: @@ -96,9 +109,10 @@ something that runs at most one delivery process at a time: .ti +5 \fBfoo.org slow:\fR -When no \fItransport\fR is specified, the default transport is -used, as specified via the \fBdefault_transport\fR configuration -parameter. The following sends all mail for \fBfoo.org\fR and its +When no \fItransport\fR is specified, Postfix uses either +\fB$local_transport\fR or \fB$default_transport\fR, depending +on whether the destination matches \fB$mydestination\fR. +The following sends all mail for \fBfoo.org\fR and its subdomains to host \fBgateway.foo.org\fR: .ti +5 @@ -163,10 +177,18 @@ requiring \fI.domain.name\fR patterns). List of transport lookup tables. .PP Other parameters of interest: +.IP \fBlocal_transport\fR +The mail delivery transport to use when no transport is explicitly +specified, and the destination matches \fB$mydestination\fR. .IP \fBdefault_transport\fR -The transport to use when no transport is explicitly specified. +The mail delivery transport to use when no transport is explicitly +specified, and the destination does not match \fB$mydestination\fR. +.IP \fBmydestination\fR +The destinations that are given to \fB$local_transport\fR +by default. .IP \fBrelayhost\fR -The default host to send to when no transport table entry matches. +The default host for destinations that do not match +\fB$mydestination\fR. .SH SEE ALSO .na .nf diff --git a/postfix/proto/transport b/postfix/proto/transport index 18559faa9..abec0c961 100644 --- a/postfix/proto/transport +++ b/postfix/proto/transport @@ -29,7 +29,7 @@ # The format of the transport table is as follows: # .IP "\fIpattern result\fR" # When \fIpattern\fR matches the domain, use the corresponding -# \fIresult\fR. +# \fIresult\fR. # .IP "blank lines and comments" # Empty lines and whitespace-only lines are ignored, as # are lines whose first non-whitespace character is a `#'. @@ -37,6 +37,22 @@ # A logical line starts with non-whitespace text. A line that # starts with whitespace continues a logical line. # .PP +# In an indexed file, a pattern of `\fB*\fR' matches everything. +# .PP +# The \fIresult\fR is of the form \fItransport\fB:\fInexthop\fR. +# The \fItransport\fR field specifies a mail delivery transport +# such as \fBsmtp\fR or \fBlocal\fR. The \fInexthop\fR field +# specifies where and how to deliver mail. A null \fItransport\fR +# or \fInexthop\fR field means "do not change": use the delivery +# transport and nexthop information that would be used if no +# match were found. +# .PP +# The interpretation of the \fInexthop\fR field is transport +# dependent. In the case of SMTP, specify \fIhost\fR:\fIservice\fR for a +# non-default server port, and use [\fIhost\fR] or [\fIhost\fR]:\fIport\fR +# in order to disable MX (mail exchanger) DNS lookups. The [] form +# can also be used with IP addresses instead of hostnames. +# .PP # With lookups from indexed files such as DB or DBM, or from networked # tables such as NIS, LDAP or SQL, patterns are tried in the order as # listed below: @@ -49,26 +65,23 @@ # string \fBtransport_maps\fR is not listed in the # \fBparent_domain_matches_subdomains\fR configuration setting. # Otherwise, a domain name matches itself and its subdomains. -# .PP -# Note: transport map entries take precedence over domains -# specified in the \fBmydestination\fR parameter. If you use -# the optional transport map, it may be safer to specify explicit -# entries for all domains specified in \fBmydestination\fR, -# for example: -# -# .ti +5 -# \fBhostname.my.domain local:\fR -# .ti +5 -# \fBlocalhost.my.domain local:\fR -# -# The interpretation of the \fInexthop\fR field is transport -# dependent. In the case of SMTP, specify \fIhost\fR:\fIservice\fR for a -# non-default server port, and use [\fIhost\fR] or [\fIhost\fR]:\fIport\fR -# in order to disable MX (mail exchanger) DNS lookups. The [] form -# can also be used with IP addresses instead of hostnames. # EXAMPLES # .ad # .fi +# In order to deliver internal mail directly, while using a +# mail relay for all other mail, specify a null entry for +# internal destinations (do not change the delivery transport or +# the nexthop information) and specify a wildcard for all other +# destinations. Note that for this trick to work you should +# not specify a \fBrelayhost\fR in the \fBmain.cf\fR file. +# +# .ti +5 +# \fB\&my.domain :\fR +# .ti +5 +# \fB\&.my.domain :\fR +# .ti +5 +# \fB* smtp:outbound-relay.my.domain\fR +# # In order to send mail for \fBfoo.org\fR and its subdomains # via the \fBuucp\fR transport to the UUCP host named \fBfoo\fR: # @@ -86,9 +99,10 @@ # .ti +5 # \fBfoo.org slow:\fR # -# When no \fItransport\fR is specified, the default transport is -# used, as specified via the \fBdefault_transport\fR configuration -# parameter. The following sends all mail for \fBfoo.org\fR and its +# When no \fItransport\fR is specified, Postfix uses either +# \fB$local_transport\fR or \fB$default_transport\fR, depending +# on whether the destination matches \fB$mydestination\fR. +# The following sends all mail for \fBfoo.org\fR and its # subdomains to host \fBgateway.foo.org\fR: # # .ti +5 @@ -149,10 +163,18 @@ # List of transport lookup tables. # .PP # Other parameters of interest: +# .IP \fBlocal_transport\fR +# The mail delivery transport to use when no transport is explicitly +# specified, and the destination matches \fB$mydestination\fR. # .IP \fBdefault_transport\fR -# The transport to use when no transport is explicitly specified. +# The mail delivery transport to use when no transport is explicitly +# specified, and the destination does not match \fB$mydestination\fR. +# .IP \fBmydestination\fR +# The destinations that are given to \fB$local_transport\fR +# by default. # .IP \fBrelayhost\fR -# The default host to send to when no transport table entry matches. +# The default host for destinations that do not match +# \fB$mydestination\fR. # SEE ALSO # postmap(1) create mapping table # trivial-rewrite(8) rewrite and resolve addresses diff --git a/postfix/src/global/mail_params.c b/postfix/src/global/mail_params.c index 87bd2f1c6..3e5d2dfad 100644 --- a/postfix/src/global/mail_params.c +++ b/postfix/src/global/mail_params.c @@ -85,6 +85,8 @@ /* char *var_showq_service; /* char *var_error_service; /* char *var_flush_service; +/* int var_db_create_buf; +/* int var_db_read_buf; /* /* void mail_params_init() /* DESCRIPTION @@ -131,6 +133,9 @@ #include #include #include +#ifdef HAS_DB +#include +#endif /* Global library. */ @@ -223,6 +228,8 @@ char *var_rewrite_service; char *var_showq_service; char *var_error_service; char *var_flush_service; +int var_db_create_buf; +int var_db_read_buf; #define MAIN_CONF_FILE "main.cf" @@ -456,6 +463,8 @@ void mail_params_init() VAR_FLOCK_TRIES, DEF_FLOCK_TRIES, &var_flock_tries, 1, 0, VAR_DEBUG_PEER_LEVEL, DEF_DEBUG_PEER_LEVEL, &var_debug_peer_level, 1, 0, VAR_FAULT_INJ_CODE, DEF_FAULT_INJ_CODE, &var_fault_inj_code, 0, 0, + VAR_DB_CREATE_BUF, DEF_DB_CREATE_BUF, &var_db_create_buf, 1, 0, + VAR_DB_READ_BUF, DEF_DB_READ_BUF, &var_db_read_buf, 1, 0, 0, }; static CONFIG_TIME_TABLE time_defaults[] = { @@ -515,6 +524,9 @@ void mail_params_init() check_mail_owner(); check_sgid_group(); check_overlap(); +#ifdef HAS_DB + dict_db_mpool_size = var_db_read_buf; +#endif /* * Variables whose defaults are determined at runtime, after other diff --git a/postfix/src/global/mail_params.h b/postfix/src/global/mail_params.h index 922bc1d25..d5565306e 100644 --- a/postfix/src/global/mail_params.h +++ b/postfix/src/global/mail_params.h @@ -1475,6 +1475,17 @@ extern char *var_mbx_defer_errs; #define DEF_MDR_DEFER_ERRS "enospc, estale" extern char *var_mdr_defer_errs; + /* + * Berkeley DB memory pool sizes. + */ +#define VAR_DB_CREATE_BUF "berkeley_db_create_buffer_size" +#define DEF_DB_CREATE_BUF (16 * 1024 *1024) +extern int var_db_create_buf; + +#define VAR_DB_READ_BUF "berkeley_db_read_buffer_size" +#define DEF_DB_READ_BUF (256 *1024) +extern int var_db_read_buf; + /* LICENSE /* .ad /* .fi diff --git a/postfix/src/global/mail_version.h b/postfix/src/global/mail_version.h index e3c6863f9..6e54d26bb 100644 --- a/postfix/src/global/mail_version.h +++ b/postfix/src/global/mail_version.h @@ -20,10 +20,10 @@ * Patches change the patchlevel and the release date. Snapshots change the * release date only, unless they include the same bugfix as a patch release. */ -#define MAIL_RELEASE_DATE "20020501" +#define MAIL_RELEASE_DATE "20020505" #define VAR_MAIL_VERSION "mail_version" -#define DEF_MAIL_VERSION "1.1.7-" MAIL_RELEASE_DATE +#define DEF_MAIL_VERSION "1.1.8-" MAIL_RELEASE_DATE extern char *var_mail_version; /* diff --git a/postfix/src/global/mkmap_db.c b/postfix/src/global/mkmap_db.c index 0d7c9e729..d952d5956 100644 --- a/postfix/src/global/mkmap_db.c +++ b/postfix/src/global/mkmap_db.c @@ -37,10 +37,6 @@ #include -/* Global library. */ - -#include "mail_conf.h" - /* Utility library. */ #include @@ -49,6 +45,10 @@ #include #include +/* Global library. */ + +#include + /* Application-specific. */ #include "mkmap.h" @@ -62,30 +62,29 @@ /* mkmap_db_open - create or open database */ -/* - * db_mpool_size" is defined in util/dict_db.c and defaults to 256K, - * which works well for the lookup code. - * - * We use a larger memory pool when building ".db" files. - * For "hash" files performance degrades rapidly unless the memory pool - * is O(file size). - * - * For "btree" files peformance is good with sorted input even for small - * memory pools, but with random input degrades rapidly unless the memory - * pool is O(file size). - */ -extern int db_mpool_size; - -#define VAR_MPOOL_SIZE "db_mkmap_mpool_size" -#define DEF_MPOOL_SIZE 16777216 /* 16MB */ - static MKMAP *mkmap_db_open(const char *path, DICT *(*db_open) (const char *, int, int)) { MKMAP *mkmap = (MKMAP *) mymalloc(sizeof(*mkmap)); - /* Override default mpool size for map rebuilds */ - db_mpool_size = get_mail_conf_int(VAR_MPOOL_SIZE, DEF_MPOOL_SIZE, 0, 0); + /* + * Override the default mpool size for map (re)builds. + * + * db_mpool_size" is defined in util/dict_db.c and defaults to 256K, which + * works well for the lookup code. + * + * We use a larger memory pool when building ".db" files. For "hash" files + * performance degrades rapidly unless the memory pool is O(file size). + * + * For "btree" files peformance is good with sorted input even for small + * memory pools, but with random input degrades rapidly unless the memory + * pool is O(file size). + * + * XXX This should be specified via the DICT interface so that the buffer + * size becomes an object property, instead of being specified by poking + * a global variable so that it becomes a class property. + */ + dict_db_mpool_size = var_db_create_buf; /* * Fill in the generic members. diff --git a/postfix/src/pipe/pipe.c b/postfix/src/pipe/pipe.c index 8061389a3..59741bda0 100644 --- a/postfix/src/pipe/pipe.c +++ b/postfix/src/pipe/pipe.c @@ -572,21 +572,21 @@ static void get_service_attr(PIPE_ATTR *attr, char **argv) case 'B': attr->flags |= MAIL_COPY_BLANK; break; + case 'D': + attr->flags |= MAIL_COPY_DELIVERED; + break; case 'F': attr->flags |= MAIL_COPY_FROM; break; + case 'R': + attr->flags |= MAIL_COPY_RETURN_PATH; + break; case '.': attr->flags |= MAIL_COPY_DOT; break; case '>': attr->flags |= MAIL_COPY_QUOTE; break; - case 'R': - attr->flags |= MAIL_COPY_RETURN_PATH; - break; - case 'D': - attr->flags |= MAIL_COPY_DELIVERED; - break; case 'h': attr->flags |= PIPE_OPT_FOLD_HOST; break; diff --git a/postfix/src/postalias/postalias.c b/postfix/src/postalias/postalias.c index 83eb23e95..29e013c26 100644 --- a/postfix/src/postalias/postalias.c +++ b/postfix/src/postalias/postalias.c @@ -116,6 +116,12 @@ /* .IP \fBdatabase_type\fR /* Default alias database type. On many UNIX systems, the default type /* is either \fBdbm\fR or \fBhash\fR. +/* .IP \fBberkeley_db_create_buffer_size\fR +/* Amount of buffer memory to be used when creating a Berkeley DB +/* \fBhash\fR or \fBbtree\fR lookup table. +/* .IP \fBberkeley_db_read_buffer_size\fR +/* Amount of buffer memory to be used when reading a Berkeley DB +/* \fBhash\fR or \fBbtree\fR lookup table. /* STANDARDS /* RFC 822 (ARPA Internet Text Messages) /* SEE ALSO diff --git a/postfix/src/postmap/postmap.c b/postfix/src/postmap/postmap.c index fe85e21ee..d9495e39e 100644 --- a/postfix/src/postmap/postmap.c +++ b/postfix/src/postmap/postmap.c @@ -134,6 +134,12 @@ /* Default output database type. /* On many UNIX systems, the default database type is either \fBhash\fR /* or \fBdbm\fR. +/* .IP \fBberkeley_db_create_buffer_size\fR +/* Amount of buffer memory to be used when creating a Berkeley DB +/* \fBhash\fR or \fBbtree\fR lookup table. +/* .IP \fBberkeley_db_read_buffer_size\fR +/* Amount of buffer memory to be used when reading a Berkeley DB +/* \fBhash\fR or \fBbtree\fR lookup table. /* LICENSE /* .ad /* .fi diff --git a/postfix/src/postqueue/postqueue.c b/postfix/src/postqueue/postqueue.c index c7e06a811..40210d6af 100644 --- a/postfix/src/postqueue/postqueue.c +++ b/postfix/src/postqueue/postqueue.c @@ -188,7 +188,7 @@ static void show_queue(void) * Don't assume that the mail system is down when the user has * insufficient permission to access the showq socket. */ - else if (errno != ECONNREFUSED && errno != ENOENT) { + else if (errno == EACCES) { msg_fatal_status(EX_SOFTWARE, "Connect to the %s %s service: %m", var_mail_name, var_showq_service); diff --git a/postfix/src/trivial-rewrite/resolve.c b/postfix/src/trivial-rewrite/resolve.c index ba4463019..22eca78c5 100644 --- a/postfix/src/trivial-rewrite/resolve.c +++ b/postfix/src/trivial-rewrite/resolve.c @@ -188,24 +188,12 @@ void resolve_addr(char *addr, VSTRING *channel, VSTRING *nexthop, } tok822_internalize(nextrcpt, tree, TOK822_STR_DEFL); - /* - * The transport map overrides any transport and next-hop host info that - * is set up below. For a long time, it was not possible to override - * routing of mail that resolves locally, because Postfix used a - * zero-length next-hop hostname result to indicate local delivery, and - * transport maps cannot return zero-length hostnames. - */ - if (*var_transport_maps - && transport_lookup(strrchr(STR(nextrcpt), '@') + 1, channel, nexthop)) { - /* void */ ; - } - /* * Non-local delivery, presumably. Set up the default remote transport * specified with var_def_transport. Use the destination's mail exchanger * unless a default mail relay is specified with var_relayhost. */ - else if (domain != 0) { + if (domain != 0) { vstring_strcpy(channel, var_def_transport); if ((destination = split_at(STR(channel), ':')) != 0 && *destination) vstring_strcpy(nexthop, destination); @@ -235,6 +223,16 @@ void resolve_addr(char *addr, VSTRING *channel, VSTRING *nexthop, if (*STR(nexthop) == 0) msg_panic("%s: null nexthop", myname); + /* + * The transport map overrides any transport and next-hop host info that + * is set up above. For a long time, it was not possible to override + * routing of mail that resolves locally, because Postfix used a + * zero-length next-hop hostname result to indicate local delivery, and + * transport maps cannot return zero-length hostnames. + */ + if (*var_transport_maps) + transport_lookup(strrchr(STR(nextrcpt), '@') + 1, channel, nexthop); + /* * Clean up. */ diff --git a/postfix/src/trivial-rewrite/transport.c b/postfix/src/trivial-rewrite/transport.c index 5d0230906..00ec9d734 100644 --- a/postfix/src/trivial-rewrite/transport.c +++ b/postfix/src/trivial-rewrite/transport.c @@ -85,17 +85,22 @@ void transport_init(void) } +/* transport_wildcard_init - post-jail initialization */ + void transport_wildcard_init(void) { wildcard_channel = vstring_alloc(10); wildcard_nexthop = vstring_alloc(10); - if (!transport_lookup("*", wildcard_channel, wildcard_nexthop)) { - vstring_free(wildcard_channel); - vstring_free(wildcard_nexthop); - } - if (msg_verbose) { - msg_info("wildcard_{chan,hop}={%s %s}", + + if (transport_lookup("*", wildcard_channel, wildcard_nexthop)) { + if (msg_verbose) + msg_info("wildcard_{chan:hop}={%s:%s}", vstring_str(wildcard_channel), vstring_str(wildcard_nexthop)); + } else { + vstring_free(wildcard_channel); + wildcard_channel = 0; + vstring_free(wildcard_nexthop); + wildcard_nexthop = 0; } } @@ -111,7 +116,6 @@ int transport_lookup(const char *domain, VSTRING *channel, VSTRING *nexthop) char *saved_value; char *transport; int found = 0; - int null_found = 0; #define FULL 0 #define PARTIAL DICT_FLAG_FIXED @@ -123,9 +127,12 @@ int transport_lookup(const char *domain, VSTRING *channel, VSTRING *nexthop) /* * Keep stripping domain components until nothing is left or until a - * matching entry is found. If a NULL entry (either no RHS, or ':'), - * then pretend we got no match, and return. If we really got no match, - * then return the wildcard transport, if any. + * matching entry is found. + * + * If the entry specifies no nexthop host and/or delivery channel, do not + * change caller-provided information. + * + * If we find no match, then return the wildcard entry, if any. * * After checking the full name, check for .upper.domain, to distinguish * between the upper domain and it's decendants, ala sendmail and tcp @@ -140,22 +147,10 @@ int transport_lookup(const char *domain, VSTRING *channel, VSTRING *nexthop) for (name = low_domain; /* void */ ; name = next) { if ((value = maps_find(transport_path, name, maps_flag)) != 0) { saved_value = mystrdup(value); - if ((host = split_at(saved_value, ':')) == 0 || *host == 0) { - if (*saved_value == 0) { - myfree(saved_value); - null_found = 1; - break; - } - host = domain; - } - if (*(transport = saved_value) == 0) - transport = var_def_transport; - vstring_strcpy(channel, transport); - (void) split_at(vstring_str(channel), ':'); - if (*vstring_str(channel) == 0) - msg_fatal("null transport is not allowed: %s = %s", - VAR_DEF_TRANSPORT, var_def_transport); - vstring_strcpy(nexthop, host); + if ((host = split_at(saved_value, ':')) != 0 && *host != 0) + vstring_strcpy(nexthop, host); + if (*(transport = saved_value) != 0) + vstring_strcpy(channel, transport); myfree(saved_value); found = 1; break; @@ -170,12 +165,14 @@ int transport_lookup(const char *domain, VSTRING *channel, VSTRING *nexthop) } myfree(low_domain); - if (wildcard_channel && !null_found) { - vstring_strcpy(channel, vstring_str(wildcard_channel)); - if (vstring_str(wildcard_nexthop)) + /* + * Fall back to the wild-card entry. + */ + if (found == 0 && wildcard_channel) { + if (*vstring_str(wildcard_channel)) + vstring_strcpy(channel, vstring_str(wildcard_channel)); + if (*vstring_str(wildcard_nexthop)) vstring_strcpy(nexthop, vstring_str(wildcard_nexthop)); - else - vstring_strcpy(nexthop, domain); found = 1; } return (found); diff --git a/postfix/src/util/dict_db.c b/postfix/src/util/dict_db.c index 004e65793..48ccbf6c9 100644 --- a/postfix/src/util/dict_db.c +++ b/postfix/src/util/dict_db.c @@ -6,6 +6,8 @@ /* SYNOPSIS /* #include /* +/* int dict_db_mpool_size; +/* /* DICT *dict_hash_open(path, open_flags, dict_flags) /* const char *path; /* int open_flags; @@ -20,6 +22,11 @@ /* a pointer to a structure that can be used to access the dictionary /* using the generic methods documented in dict_open(3). /* +/* The dict_db_mpool_size variable specifies a non-default I/O buffer +/* size. The default buffer size is adequate for reading. For better +/* performance while creating a large table, specify a large buffer size +/* before opening the file. +/* /* Arguments: /* .IP path /* The database pathname, not including the ".db" suffix. @@ -105,16 +112,16 @@ typedef struct { } DICT_DB; /* - * db_mpool_size is initialized when the first database is opened. The - * parameter can be preempted by setting db_mpool_size != 0 before calling - * dict_hash_open() or dict_btree_open(). This is done in mkmap_db_open() - * via "db_mkmap_mpool_size" to set a larger memory pool for database - * rebuilds. + * You can override the default dict_db_mpool_size setting before calling + * dict_hash_open() or dict_btree_open(). This is done in mkmap_db_open() to + * set a larger memory pool for database (re)builds. + * + * XXX This should be specified via the DICT interface so that it becomes an + * object property, instead of being specified by poking a global variable + * so that it becomes a class property. */ -#define VAR_MPOOL_SIZE "db_mpool_size" -#define DEF_MPOOL_SIZE 262144 /* 256K default memory pool */ #define DICT_DB_NELM 4096 -int db_mpool_size; +int dict_db_mpool_size = (256 * 1024); /* 256K default memory pool */ #if DB_VERSION_MAJOR > 1 @@ -152,6 +159,8 @@ static int sanitize(int status) static DB_ENV *dict_db_env; static int dict_db_refcount; +/* dict_db_env_alloc - allocate shared environment */ + static int dict_db_env_alloc(DB_ENV ** env) { int err; @@ -164,19 +173,19 @@ static int dict_db_env_alloc(DB_ENV ** env) if (dict_db_env != 0) { ++dict_db_refcount; *env = dict_db_env; - return 0; + return (0); } #if DB_VERSION_MAJOR == 2 #define DICT_DB_ENV_FLAGS (DB_CREATE|DB_INIT_MPOOL|DB_MPOOL_PRIVATE) dict_db_env = (DB_ENV *) mymalloc(sizeof(DB_ENV)); memset((char *) dict_db_env, 0, sizeof(DB_ENV)); - dict_db_env->mp_size = db_mpool_size; + dict_db_env->mp_size = dict_db_mpool_size; if ((err = db_appinit(0, 0, dict_db_env, DICT_DB_ENV_FLAGS)) != 0) { myfree((char *) dict_db_env); dict_db_env = 0; - return err; + return (err); } #endif /* DB_VERSION_MAJOR == 2 */ @@ -185,7 +194,7 @@ static int dict_db_env_alloc(DB_ENV ** env) err = db_env_create(&dict_db_env, 0); if (err == 0) - err = dict_db_env->set_cachesize(dict_db_env, 0, db_mpool_size, 1); + err = dict_db_env->set_cachesize(dict_db_env, 0, dict_db_mpool_size, 1); if (err == 0) err = dict_db_env->open(dict_db_env, 0, DICT_DB_ENV_FLAGS, 0644); @@ -193,13 +202,13 @@ static int dict_db_env_alloc(DB_ENV ** env) if (dict_db_env) dict_db_env->close(dict_db_env, 0); dict_db_env = 0; - return err; + return (err); } #endif /* DB_VERSION_MAJOR > 2 */ ++dict_db_refcount; *env = dict_db_env; - return 0; + return (0); } static void dict_db_env_free(void) @@ -213,6 +222,7 @@ static void dict_db_env_free(void) #if DB_VERSION_MAJOR == 2 if (dict_db_env && dict_db_refcount > 0 && --dict_db_refcount == 0) { db_appexit(dict_db_env); + myfree((char *) dict_db_env); dict_db_env = 0; } #endif @@ -667,31 +677,21 @@ DICT *dict_hash_open(const char *path, int open_flags, int dict_flags) #if DB_VERSION_MAJOR < 2 HASHINFO tweak; + memset((char *) &tweak, 0, sizeof(tweak)); + tweak.nelem = DICT_DB_NELM; + tweak.cachesize = dict_db_mpool_size; #endif #if DB_VERSION_MAJOR == 2 DB_INFO tweak; + memset((char *) &tweak, 0, sizeof(tweak)); + tweak.h_nelem = DICT_DB_NELM; #endif #if DB_VERSION_MAJOR > 2 void *tweak; + tweak = 0; #endif - - /* Set the mpool size if not already set in mkmap_db_open() */ - if (db_mpool_size == 0) - db_mpool_size = get_mail_conf_int(VAR_MPOOL_SIZE, DEF_MPOOL_SIZE, 0, 0); - - memset((char *) &tweak, 0, sizeof(tweak)); - -#if DB_VERSION_MAJOR < 2 - tweak.nelem = DICT_DB_NELM; - tweak.cachesize = db_mpool_size; -#endif -#if DB_VERSION_MAJOR == 2 - tweak.h_nelem = DICT_DB_NELM; - tweak.db_cachesize = 0; -#endif - return (dict_db_open(DICT_TYPE_HASH, path, open_flags, DB_HASH, (void *) &tweak, dict_flags)); } @@ -703,24 +703,18 @@ DICT *dict_btree_open(const char *path, int open_flags, int dict_flags) #if DB_VERSION_MAJOR < 2 BTREEINFO tweak; + memset((char *) &tweak, 0, sizeof(tweak)); + tweak.cachesize = dict_db_mpool_size; #endif #if DB_VERSION_MAJOR == 2 DB_INFO tweak; + memset((char *) &tweak, 0, sizeof(tweak)); #endif #if DB_VERSION_MAJOR > 2 void *tweak; -#endif - - /* Set the mpool size if not already set in mkmap_db_open() */ - if (db_mpool_size == 0) - db_mpool_size = get_mail_conf_int(VAR_MPOOL_SIZE, DEF_MPOOL_SIZE, 0, 0); - - memset((char *) &tweak, 0, sizeof(tweak)); - -#if DB_VERSION_MAJOR < 2 - tweak.cachesize = db_mpool_size; + tweak = 0; #endif return (dict_db_open(DICT_TYPE_BTREE, path, open_flags, DB_BTREE, diff --git a/postfix/src/util/dict_db.h b/postfix/src/util/dict_db.h index f42984ffc..35c12177e 100644 --- a/postfix/src/util/dict_db.h +++ b/postfix/src/util/dict_db.h @@ -25,6 +25,11 @@ extern DICT *dict_hash_open(const char *, int, int); extern DICT *dict_btree_open(const char *, int, int); + /* + * XXX Should be part of the DICT interface. + */ +extern int dict_db_mpool_size; + /* LICENSE /* .ad /* .fi