OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
 
Subject: CDB map for postfix
From: Michael Tokarev (mjttls.msk.ru)
Date: Tue Sep 12 2000 - 14:05:14 CDT


As discussed some time ago this week.

I cleaned up a bit my implementation of dict_cdb that was made
some time ago (but not used by me). And here it is -- in hope
that it can be useful to someone.

Problems are. It have no support in postmap -- and this is very
bad. But mkmap interface does not have close routine, while
working with cdb requires (well, the best solution is) that
new file will be created and renamed into place, that can be
made only in close() routine. DJB's 'cdbmake-12' can be used
in place of postmap to create db (in one-line postfix map format).
It is very simple to write interface for postmap/postalias, but
if api changes a bit.
Also, data size checking as read from db omitted. Little hack
maybe.

Includes: implementation of dictionary: dict_cdb.{c,h}
Patch for utils/dict_open.c to include this stuff, against
last stable version (19991231-pl08); should be easily adopted
to any postfix version.

Also I included here my "rework" of djb's cdb library, to remove
system-supplied routines. It is fully compatible with original
one in format, and almost source-compatible (I renamed structure
fields; if one uses only interface routines, all will be ok).
It _very_ small -- just takes 6k (compressed) in source form
(original cdb-0.75.tar.gz has >50 k in size).

I recall that all stuff here does not used by me (but tested
and used some time ago). Cdb (re)implementation _is_ used now
by me -- djb's idea is good, but implementation is just toooo
ugly.

Regards,
 Michael.

--- postfix-19991231-pl08/util/dict_open.c.orig Wed Nov 17 00:30:51 1999
+++ postfix-19991231-pl08/util/dict_open.c Tue Sep 12 21:45:08 2000
-88,6 +88,8
 /* Berkeley DB file in hash format.
 /* .IP btree
 /* Berkeley DB file in btree format.
+/* .IP cdb
+/* DJB CDB Constant DataBase format.
 /* .IP nis
 /* NIS map. Only read access is supported.
 /* .IP nisplus
-155,6 +157,7
 #include <dict_unix.h>
 #include <dict_dbm.h>
 #include <dict_db.h>
+#include <dict_cdb.h>
 #include <dict_nis.h>
 #include <dict_nisplus.h>
 #include <dict_ni.h>
-183,6 +186,9
 #ifdef HAS_DB
     "hash", dict_hash_open,
     "btree", dict_btree_open,
+#endif
+#ifdef HAS_CDB
+ "cdb", dict_cdb_open,
 #endif
 #ifdef HAS_NIS
     "nis", dict_nis_open,