Help with sdb/pgsql zonetodb

Mark Andrews Mark_Andrews at isc.org
Thu Aug 11 23:38:41 UTC 2005


> On Thu, 2005-08-11 at 11:17, Enrico Pelletta wrote:
> > Hi!
> > 
> > I'm trying to making working Bind 9.3.1 with sdb/pgsql on Debian 3.1
> > running postgresql 7.4.7.
> > 
> > I built and installed bind with sdb/pgsql. Now, I would like to use
> > zonetodb to add into my DB a test zone. The tool successfully compiled
> > but when I run:
> > 
> > ./zonetodb mydom.net myzonefile zonesDB t_zone
> > 
> > I always get the error message:
> > 
> > hash.c:383: INSIST(hash != ((void *)0) && ((((hash)) != ((void *)0)) &&
> > (((const isc__magic_t *)((hash)))->magic == ((('H') << 24 | ('a') << 16
> > | ('s') << 8 | ('h')))))) failed.
> > Aborted
> > 
> > It seems zonetodb fails when running the following main function line:.
> > 
> > result = dns_db_create(mctx, "rbt", origin,
> > dns_dbtype_zone,dns_rdataclass_in, 0, NULL, &db);
> > 
> > I have token a look around without founding any kind of tips. I'm new to
> > bind/sdb and any help will be really welcome!
> > Thank!
> > 
> >     Enrico.
> > 
> > 
> You need to apply something like this patch, which I applied in 
> Red Hat bind-9.3.1's contrib/sdb/ldap/zone2ldap.c, @ line 200, in the 
> main() function initialization code before any dns_*name or 
> dns_db_create functions are called:
> 
> +
> +  /* It is required to initialize the hash before dns_db_create in BIND 9 */
> +  result = isc_hash_create(isc_ctx, NULL, DNS_NAME_MAXWIRE);
> +  isc_result_check (result, "isc_hash_create");
> +
> 
> I'll patch Red Hat's zonetodb.c today in bind-9.3.1-10 and you can pick it up
> from there.
> 
> 
> 

	I don't have ldap install on my box but the following should
	be correct.

	There is a possibility that more cleanup is required.

	Mark
 
Index: bind9/contrib/sdb/ldap/zone2ldap.c
diff -u bind9/contrib/sdb/ldap/zone2ldap.c:1.3 bind9/contrib/sdb/ldap/zone2ldap.c:1.4
--- bind9/contrib/sdb/ldap/zone2ldap.c:1.3	Sun Jun 10 22:36:38 2001
+++ bind9/contrib/sdb/ldap/zone2ldap.c	Thu Aug 11 23:32:32 2005
@@ -20,6 +20,8 @@
 #include <getopt.h>
 
 #include <isc/buffer.h>
+#include <isc/entropy.h>
+#include <isc/hash.h>
 #include <isc/mem.h>
 #include <isc/print.h>
 #include <isc/result.h>
@@ -106,7 +108,8 @@
 int
 main (int *argc, char **argv)
 {
-  isc_mem_t *isc_ctx = NULL;
+  isc_mem_t *mctx = NULL;
+  isc_entropy_t *ectx = NULL;
   isc_result_t result;
   char *basedn;
   ldap_info *tmp;
@@ -185,9 +188,15 @@
   if (debug)
     printf ("Initializing ISC Routines, parsing zone file\n");
 
-  result = isc_mem_create (0, 0, &isc_ctx);
+  result = isc_mem_create (0, 0, &mctx);
   isc_result_check (result, "isc_mem_create");
 
+  result = isc_entropy_create(mctx, &ectx);
+  isc_result_check (result, "isc_entropy_create");
+
+  result = isc_hash_create(mctx, ectx, DNS_NAME_MAXWIRE);
+  isc_result_check (result, "isc_hash_create");
+
   isc_buffer_init (&buff, argzone, strlen (argzone));
   isc_buffer_add (&buff, strlen (argzone));
   dns_fixedname_init (&fixedzone);
@@ -195,9 +204,8 @@
   result = dns_name_fromtext (zone, &buff, dns_rootname, ISC_FALSE, NULL);
   isc_result_check (result, "dns_name_fromtext");
 
-  result =
-    dns_db_create (isc_ctx, "rbt", zone, dns_dbtype_zone, dns_rdataclass_in,
-		   0, NULL, &db);
+  result = dns_db_create (mctx, "rbt", zone, dns_dbtype_zone,
+			  dns_rdataclass_in, 0, NULL, &db);
   isc_result_check (result, "dns_db_create");
 
   result = dns_db_load (db, zonefile);
@@ -313,9 +321,14 @@
       add_ldap_values (tmp);
     }
 
-if (debug)
+  if (debug)
 	printf("Operation Complete.\n");
 
+  /* Cleanup */
+  isc_hash_destroy();
+  isc_entropy_detach(&ectx);
+  isc_mem_destroy(&mctx);
+
   return 0;
 }
 
--
Mark Andrews, ISC
1 Seymour St., Dundas Valley, NSW 2117, Australia
PHONE: +61 2 9871 4742                 INTERNET: Mark_Andrews at isc.org



More information about the bind-users mailing list