[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

db4.1



Hello,

I have got a Debian bug report requesting libdb4.1 support in Heimdal,
because krb4 has it.

Has anyone else investigated this? I don't particularly want to
re-invent the wheel if the wheel has already been discovered.

So far I have the attached patch, adapted from the patch for krb4.

Unfortunately, the configure code now appears to be obsolete, because
the include files for db4 aren't under the db4 directory. There was
also another directory that I haven't altered that needed fixing
(IIRC).

Any comments?

diff -ruN heimdal-0.6-old/cf/db.m4 heimdal-0.6/cf/db.m4
--- heimdal-0.6-old/cf/db.m4	2002-09-11 00:29:47.000000000 +1000
+++ heimdal-0.6/cf/db.m4	2003-12-13 14:19:52.000000000 +1100
@@ -40,7 +40,18 @@
     else
       DBLIB=""
     fi
-    AC_DEFINE(HAVE_DB3, 1, [define if you have a berkeley db3/4 library])
+    AC_TRY_COMPILE([#if defined(HAVE_DB4_DB_H)
+    #include <db.h>
+    #elif defined(HAVE_DB3_DB_H)
+    #include <db3/db.h>
+    #else
+    #include <db.h>
+    #endif], [
+    return (DB_VERSION_MAJOR == 4);
+    ],
+    AC_DEFINE(HAVE_DB4, 1, [define if you have a berkeley db4 library]),
+    AC_DEFINE(HAVE_DB3, 1, [define if you have a berkeley db3 library])
+    )
   else
 
 dnl dbopen is used by db1/db2
@@ -188,6 +199,7 @@
 
 AM_CONDITIONAL(HAVE_DB1, test "$db_type" = db1)dnl
 AM_CONDITIONAL(HAVE_DB3, test "$db_type" = db3)dnl
+AM_CONDITIONAL(HAVE_DB4, test "$db_type" = db4)dnl
 AM_CONDITIONAL(HAVE_NDBM, test "$db_type" = ndbm)dnl
 
 ## it's probably not correct to include LDFLAGS here, but we might
diff -ruN heimdal-0.6-old/include/config.h.in heimdal-0.6/include/config.h.in
--- heimdal-0.6-old/include/config.h.in	2003-05-13 01:28:41.000000000 +1000
+++ heimdal-0.6/include/config.h.in	2003-12-13 14:21:39.000000000 +1100
@@ -126,9 +126,12 @@
 /* define if you have a berkeley db1/2 library */
 #undef HAVE_DB1
 
-/* define if you have a berkeley db3/4 library */
+/* define if you have a berkeley db3 library */
 #undef HAVE_DB3
 
+/* define if you have a berkeley db4 library */
+#undef HAVE_DB4
+
 /* Define to 1 if you have the <db3/db.h> header file. */
 #undef HAVE_DB3_DB_H
 
diff -ruN heimdal-0.6-old/lib/hdb/db3.c heimdal-0.6/lib/hdb/db3.c
--- heimdal-0.6-old/lib/hdb/db3.c	2001-08-09 18:41:48.000000000 +1000
+++ heimdal-0.6/lib/hdb/db3.c	2003-12-13 14:27:01.000000000 +1100
@@ -35,7 +35,7 @@
 
 RCSID("$Id: db3.c,v 1.8 2001/08/09 08:41:48 assar Exp $");
 
-#if HAVE_DB3
+#if defined(HAVE_DB3) || defined(HAVE_DB4)
 
 #include <db.h>
 
@@ -262,10 +262,18 @@
     }
     db_create(&d, NULL, 0);
     db->db = d;
+#ifdef HAVE_DB4
+    if ((ret = d->open(db->db, NULL, fn, NULL, DB_BTREE, myflags, mode))) {
+#else
     if ((ret = d->open(db->db, fn, NULL, DB_BTREE, myflags, mode))) {
+#endif
       if(ret == ENOENT)
 	/* try to open without .db extension */
+#ifdef HAVE_DB4
+	if (d->open(db->db, NULL, db->name, NULL, DB_BTREE, myflags, mode)) {
+#else
 	if (d->open(db->db, db->name, NULL, DB_BTREE, myflags, mode)) {
+#endif
 	  free(fn);
 	  krb5_set_error_string(context, "opening %s: %s",
 				db->name, strerror(ret));
-- 
Brian May <bam@snoopy.apana.org.au>