Sendmail tinycdb support

TinyCDB | Sendmail Compile | TODO

TinyCDB is a fast and simple public domain database format, similar to Berkeley DB. Sendmail does not support TinyCDB by default, though can be patched to do so.

TinyCDB

TinyCDB may be installed manually from source, or may be available as a port or package for the system in question. Be sure to test whether TinyCDB works on the system in question; as of writing, it does not work on Mac OS X 10.2 for me. On FreeBSD, the install and a simple test would look something like the following.

$ cd /usr/ports/databases/tinycdb
$ sudo make install

$ cd /tmp
$ (echo foo bar; echo cat dog) | cdb -m -c test.cdb
$ cdb -d test.cdb
+3,3:foo->bar
+3,3:cat->dog

$ rm test.cdb

Sendmail Compile

Sendmail will need to be patched for TinyCDB support, and then recompiled before TinyCDB database maps can be configured.

  1. Obtain patch.
  2. Sendmail CDB patch for 8.12.7 from the original source, or the local patch.sendmail-cdb-0.1 copy of the patch.

  3. Patch clean sendmail source.
  4. The patch applies against the current 8.12.9 sources cleanly.

    $ cd sendmail-8.12.9
    $ patch -p1 < ../patch.sendmail-cdb-0.1

  5. Compile sendmail.
  6. The patch creates a custom devtools/Site/site.config.m4 with the required definitions for CDB support. This data will need to be merged with any local parameters used to compile a custom sendmail. Note that the sendmail Build script needs a fully qualified path to a custom site.config.m4, and that subcomponents of sendmail (such as libmilter) will need to be built using the same custom file to prevent odd runtime errors.

    $ cat devtools/Site/site.config.m4 >> ../local.m4
    $ sh Build -c -f `pwd`/../local.m4 > ../build.log

    $ (cd libmilter && sh Build -c -f `pwd`/../../local.m4)

    I usually keep the site.config.m4 under /etc/mail to simplify the above commands.

  7. Test sendmail.
  8. Ensure sendmail was compiled with CDB.

    $ ./obj.*.*/sendmail/sendmail -d0 </dev/null | grep CDB
    NETINET NETINET6 NETUNIX CDB PIPELINING SCANF STARTTLS
    Program mode requires special privileges, e.g., root or TrustedUser.

    Before installing, also test that the cdb database map lookups work.

    $ cd /tmp
    $ (echo V10; echo Kcdb cdb /tmp/test.cdb) > test.cf
    $ (echo foo bar; echo cat dog) | cdb -m -c test.cdb
    $ /obj.*.*/sendmail/sendmail -bt -C test.cf
    ADDRESS TEST MODE (ruleset 3 NOT automatically invoked)
    Enter <ruleset> <address>
    > /map cdb cat
    map_lookup: cdb (cat) returns dog (0)
    > control+d
    $ rm test.c*

    If cdb works, then install sendmail with the usual sh Build install.

TODO

  1. Replacing existing maps or creating custom cdb lookups.
  2. The access map file is used by everything, can we drop in CDB as the map type and have it work??

  3. Benchmarking.