NSD ACL Plugin

Colm MacCarthaigh colm.maccarthaigh at heanet.ie
Thu Jul 17 09:26:13 UTC 2003


On Thu, Jul 10, 2003 at 02:37:16PM +0100, Colm MacCarthaigh wrote:
> > Probably the easiest way is to use the HEAP_WALK macro in heap.h (which 
> > redefines RBTREE_WALK in rbtree.h) on interface->nsd->db->heap.  This will 
> > give you all the domains (not just the ones specific to a zone).
> 
> O.k., I'll give that a go.

I've been playing with this, but getting very far. My recursive
register_data replacement now looks like this:

/* Recursively register data for a zone */
int register_zone_data (
	const struct nsd_plugin_interface *nsd,
	nsd_plugin_id_type                 id,
	const uint8_t *                    domain_name,
	void *                             data)
{
	void * key , * key_data;
	int  klen, dlen;

	/* Register the data for the super zone */
	if ( ! nsd->register_data (nsd, id, domain_name, data) )
	{
		/* Zone doest exist at all */
		return 0;
	}

	/* Now register the data within that zone, but only if not
	** already set */

	/* Skip past the first byte */
	domain_name ++;

	/* The length of our domain_name */
	dlen = strlen((char *) domain_name);

	nsd->nsd->db->heap->_node = rbtree_first(nsd->nsd->db->heap);

	/* 
	** if nsd knows about www.example.com, ftp.example.com and ns.example.com
	** and domain_name = example.com , we need to register data for 
	** www.example.com, ftp.example.com and ns.example.com
	*/
 	HEAP_WALK(nsd->nsd->db->heap, key, key_data) {
		klen = *key;

		if ( ! bcmp((char *) key + (dlen - klen), (char *) domain_name) )
		{
			printf("%s matched %s\n", dnamestr(key), dnamestr(domain_name));
		}
	}

	return 1;
}


I know the code within the HEAP_WALK loop needs changing, but the
problem I'm seeing is that the code never gets inside the loop,
nothing in there ever runs. NSD just sits there, it seems that
rbtree_first gets itself into an infinite loop and never exists. 

Before I go debugging this properly, am I actually using HEAP_WALK
correctly ?

-- 
Colm MacCárthaigh  /  HEAnet, Teach Brooklawn,  / Innealtóir Ghréasáin
+353 1 6609040    / Bóthar Shelbourne, BÁC, IE /   http://www.hea.net/


More information about the nsd-users mailing list