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