a3155ae
--- bind-9.3.2b2/lib/dns/rbt.c.dbus	2005-06-17 21:03:24.000000000 -0400
a3155ae
+++ bind-9.3.2b2/lib/dns/rbt.c	2005-11-15 12:45:05.000000000 -0500
a3155ae
@@ -2172,6 +2172,47 @@
a3155ae
 	dns_rbt_printtree(rbt->root, NULL, 0);
a3155ae
 }
a3155ae
 
a3155ae
+static void
a3155ae
+dns_rbt_traverse_tree(dns_rbtnode_t *root,  dns_rbt_traverse_callback_t cb, void *cb_arg1, void *cb_arg2 ) {
a3155ae
+/*
a3155ae
+ * This is used ONLY to traverse the forward table by dbus_mgr at the moment.
a3155ae
+ * Since the forward table is not likely to be large, this can be recursive.
a3155ae
+ */
a3155ae
+	dns_name_t name;
a3155ae
+	dns_offsets_t offsets;
a3155ae
+	char buf[DNS_NAME_MAXWIRE];
a3155ae
+	isc_buffer_t buffer;
a3155ae
+
a3155ae
+	if (root != NULL) {
a3155ae
+
a3155ae
+		if (DOWN(root)) 
a3155ae
+			dns_rbt_traverse_tree(DOWN(root), cb, cb_arg1, cb_arg2);
a3155ae
+
a3155ae
+		if( LEFT(root) != NULL )
a3155ae
+		        dns_rbt_traverse_tree(LEFT(root), cb, cb_arg1, cb_arg2);
a3155ae
+
a3155ae
+		if( RIGHT(root) != NULL )
a3155ae
+		        dns_rbt_traverse_tree(RIGHT(root), cb, cb_arg1, cb_arg2);
a3155ae
+
a3155ae
+		if( DATA(root) == 0L )
a3155ae
+		    return;
a3155ae
+
a3155ae
+		dns_name_init(&name, offsets);
a3155ae
+		isc_buffer_init(&buffer, buf, DNS_NAME_MAXWIRE);
a3155ae
+		dns_name_setbuffer( &name, &buffer);
a3155ae
+		dns_rbt_fullnamefromnode(root, &name);
a3155ae
+		
a3155ae
+		(*cb)(&name, DATA(root), cb_arg1, cb_arg2);		
a3155ae
+	} 
a3155ae
+}
a3155ae
+
a3155ae
+void dns_rbt_traverse( dns_rbt_t *rbt, dns_rbt_traverse_callback_t cb, void *cb_arg1, void *cb_arg2  )
a3155ae
+{
a3155ae
+        REQUIRE(VALID_RBT(rbt));
a3155ae
+
a3155ae
+	dns_rbt_traverse_tree( rbt->root, cb, cb_arg1, cb_arg2 );       
a3155ae
+}
a3155ae
+
a3155ae
 /*
a3155ae
  * Chain Functions
a3155ae
  */
a3155ae
--- bind-9.3.2b2/lib/dns/forward.c.dbus	2005-03-16 22:58:30.000000000 -0500
a3155ae
+++ bind-9.3.2b2/lib/dns/forward.c	2005-11-15 12:45:05.000000000 -0500
a3155ae
@@ -200,3 +200,89 @@
a3155ae
 	}
a3155ae
 	isc_mem_put(fwdtable->mctx, forwarders, sizeof(dns_forwarders_t));
a3155ae
 }
a3155ae
+
a3155ae
+/***
a3155ae
+ *** new D-BUS Dynamic Forwarding Zones functions:
a3155ae
+ ***/
a3155ae
+isc_result_t
a3155ae
+dns_fwdtable_delete(dns_fwdtable_t *fwdtable, dns_name_t *name )
a3155ae
+{
a3155ae
+	isc_result_t result;
a3155ae
+
a3155ae
+	REQUIRE(VALID_FWDTABLE(fwdtable));
a3155ae
+
a3155ae
+	RWLOCK(&fwdtable->rwlock, isc_rwlocktype_write);
a3155ae
+
a3155ae
+	result = dns_rbt_deletename(fwdtable->table, name, ISC_FALSE);
a3155ae
+
a3155ae
+	RWUNLOCK(&fwdtable->rwlock, isc_rwlocktype_write);		    
a3155ae
+
a3155ae
+	return (result);
a3155ae
+}
a3155ae
+
a3155ae
+isc_result_t
a3155ae
+dns_fwdtable_find_closest(dns_fwdtable_t *fwdtable, 
a3155ae
+			  dns_name_t *name, 
a3155ae
+			  dns_name_t *foundname,
a3155ae
+			  dns_forwarders_t **forwardersp)
a3155ae
+{
a3155ae
+	isc_result_t result;
a3155ae
+
a3155ae
+	REQUIRE(VALID_FWDTABLE(fwdtable));
a3155ae
+	
a3155ae
+	RWLOCK(&fwdtable->rwlock, isc_rwlocktype_read);
a3155ae
+
a3155ae
+	result = dns_rbt_findname(fwdtable->table, name, 0, foundname,
a3155ae
+				  (void **)forwardersp);
a3155ae
+	
a3155ae
+	if(result == DNS_R_PARTIALMATCH)
a3155ae
+	    result = ISC_R_SUCCESS;
a3155ae
+
a3155ae
+	RWUNLOCK(&fwdtable->rwlock, isc_rwlocktype_read);
a3155ae
+
a3155ae
+	return (result);
a3155ae
+}
a3155ae
+
a3155ae
+isc_result_t
a3155ae
+dns_fwdtable_find_exact(dns_fwdtable_t *fwdtable, dns_name_t *name,
a3155ae
+		  dns_forwarders_t **forwardersp)
a3155ae
+{
a3155ae
+	isc_result_t result;
a3155ae
+
a3155ae
+	REQUIRE(VALID_FWDTABLE(fwdtable));
a3155ae
+
a3155ae
+	REQUIRE(forwardersp != 0L);
a3155ae
+
a3155ae
+	RWLOCK(&fwdtable->rwlock, isc_rwlocktype_read);
a3155ae
+
a3155ae
+	result = dns_rbt_findname(fwdtable->table, name, 0, NULL,
a3155ae
+				  (void **)forwardersp);
a3155ae
+	
a3155ae
+	if( result != ISC_R_SUCCESS )
a3155ae
+	    *forwardersp = 0L;
a3155ae
+
a3155ae
+	RWUNLOCK(&fwdtable->rwlock, isc_rwlocktype_read);
a3155ae
+
a3155ae
+	return (result);
a3155ae
+}
a3155ae
+
a3155ae
+static 
a3155ae
+void dns_fwdtable_traverse
a3155ae
+(   
a3155ae
+    dns_name_t *name,
a3155ae
+    void *node_data,
a3155ae
+    void *cbp,
a3155ae
+    void *cb_arg
a3155ae
+)
a3155ae
+{
a3155ae
+    dns_fwdtable_callback_t  cb = (dns_fwdtable_callback_t) cbp;
a3155ae
+    
a3155ae
+    (*cb)( name, node_data, cb_arg);
a3155ae
+}
a3155ae
+
a3155ae
+void dns_fwdtable_foreach(dns_fwdtable_t *fwdtable, dns_fwdtable_callback_t cb, void *cb_arg )
a3155ae
+{
a3155ae
+    REQUIRE(VALID_FWDTABLE(fwdtable));
a3155ae
+
a3155ae
+    dns_rbt_traverse( fwdtable->table, dns_fwdtable_traverse, cb, cb_arg );
a3155ae
+}
a3155ae
--- bind-9.3.2b2/lib/dns/include/dns/forward.h.dbus	2005-03-16 22:58:31.000000000 -0500
a3155ae
+++ bind-9.3.2b2/lib/dns/include/dns/forward.h	2005-11-15 12:45:05.000000000 -0500
a3155ae
@@ -98,6 +98,37 @@
a3155ae
  * 	all memory associated with the forwarding table is freed.
a3155ae
  */
a3155ae
 
a3155ae
+
a3155ae
+/* These are ONLY used by dbus_mgr :
a3155ae
+ */
a3155ae
+
a3155ae
+isc_result_t
a3155ae
+dns_fwdtable_delete( dns_fwdtable_t *fwdtable, dns_name_t *name );
a3155ae
+/* 
a3155ae
+ * Removes an entry from the forwarding table.
a3155ae
+ */
a3155ae
+
a3155ae
+isc_result_t
a3155ae
+dns_fwdtable_find_exact(dns_fwdtable_t *fwdtable, dns_name_t *name,
a3155ae
+		  dns_forwarders_t **forwardersp);
a3155ae
+/*
a3155ae
+ * Finds an exact match for "name" in the forwarding table.  
a3155ae
+ */
a3155ae
+
a3155ae
+isc_result_t
a3155ae
+dns_fwdtable_find_closest(dns_fwdtable_t *fwdtable, dns_name_t *name, dns_name_t *foundname,
a3155ae
+		  dns_forwarders_t **forwardersp);
a3155ae
+/*
a3155ae
+ * Finds the closest match for "*name" in the forwarding table, returning  
a3155ae
+ * the actual name matching in *name if different to *name passed in. 
a3155ae
+ */
a3155ae
+
a3155ae
+typedef void (*dns_fwdtable_callback_t)( dns_name_t *, dns_forwarders_t *, void *);
a3155ae
+void dns_fwdtable_foreach(dns_fwdtable_t *fwdtable, dns_fwdtable_callback_t cb, void * );
a3155ae
+/* Invoke cb for each member of fwdtable 
a3155ae
+ */
a3155ae
+
a3155ae
+
a3155ae
 ISC_LANG_ENDDECLS
a3155ae
 
a3155ae
 #endif /* DNS_FORWARD_H */
a3155ae
--- bind-9.3.2b2/lib/dns/include/dns/rbt.h.dbus	2004-10-11 01:55:51.000000000 -0400
a3155ae
+++ bind-9.3.2b2/lib/dns/include/dns/rbt.h	2005-11-15 12:45:05.000000000 -0500
a3155ae
@@ -833,6 +833,17 @@
a3155ae
  *	<something_else>	Any error result from dns_name_concatenate.
a3155ae
  */
a3155ae
 
a3155ae
+
a3155ae
+typedef void (*dns_rbt_traverse_callback_t)(  dns_name_t *name,
a3155ae
+					      void *node_data,
a3155ae
+					      void *cb_arg1,
a3155ae
+					      void *cb_arg2);
a3155ae
+
a3155ae
+void dns_rbt_traverse( dns_rbt_t *rbt, dns_rbt_traverse_callback_t cb, void *cb_arg1, void *cb_arg2 );
a3155ae
+/* tree traversal function (only used by D-BUS dynamic forwarding dbus_mgr at
a3155ae
+ * the moment)
a3155ae
+ */
a3155ae
+
a3155ae
 ISC_LANG_ENDDECLS
a3155ae
 
a3155ae
 #endif /* DNS_RBT_H */
a3155ae
--- bind-9.3.2b2/lib/isc/unix/socket.c.dbus	2005-11-15 12:43:36.000000000 -0500
a3155ae
+++ bind-9.3.2b2/lib/isc/unix/socket.c	2005-11-15 12:45:05.000000000 -0500
a3155ae
@@ -148,6 +148,11 @@
a3155ae
 	ISC_LIST(isc_socketevent_t)		recv_list;
a3155ae
 	ISC_LIST(isc_socket_newconnev_t)	accept_list;
a3155ae
 	isc_socket_connev_t		       *connect_ev;
a3155ae
+        
a3155ae
+        /* these are used only by isc_sockettype_fd sockets:*/
a3155ae
+        isc_socketevent_t      *read_ready_event;
a3155ae
+        isc_socketevent_t      *write_ready_event;
a3155ae
+        isc_socketevent_t      *selected_event;
a3155ae
 
a3155ae
 	/*
a3155ae
 	 * Internal events.  Posted when a descriptor is readable or
a3155ae
@@ -304,7 +309,7 @@
a3155ae
 
a3155ae
 static void
a3155ae
 wakeup_socket(isc_socketmgr_t *manager, int fd, int msg) {
a3155ae
-	isc_socket_t *sock;
a3155ae
+	isc_socket_t *sock=0L;
a3155ae
 
a3155ae
 	/*
a3155ae
 	 * This is a wakeup on a socket.  If the socket is not in the
a3155ae
@@ -1266,6 +1271,9 @@
a3155ae
 	sock->connected = 0;
a3155ae
 	sock->connecting = 0;
a3155ae
 	sock->bound = 0;
a3155ae
+	sock->read_ready_event = 0L;
a3155ae
+	sock->write_ready_event = 0L;
a3155ae
+	sock->selected_event = 0L;
a3155ae
 
a3155ae
 	/*
a3155ae
 	 * initialize the lock
a3155ae
@@ -1378,13 +1386,16 @@
a3155ae
 	case isc_sockettype_tcp:
a3155ae
 		sock->fd = socket(pf, SOCK_STREAM, IPPROTO_TCP);
a3155ae
 		break;
a3155ae
+
a3155ae
+	case isc_sockettype_fd:
a3155ae
+	        sock->fd = pf;
a3155ae
 	}
a3155ae
 
a3155ae
 #ifdef F_DUPFD
a3155ae
 	/*
a3155ae
 	 * Leave a space for stdio to work in.
a3155ae
 	 */
a3155ae
-	if (sock->fd >= 0 && sock->fd < 20) {
a3155ae
+	if ( (type != isc_sockettype_fd) && (sock->fd >= 0) && (sock->fd < 20) ) {
a3155ae
 		int new, tmp;
a3155ae
 		new = fcntl(sock->fd, F_DUPFD, 20);
a3155ae
 		tmp = errno;
a3155ae
@@ -1438,7 +1449,7 @@
a3155ae
 		}
a3155ae
 	}
a3155ae
 
a3155ae
-	if (make_nonblock(sock->fd) != ISC_R_SUCCESS) {
a3155ae
+	if ((type != isc_sockettype_fd) && (make_nonblock(sock->fd) != ISC_R_SUCCESS)) {
a3155ae
 		(void)close(sock->fd);
a3155ae
 		free_socket(&sock);
a3155ae
 		return (ISC_R_UNEXPECTED);
a3155ae
@@ -1706,6 +1717,38 @@
a3155ae
 	isc_task_send(ev->ev_sender, (isc_event_t **)&iev;;
a3155ae
 }
a3155ae
 
a3155ae
+static
a3155ae
+isc_event_t *dispatch_read_ready(isc_socketmgr_t *manager, isc_socket_t *sock)
a3155ae
+{
a3155ae
+    isc_event_t *dev = (isc_event_t*)sock->read_ready_event, *ev;
a3155ae
+    
a3155ae
+    ev = isc_mem_get(manager->mctx, dev->ev_size);
a3155ae
+    memcpy(ev,dev,dev->ev_size);
a3155ae
+    ISC_LINK_INIT(ev,ev_link);
a3155ae
+    isc_task_send(dev->ev_sender, &ev );
a3155ae
+    return (isc_event_t *)sock->selected_event;
a3155ae
+}
a3155ae
+
a3155ae
+static
a3155ae
+isc_event_t *dispatch_write_ready(isc_socketmgr_t *manager,isc_socket_t *sock)
a3155ae
+{
a3155ae
+    isc_event_t *dev = (isc_event_t*)sock->write_ready_event, *ev;
a3155ae
+    ev = isc_mem_get(manager->mctx, dev->ev_size);
a3155ae
+    memcpy(ev,dev,dev->ev_size);
a3155ae
+    ISC_LINK_INIT(ev,ev_link);
a3155ae
+    isc_task_send(dev->ev_sender, &ev );
a3155ae
+    return (isc_event_t *)sock->selected_event;
a3155ae
+}
a3155ae
+
a3155ae
+static
a3155ae
+void dispatch_selected(isc_socketmgr_t *manager, isc_event_t *dev)
a3155ae
+{   isc_event_t *ev;
a3155ae
+    ev = isc_mem_get(manager->mctx, dev->ev_size);
a3155ae
+    memcpy(ev,dev,dev->ev_size);
a3155ae
+    ISC_LINK_INIT(ev,ev_link);
a3155ae
+    isc_task_send(dev->ev_sender, &ev );
a3155ae
+}
a3155ae
+
a3155ae
 /*
a3155ae
  * Dequeue an item off the given socket's read queue, set the result code
a3155ae
  * in the done event to the one provided, and send it to the task it was
a3155ae
@@ -2113,6 +2156,7 @@
a3155ae
 	int i;
a3155ae
 	isc_socket_t *sock;
a3155ae
 	isc_boolean_t unlock_sock;
a3155ae
+	isc_event_t *sock_selected = 0L;
a3155ae
 
a3155ae
 	REQUIRE(maxfd <= (int)FD_SETSIZE);
a3155ae
 
a3155ae
@@ -2146,11 +2190,15 @@
a3155ae
 			unlock_sock = ISC_TRUE;
a3155ae
 			LOCK(&sock->lock);
a3155ae
 			if (!SOCK_DEAD(sock)) {
a3155ae
+			    if( sock->type != isc_sockettype_fd )
a3155ae
+			    {
a3155ae
 				if (sock->listener)
a3155ae
 					dispatch_accept(sock);
a3155ae
 				else
a3155ae
 					dispatch_recv(sock);
a3155ae
-			}
a3155ae
+			    }else			    
a3155ae
+				sock_selected = dispatch_read_ready(manager,sock);
a3155ae
+			}			    
a3155ae
 			FD_CLR(i, &manager->read_fds);
a3155ae
 		}
a3155ae
 	check_write:
a3155ae
@@ -2164,16 +2212,24 @@
a3155ae
 				LOCK(&sock->lock);
a3155ae
 			}
a3155ae
 			if (!SOCK_DEAD(sock)) {
a3155ae
+			    if( sock->type != isc_sockettype_fd )
a3155ae
+			    {
a3155ae
 				if (sock->connecting)
a3155ae
 					dispatch_connect(sock);
a3155ae
 				else
a3155ae
 					dispatch_send(sock);
a3155ae
+			    }else			   
a3155ae
+				sock_selected =	dispatch_write_ready(manager,sock);
a3155ae
 			}
a3155ae
 			FD_CLR(i, &manager->write_fds);
a3155ae
 		}
a3155ae
 		if (unlock_sock)
a3155ae
 			UNLOCK(&sock->lock);
a3155ae
 	}
a3155ae
+	if( sock_selected != 0L )
a3155ae
+	{
a3155ae
+	    dispatch_selected(manager, sock_selected);
a3155ae
+	}
a3155ae
 }
a3155ae
 
a3155ae
 #ifdef ISC_PLATFORM_USETHREADS
a3155ae
@@ -2192,7 +2248,7 @@
a3155ae
 	int cc;
a3155ae
 	fd_set readfds;
a3155ae
 	fd_set writefds;
a3155ae
-	int msg, fd;
a3155ae
+	int msg, fd = -1;
a3155ae
 	int maxfd;
a3155ae
 	char strbuf[ISC_STRERRORSIZE];
a3155ae
 
a3155ae
@@ -3523,3 +3579,55 @@
a3155ae
 	return (ISC_R_SUCCESS);
a3155ae
 }
a3155ae
 #endif /* ISC_PLATFORM_USETHREADS */
a3155ae
+
a3155ae
+isc_socketevent_t*
a3155ae
+isc_socket_fd_handle_reads( isc_socket_t *sock, isc_socketevent_t *dev )
a3155ae
+{    
a3155ae
+    REQUIRE(VALID_SOCKET(sock));   
a3155ae
+    if(dev != 0L) 
a3155ae
+    {
a3155ae
+	sock->references=1;
a3155ae
+	sock->read_ready_event = dev;
a3155ae
+	select_poke(sock->manager, sock->fd, SELECT_POKE_READ);
a3155ae
+    }else
a3155ae
+    {
a3155ae
+	dev = sock->read_ready_event ;
a3155ae
+	sock->read_ready_event = 0L ;
a3155ae
+    }
a3155ae
+    return dev;
a3155ae
+}
a3155ae
+
a3155ae
+isc_socketevent_t*
a3155ae
+isc_socket_fd_handle_writes( isc_socket_t *sock, isc_socketevent_t *dev )
a3155ae
+{
a3155ae
+    REQUIRE(VALID_SOCKET(sock));   
a3155ae
+    if(dev != 0L) 
a3155ae
+    {
a3155ae
+	sock->references=1;
a3155ae
+	sock->write_ready_event = dev;
a3155ae
+	select_poke(sock->manager, sock->fd, SELECT_POKE_WRITE);    
a3155ae
+    }else
a3155ae
+    {
a3155ae
+	dev = sock->write_ready_event;
a3155ae
+	sock->write_ready_event = 0L;
a3155ae
+    }
a3155ae
+    return dev;
a3155ae
+}
a3155ae
+
a3155ae
+isc_socketevent_t*
a3155ae
+isc_socket_fd_handle_selected( isc_socket_t *sock, isc_socketevent_t *dev )
a3155ae
+{
a3155ae
+    REQUIRE(VALID_SOCKET(sock));
a3155ae
+    if(dev != 0L) 
a3155ae
+    {
a3155ae
+	sock->references=1;
a3155ae
+	sock->selected_event = dev;
a3155ae
+    }else
a3155ae
+    {
a3155ae
+	dev = sock->selected_event;
a3155ae
+	sock->selected_event = 0L;
a3155ae
+	sock->references=0;
a3155ae
+	destroy(&sock);
a3155ae
+    }
a3155ae
+    return dev;
a3155ae
+}
a3155ae
--- bind-9.3.2b2/lib/isc/include/isc/socket.h.dbus	2004-03-08 04:04:53.000000000 -0500
a3155ae
+++ bind-9.3.2b2/lib/isc/include/isc/socket.h	2005-11-15 12:45:05.000000000 -0500
a3155ae
@@ -136,6 +136,10 @@
a3155ae
 #define ISC_SOCKEVENT_NEWCONN	(ISC_EVENTCLASS_SOCKET + 3)
a3155ae
 #define ISC_SOCKEVENT_CONNECT	(ISC_EVENTCLASS_SOCKET + 4)
a3155ae
 
a3155ae
+#define ISC_SOCKEVENT_READ_READY  (ISC_EVENTCLASS_SOCKET + 5)
a3155ae
+#define ISC_SOCKEVENT_WRITE_READY (ISC_EVENTCLASS_SOCKET + 6)
a3155ae
+#define ISC_SOCKEVENT_SELECTED    (ISC_EVENTCLASS_SOCKET + 7)
a3155ae
+
a3155ae
 /*
a3155ae
  * Internal events.
a3155ae
  */
a3155ae
@@ -144,7 +148,8 @@
a3155ae
 
a3155ae
 typedef enum {
a3155ae
 	isc_sockettype_udp = 1,
a3155ae
-	isc_sockettype_tcp = 2
a3155ae
+	isc_sockettype_tcp = 2,
a3155ae
+	isc_sockettype_fd  = 8
a3155ae
 } isc_sockettype_t;
a3155ae
 
a3155ae
 /*
a3155ae
@@ -699,6 +704,30 @@
a3155ae
  *	'sock' is a valid socket.
a3155ae
  */
a3155ae
 
a3155ae
+isc_socketevent_t*
a3155ae
+isc_socket_fd_handle_reads( isc_socket_t *sock, isc_socketevent_t *dev );
a3155ae
+/* register the "dev" event to be sent when the isc_sockettype_fd sock 
a3155ae
+ * was select()-ed for read. If there is already an event registered, it
a3155ae
+ * is returned, otherwise 0 is returned. If dev is 0, removes any existing
a3155ae
+ * registered event.
a3155ae
+ */
a3155ae
+ 
a3155ae
+isc_socketevent_t*
a3155ae
+isc_socket_fd_handle_writes( isc_socket_t *sock, isc_socketevent_t *dev );
a3155ae
+/* register the "dev" event to be sent when the isc_sockettype_fd sock 
a3155ae
+ * was select()-ed for write. If there is already an event registered, it
a3155ae
+ * is returned, otherwise 0 is returned. If dev is 0, removes any existing
a3155ae
+ * registered event.
a3155ae
+ */
a3155ae
+
a3155ae
+isc_socketevent_t*
a3155ae
+isc_socket_fd_handle_selected( isc_socket_t *sock, isc_socketevent_t *dev );
a3155ae
+/* register the "dev" event to be sent when ALL isc_sockettype_fd sockets 
a3155ae
+ * have been select()-ed . If there is already an event registered, it
a3155ae
+ * is returned, otherwise 0 is returned. If dev is 0, removes any existing
a3155ae
+ * registered event.
a3155ae
+ */
a3155ae
+
a3155ae
 ISC_LANG_ENDDECLS
a3155ae
 
a3155ae
 #endif /* ISC_SOCKET_H */
a3155ae
--- bind-9.3.2b2/bin/named/log.c.dbus	2005-05-24 19:58:17.000000000 -0400
a3155ae
+++ bind-9.3.2b2/bin/named/log.c	2005-11-15 12:45:05.000000000 -0500
a3155ae
@@ -41,6 +41,7 @@
a3155ae
 	{ "queries",	 		0 },
a3155ae
 	{ "unmatched",	 		0 },
a3155ae
 	{ "update-security",		0 },
a3155ae
+	{ "dbus",                       0 },
a3155ae
 	{ NULL, 			0 }
a3155ae
 };
a3155ae
 
a3155ae
@@ -60,6 +61,7 @@
a3155ae
 	{ "notify",	 		0 },
a3155ae
 	{ "control",	 		0 },
a3155ae
 	{ "lwresd",	 		0 },
a3155ae
+	{ "dbus",                       0 },
a3155ae
 	{ NULL, 			0 }
a3155ae
 };
a3155ae
 
a3155ae
--- bind-9.3.2b2/bin/named/Makefile.in.dbus	2005-11-15 12:43:36.000000000 -0500
a3155ae
+++ bind-9.3.2b2/bin/named/Makefile.in	2005-11-15 12:45:05.000000000 -0500
a3155ae
@@ -35,7 +35,8 @@
a3155ae
 		${LWRES_INCLUDES} ${DNS_INCLUDES} ${BIND9_INCLUDES} \
a3155ae
 		${ISCCFG_INCLUDES} ${ISCCC_INCLUDES} ${ISC_INCLUDES} \
a3155ae
 		${DBDRIVER_INCLUDES}
a3155ae
-
a3155ae
+DBUS_INCLUDES = \
a3155ae
+	-I/usr/lib/dbus-1.0/include -I/usr/include/dbus-1.0
a3155ae
 CDEFINES =
a3155ae
 CWARNINGS =
a3155ae
 
a3155ae
@@ -52,6 +53,7 @@
a3155ae
 ISCDEPLIBS =	../../lib/isc/libisc.@A@
a3155ae
 LWRESDEPLIBS =	../../lib/lwres/liblwres.@A@
a3155ae
 BIND9DEPLIBS =	../../lib/bind9/libbind9.@A@
a3155ae
+DBUSLIBS=       -ldbus-1
a3155ae
 
a3155ae
 DEPLIBS =	${LWRESDEPLIBS} ${DNSDEPLIBS} ${BIND9DEPLIBS} \
a3155ae
 		${ISCCFGDEPLIBS} ${ISCCCDEPLIBS} ${ISCDEPLIBS}
a3155ae
@@ -70,7 +72,8 @@
a3155ae
 		tkeyconf.o tsigconf.o update.o xfrout.o \
a3155ae
 		zoneconf.o \
a3155ae
 		lwaddr.o lwresd.o lwdclient.o lwderror.o lwdgabn.o \
a3155ae
-		lwdgnba.o lwdgrbn.o lwdnoop.o lwsearch.o \
a3155ae
+		lwdgnba.o lwdgrbn.o lwdnoop.o lwsearch.o  \
a3155ae
+		dbus_service.o dbus_mgr.o \
a3155ae
 		$(DBDRIVER_OBJS)
a3155ae
 
a3155ae
 UOBJS =		unix/os.o
a3155ae
@@ -83,6 +86,7 @@
a3155ae
 		zoneconf.c \
a3155ae
 		lwaddr.c lwresd.c lwdclient.c lwderror.c lwdgabn.c \
a3155ae
 		lwdgnba.c lwdgrbn.c lwdnoop.c lwsearch.c \
a3155ae
+	        dbus_service.c dbus_mgr.c \
a3155ae
 		$(DBDRIVER_SRCS)
a3155ae
 
a3155ae
 MANPAGES =	named.8 lwresd.8 named.conf.5
a3155ae
@@ -111,9 +115,14 @@
a3155ae
 		-DNS_LOCALSTATEDIR=\"${localstatedir}\" \
a3155ae
 		-c ${srcdir}/config.c
a3155ae
 
a3155ae
+dbus_service.o: dbus_service.c
a3155ae
+	${LIBTOOL_MODE_COMPILE} ${CC} ${ALL_CFLAGS} \
a3155ae
+	        ${DBUS_INCLUDES} \
a3155ae
+		-c ${srcdir}/dbus_service.c
a3155ae
+
a3155ae
 named@EXEEXT@: ${OBJS} ${UOBJS} ${DEPLIBS}
a3155ae
 	${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \
a3155ae
-	${OBJS} ${UOBJS} ${LIBS}
a3155ae
+	${OBJS} ${UOBJS} ${LIBS} ${DBUSLIBS}
a3155ae
 
a3155ae
 lwresd@EXEEXT@: named@EXEEXT@
a3155ae
 	rm -f lwresd@EXEEXT@
a3155ae
--- bind-9.3.2b2/bin/named/named.8.dbus	2005-10-12 22:33:46.000000000 -0400
a3155ae
+++ bind-9.3.2b2/bin/named/named.8	2005-11-15 12:48:31.000000000 -0500
a3155ae
@@ -30,7 +30,7 @@
a3155ae
 named \- Internet domain name server
a3155ae
 .SH "SYNOPSIS"
a3155ae
 .HP 6
a3155ae
-\fBnamed\fR [\fB\-4\fR] [\fB\-6\fR] [\fB\-c\ \fR\fB\fIconfig\-file\fR\fR] [\fB\-d\ \fR\fB\fIdebug\-level\fR\fR] [\fB\-f\fR] [\fB\-g\fR] [\fB\-n\ \fR\fB\fI#cpus\fR\fR] [\fB\-p\ \fR\fB\fIport\fR\fR] [\fB\-s\fR] [\fB\-t\ \fR\fB\fIdirectory\fR\fR] [\fB\-u\ \fR\fB\fIuser\fR\fR] [\fB\-v\fR] [\fB\-x\ \fR\fB\fIcache\-file\fR\fR]
a3155ae
+\fBnamed\fR [\fB\-4\fR] [\fB\-6\fR] [\fB\-c\ \fR\fB\fIconfig\-file\fR\fR] [\fB\-d\ \fR\fB\fIdebug\-level\fR\fR] [\fB\-f\fR] [\fB\-g\fR] [\fB\-n\ \fR\fB\fI#cpus\fR\fR] [\fB\-p\ \fR\fB\fIport\fR\fR] [\fB\-s\fR] [\fB\-t\ \fR\fB\fIdirectory\fR\fR] [\fB\-u\ \fR\fB\fIuser\fR\fR] [\fB\-v\fR] [\fB\-x\ \fR\fB\fIcache\-file\fR\fR] [\fB\-D\fR]
a3155ae
 .SH "DESCRIPTION"
a3155ae
 .PP
a3155ae
 \fBnamed\fR
a3155ae
@@ -143,6 +143,13 @@
a3155ae
 .B "Warning:"
a3155ae
 This option must not be used. It is only of interest to BIND 9 developers and may be removed or changed in a future release.
a3155ae
 .RE
a3155ae
+.sp
a3155ae
+.TP
a3155ae
+\fB\-D\fR
a3155ae
+Enable dynamic management of the forwarding table with D-BUS
a3155ae
+messages. This option is required for Red Hat NetworkManager
a3155ae
+support. See doc/README.DBUS .
a3155ae
+.sp
a3155ae
 .SH "SIGNALS"
a3155ae
 .PP
a3155ae
 In routine operation, signals should not be used to control the nameserver;
a3155ae
@@ -162,6 +169,73 @@
a3155ae
 \fBnamed\fR
a3155ae
 configuration file is too complex to describe in detail here. A complete description is provided in the
a3155ae
 BIND 9 Administrator Reference Manual.
a3155ae
+.PP
a3155ae
+.SH "NOTES"
a3155ae
+.PP
a3155ae
+.TP
a3155ae
+\fBRed Hat SELinux BIND Security Profile:\fR
a3155ae
+.PP
a3155ae
+By default, Red Hat ships BIND with the most secure SELinux policy
a3155ae
+that will not prevent normal BIND operation and will prevent exploitation
a3155ae
+of all known BIND security vulnerabilities . See the selinux(8) man page
a3155ae
+for information about SElinux.
a3155ae
+.PP
a3155ae
+It is not necessary to run named in a chroot environment if the Red Hat
a3155ae
+SELinux policy for named is enabled. When enabled, this policy is far
a3155ae
+more secure than a chroot environment.
a3155ae
+.PP
a3155ae
+With this extra security comes some restrictions:
a3155ae
+.br
a3155ae
+By default, the SELinux policy does not allow named to write any master
a3155ae
+zone database files. Only the root user may create files in the $ROOTDIR/var/named
a3155ae
+zone database file directory (the options { "directory" } option), where
a3155ae
+$ROOTDIR is set in /etc/sysconfig/named.
a3155ae
+.br
a3155ae
+The "named" group must be granted read privelege to 
a3155ae
+these files in order for named to be enabled to read them. 
a3155ae
+.br
a3155ae
+Any file created in the zone database file directory is automatically assigned
a3155ae
+the SELinux file context named_zone_t .
a3155ae
+.br
a3155ae
+By default, SELinux prevents any role from modifying named_zone_t files; this
a3155ae
+means that files in the zone database directory cannot be modified by dynamic
a3155ae
+DNS (DDNS) updates or zone transfers.
a3155ae
+.br
a3155ae
+The Red Hat BIND distribution and SELinux policy creates two directories where
a3155ae
+named is allowed to create and modify files: $ROOTDIR/var/named/slaves and
a3155ae
+$ROOTDIR/var/named/data. By placing files you want named to modify, such as
a3155ae
+slave or DDNS updateable zone files and database / statistics dump files in 
a3155ae
+these directories, named will work normally and no further operator action is
a3155ae
+required. Files in these directories are automatically assigned the 'named_cache_t'
a3155ae
+file context, which SELinux allows named to write.
a3155ae
+.br
a3155ae
+You can enable the named_t domain to write and create named_zone_t files by use
a3155ae
+of the SELinux tunable boolean variable "named_write_master_zones", using the
a3155ae
+setsebool(8) command or the system-config-security GUI . If you do this, you
a3155ae
+must also set the ENABLE_ZONE_WRITE variable in /etc/sysconfig/named to 
a3155ae
+1 / yes to set the ownership of files in the $ROOTDIR/var/named directory
a3155ae
+to named:named in order for named to be allowed to write them. 
a3155ae
+.PP
a3155ae
+\fBRed Hat BIND named_sdb SDB support:\fR
a3155ae
+.PP
a3155ae
+Red Hat ships the bind-sdb RPM that provides the /usr/sbin/named_sdb program,
a3155ae
+which is named compiled with the Simplified Database Backend modules that ISC
a3155ae
+provides in the "contrib/sdb" directory.
a3155ae
+.br
a3155ae
+The SDB modules for LDAP, PostGreSQL and DirDB are compiled into named_sdb.
a3155ae
+.br
a3155ae
+To run named_sdb, set the ENABLE_SDB variable in /etc/sysconfig/named to 1 or "yes",
a3155ae
+and then the "service named start" named initscript will run named_sdb instead
a3155ae
+of named .
a3155ae
+.br
a3155ae
+See the documentation for the various SDB modules in /usr/share/doc/bind-sdb-*/ .
a3155ae
+.PP
a3155ae
+\fBRed Hat system-config-bind:\fR
a3155ae
+.PP
a3155ae
+Red Hat provides the system-config-bind GUI to configure named.conf and zone
a3155ae
+database files. Run the "system-config-bind" command and access the manual
a3155ae
+by selecting the Help menu.
a3155ae
+.PP
a3155ae
 .SH "FILES"
a3155ae
 .TP
a3155ae
 \fI/etc/named.conf\fR
a3155ae
--- bind-9.3.2b2/bin/named/main.c.dbus	2005-04-28 21:04:47.000000000 -0400
a3155ae
+++ bind-9.3.2b2/bin/named/main.c	2005-11-15 12:45:05.000000000 -0500
a3155ae
@@ -239,7 +239,8 @@
a3155ae
 		"usage: named [-4|-6] [-c conffile] [-d debuglevel] "
a3155ae
 		"[-f|-g] [-n number_of_cpus]\n"
a3155ae
 		"             [-p port] [-s] [-t chrootdir] [-u username]\n"
a3155ae
-		"             [-m {usage|trace|record}]\n");
a3155ae
+		"             [-m {usage|trace|record}]\n"
a3155ae
+	        "             [-D ]\n");
a3155ae
 }
a3155ae
 
a3155ae
 static void
a3155ae
@@ -345,7 +346,7 @@
a3155ae
 
a3155ae
 	isc_commandline_errprint = ISC_FALSE;
a3155ae
 	while ((ch = isc_commandline_parse(argc, argv,
a3155ae
-			           "46c:C:d:fgi:lm:n:N:p:P:st:u:vx:")) != -1) {
a3155ae
+			           "46c:C:d:fgi:lm:n:N:p:P:st:u:vx:D")) != -1) {
a3155ae
 		switch (ch) {
a3155ae
 		case '4':
a3155ae
 			if (disable4)
a3155ae
@@ -434,6 +435,9 @@
a3155ae
 		case 'v':
a3155ae
 			printf("BIND %s\n", ns_g_version);
a3155ae
 			exit(0);
a3155ae
+		case 'D':
a3155ae
+		        ns_g_dbus = 1;
a3155ae
+			break;
a3155ae
 		case '?':
a3155ae
 			usage();
a3155ae
 			ns_main_earlyfatal("unknown option '-%c'",
a3155ae
--- bind-9.3.2b2/bin/named/server.c.dbus	2005-07-26 22:53:15.000000000 -0400
a3155ae
+++ bind-9.3.2b2/bin/named/server.c	2005-11-15 12:45:05.000000000 -0500
a3155ae
@@ -86,6 +86,8 @@
a3155ae
 #include <stdlib.h>
a3155ae
 #endif
a3155ae
 
a3155ae
+#include <named/dbus_mgr.h>
a3155ae
+
a3155ae
 /*
a3155ae
  * Check an operation for failure.  Assumes that the function
a3155ae
  * using it has a 'result' variable and a 'cleanup' label.
a3155ae
@@ -1496,12 +1498,12 @@
a3155ae
 	if (result != ISC_R_SUCCESS) {
a3155ae
 		char namebuf[DNS_NAME_FORMATSIZE];
a3155ae
 		dns_name_format(origin, namebuf, sizeof(namebuf));
a3155ae
-		cfg_obj_log(forwarders, ns_g_lctx, ISC_LOG_WARNING,
a3155ae
-			    "could not set up forwarding for domain '%s': %s",
a3155ae
+		cfg_obj_log(forwarders, ns_g_lctx, ISC_LOG_NOTICE,
a3155ae
+			    "setting up forwarding failed for domain '%s': %s",
a3155ae
 			    namebuf, isc_result_totext(result));
a3155ae
 		goto cleanup;
a3155ae
 	}
a3155ae
-
a3155ae
+		
a3155ae
 	result = ISC_R_SUCCESS;
a3155ae
 
a3155ae
  cleanup:
a3155ae
@@ -2873,6 +2875,20 @@
a3155ae
 
a3155ae
 	CHECKFATAL(load_zones(server, ISC_FALSE), "loading zones");
a3155ae
 
a3155ae
+	server->dbus_mgr = 0L;
a3155ae
+	if( ns_g_dbus )	
a3155ae
+	    if( dbus_mgr_create
a3155ae
+	        (  ns_g_mctx, ns_g_taskmgr, ns_g_socketmgr, ns_g_timermgr,
a3155ae
+		   &server->dbus_mgr
a3155ae
+		) != ISC_R_SUCCESS
a3155ae
+	      )
a3155ae
+	    {
a3155ae
+		isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
a3155ae
+			      NS_LOGMODULE_SERVER, ISC_LOG_WARNING,
a3155ae
+			      "dbus_mgr initialization failed. D-BUS service is disabled."
a3155ae
+		             );
a3155ae
+	    }
a3155ae
+
a3155ae
 	ns_os_started();
a3155ae
 	isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_SERVER,
a3155ae
 		      ISC_LOG_NOTICE, "running");
a3155ae
@@ -2935,6 +2951,9 @@
a3155ae
 
a3155ae
 	dns_db_detach(&server->in_roothints);
a3155ae
 
a3155ae
+	if( server->dbus_mgr != 0L )
a3155ae
+	    dbus_mgr_shutdown(server->dbus_mgr);
a3155ae
+
a3155ae
 	isc_task_endexclusive(server->task);
a3155ae
 
a3155ae
 	isc_task_detach(&server->task);
a3155ae
--- bind-9.3.2b2/bin/named/include/named/globals.h.dbus	2005-11-15 12:43:36.000000000 -0500
a3155ae
+++ bind-9.3.2b2/bin/named/include/named/globals.h	2005-11-15 12:45:05.000000000 -0500
a3155ae
@@ -112,6 +112,8 @@
a3155ae
 
a3155ae
 EXTERN int			ns_g_listen		INIT(3);
a3155ae
 
a3155ae
+EXTERN int                      ns_g_dbus               INIT(0);
a3155ae
+
a3155ae
 #undef EXTERN
a3155ae
 #undef INIT
a3155ae
 
a3155ae
--- bind-9.3.2b2/bin/named/include/named/server.h.dbus	2004-03-07 23:04:21.000000000 -0500
a3155ae
+++ bind-9.3.2b2/bin/named/include/named/server.h	2005-11-15 12:45:05.000000000 -0500
a3155ae
@@ -91,7 +91,8 @@
a3155ae
 	ns_controls_t *		controls;	/* Control channels */
a3155ae
 	unsigned int		dispatchgen;
a3155ae
 	ns_dispatchlist_t	dispatches;
a3155ae
-						
a3155ae
+
a3155ae
+        ns_dbus_mgr_t *         dbus_mgr;
a3155ae
 };
a3155ae
 
a3155ae
 #define NS_SERVER_MAGIC			ISC_MAGIC('S','V','E','R')
a3155ae
--- bind-9.3.2b2/bin/named/include/named/log.h.dbus	2004-03-07 23:04:21.000000000 -0500
a3155ae
+++ bind-9.3.2b2/bin/named/include/named/log.h	2005-11-15 12:45:05.000000000 -0500
a3155ae
@@ -34,6 +34,7 @@
a3155ae
 #define NS_LOGCATEGORY_QUERIES		(&ns_g_categories[4])
a3155ae
 #define NS_LOGCATEGORY_UNMATCHED	(&ns_g_categories[5])
a3155ae
 #define NS_LOGCATEGORY_UPDATE_SECURITY	(&ns_g_categories[6])
a3155ae
+#define NS_LOGCATEGORY_DBUS      	(&ns_g_categories[7])
a3155ae
 
a3155ae
 /*
a3155ae
  * Backwards compatibility.
a3155ae
@@ -51,6 +52,7 @@
a3155ae
 #define NS_LOGMODULE_NOTIFY		(&ns_g_modules[8])
a3155ae
 #define NS_LOGMODULE_CONTROL		(&ns_g_modules[9])
a3155ae
 #define NS_LOGMODULE_LWRESD		(&ns_g_modules[10])
a3155ae
+#define NS_LOGMODULE_DBUS		(&ns_g_modules[11])
a3155ae
 
a3155ae
 isc_result_t
a3155ae
 ns_log_init(isc_boolean_t safe);
a3155ae
--- bind-9.3.2b2/bin/named/include/named/types.h.dbus	2004-03-06 05:21:26.000000000 -0500
a3155ae
+++ bind-9.3.2b2/bin/named/include/named/types.h	2005-11-15 12:45:05.000000000 -0500
a3155ae
@@ -38,4 +38,6 @@
a3155ae
 typedef struct ns_dispatch		ns_dispatch_t;
a3155ae
 typedef ISC_LIST(ns_dispatch_t)		ns_dispatchlist_t;
a3155ae
 
a3155ae
+typedef struct ns_dbus_mgr              ns_dbus_mgr_t ;
a3155ae
+
a3155ae
 #endif /* NAMED_TYPES_H */
a3155ae