Adam Tkac 653904
--- bind-9.4.0/contrib/dbus/dbus_service.c.race-condition	2006-09-28 07:53:47.000000000 +0200
Adam Tkac 653904
+++ bind-9.4.0/contrib/dbus/dbus_service.c	2007-04-27 15:10:03.000000000 +0200
Adam Tkac 653904
@@ -5,6 +5,7 @@
Adam Tkac 653904
  *  Provides MINIMAL utilities for construction of D-BUS "Services".
Adam Tkac 653904
  *  
Adam Tkac 653904
  *  Copyright(C) Jason Vas Dias, Red Hat Inc., 2005
Adam Tkac 653904
+ *  Modified by Adam Tkac, Red Hat Inc., 2007
Adam Tkac 653904
  *
Adam Tkac 653904
  *  This program is free software; you can redistribute it and/or modify
Adam Tkac 653904
  *  it under the terms of the GNU General Public License as published by
Adam Tkac 653904
@@ -50,6 +51,7 @@
Adam Tkac 653904
 #include <dbus/dbus.h>
Adam Tkac 653904
 
Adam Tkac 653904
 #include <named/dbus_service.h>
Adam Tkac 653904
+#include <isc/result.h>
Adam Tkac 653904
 
Adam Tkac 653904
 typedef struct dbcs_s
Adam Tkac 653904
 {
Adam Tkac 653904
@@ -914,38 +916,39 @@
Adam Tkac 653904
     cs->status = SHUTDOWN;
Adam Tkac 653904
 }
Adam Tkac 653904
 
Adam Tkac 653904
-static DBusConnectionState *
Adam Tkac 653904
+static isc_result_t
Adam Tkac 653904
 connection_setup 
Adam Tkac 653904
-(   DBusConnection *connection,  
Adam Tkac 653904
+(   DBusConnection *connection,
Adam Tkac 653904
+    DBUS_SVC *dbus,
Adam Tkac 653904
     dbus_svc_WatchHandler wh, 
Adam Tkac 653904
     dbus_svc_ErrorHandler eh, 
Adam Tkac 653904
     dbus_svc_ErrorHandler dh,
Adam Tkac 653904
     void *wh_arg
Adam Tkac 653904
 )
Adam Tkac 653904
 {
Adam Tkac 653904
-    DBusConnectionState *cs = dbcs_new( connection );
Adam Tkac 653904
+    *dbus = dbcs_new( connection );
Adam Tkac 653904
     
Adam Tkac 653904
-    if ( cs == 0L )
Adam Tkac 653904
+    if ( *dbus == 0L )
Adam Tkac 653904
     {
Adam Tkac 653904
 	if(eh)(*(eh))("connection_setup: out of memory");
Adam Tkac 653904
 	goto fail;
Adam Tkac 653904
     }
Adam Tkac 653904
-    cs->wh = wh;
Adam Tkac 653904
-    cs->wh_arg = wh_arg;
Adam Tkac 653904
-    cs->eh = eh;
Adam Tkac 653904
-    cs->dh = dh;
Adam Tkac 653904
+    (*dbus)->wh = wh;
Adam Tkac 653904
+    (*dbus)->wh_arg = wh_arg;
Adam Tkac 653904
+    (*dbus)->eh = eh;
Adam Tkac 653904
+    (*dbus)->dh = dh;
Adam Tkac 653904
 
Adam Tkac 653904
     if (!dbus_connection_set_watch_functions 
Adam Tkac 653904
-	 (    cs->connection,
Adam Tkac 653904
+	 (    (*dbus)->connection,
Adam Tkac 653904
 	      add_watch,
Adam Tkac 653904
 	      remove_watch,
Adam Tkac 653904
 	      toggle_watch,
Adam Tkac 653904
-	      cs,
Adam Tkac 653904
+	      *dbus,
Adam Tkac 653904
 	      no_free
Adam Tkac 653904
 	  )
Adam Tkac 653904
        )
Adam Tkac 653904
     {
Adam Tkac 653904
-	if( cs->eh != 0L ) (*(cs->eh))("connection_setup: dbus_connection_set_watch_functions failed");
Adam Tkac 653904
+	if( (*dbus)->eh != 0L ) (*((*dbus)->eh))("connection_setup: dbus_connection_set_watch_functions failed");
Adam Tkac 653904
 	goto fail; 
Adam Tkac 653904
     }
Adam Tkac 653904
       
Adam Tkac 653904
@@ -954,43 +957,44 @@
Adam Tkac 653904
 	      add_timeout,
Adam Tkac 653904
 	      remove_timeout,
Adam Tkac 653904
 	      toggle_timeout,
Adam Tkac 653904
-	      cs, 
Adam Tkac 653904
+	      *dbus, 
Adam Tkac 653904
 	      no_free
Adam Tkac 653904
 	 )
Adam Tkac 653904
        )
Adam Tkac 653904
     {
Adam Tkac 653904
-	if( cs->eh != 0L ) (*(cs->eh))("connection_setup: dbus_connection_set_timeout_functions failed");
Adam Tkac 653904
+	if( (*dbus)->eh != 0L ) (*((*dbus)->eh))("connection_setup: dbus_connection_set_timeout_functions failed");
Adam Tkac 653904
 	goto fail;
Adam Tkac 653904
     }
Adam Tkac 653904
 
Adam Tkac 653904
     dbus_connection_set_dispatch_status_function 
Adam Tkac 653904
     (   connection, 
Adam Tkac 653904
 	dispatch_status, 
Adam Tkac 653904
-	cs, 
Adam Tkac 653904
+	*dbus, 
Adam Tkac 653904
 	no_free
Adam Tkac 653904
     ); 
Adam Tkac 653904
 
Adam Tkac 653904
     if (dbus_connection_get_dispatch_status (connection) != DBUS_DISPATCH_COMPLETE)
Adam Tkac 653904
 	dbus_connection_ref(connection);    
Adam Tkac 653904
     
Adam Tkac 653904
-    return cs;
Adam Tkac 653904
+    return ISC_R_SUCCESS;
Adam Tkac 653904
   
Adam Tkac 653904
  fail:
Adam Tkac 653904
-    if( cs != 0L )
Adam Tkac 653904
-	free(cs);
Adam Tkac 653904
+    if( *dbus != 0L )
Adam Tkac 653904
+	free(*dbus);
Adam Tkac 653904
   
Adam Tkac 653904
     dbus_connection_set_dispatch_status_function (connection, NULL, NULL, NULL);
Adam Tkac 653904
     dbus_connection_set_watch_functions (connection, NULL, NULL, NULL, NULL, NULL);
Adam Tkac 653904
     dbus_connection_set_timeout_functions (connection, NULL, NULL, NULL, NULL, NULL);
Adam Tkac 653904
   
Adam Tkac 653904
-    return 0L;
Adam Tkac 653904
+    return ISC_R_FAILURE;
Adam Tkac 653904
 }
Adam Tkac 653904
 
Adam Tkac 653904
-DBusConnectionState *
Adam Tkac 653904
+isc_result_t
Adam Tkac 653904
 dbus_svc_init
Adam Tkac 653904
 (
Adam Tkac 653904
     dbus_svc_DBUS_TYPE    bus,
Adam Tkac 653904
     char                  *name, 
Adam Tkac 653904
+    DBUS_SVC		  *dbus,
Adam Tkac 653904
     dbus_svc_WatchHandler wh ,
Adam Tkac 653904
     dbus_svc_ErrorHandler eh ,
Adam Tkac 653904
     dbus_svc_ErrorHandler dh ,
Adam Tkac 653904
@@ -999,7 +1003,6 @@
Adam Tkac 653904
 {
Adam Tkac 653904
     DBusConnection       *connection;
Adam Tkac 653904
     DBusError            error;
Adam Tkac 653904
-    DBusConnectionState  *cs;
Adam Tkac 653904
     char *session_bus_address=0L;
Adam Tkac 653904
 
Adam Tkac 653904
     memset(&error,'\0',sizeof(DBusError));
Adam Tkac 653904
@@ -1015,7 +1018,7 @@
Adam Tkac 653904
 	if ( (connection = dbus_connection_open_private("unix:path=/var/run/dbus/system_bus_socket", &error)) == 0L )
Adam Tkac 653904
 	{
Adam Tkac 653904
 	    if(eh)(*eh)("dbus_svc_init failed: %s %s",error.name, error.message);
Adam Tkac 653904
-	    return ( 0L );
Adam Tkac 653904
+	    return ISC_R_FAILURE;
Adam Tkac 653904
 	}
Adam Tkac 653904
 
Adam Tkac 653904
 	if ( ! dbus_bus_register(connection,&error) )
Adam Tkac 653904
@@ -1023,7 +1026,7 @@
Adam Tkac 653904
 	    if(eh)(*eh)("dbus_bus_register failed: %s %s", error.name, error.message);
Adam Tkac 653904
 	    dbus_connection_close(connection);
Adam Tkac 653904
 	    free(connection);
Adam Tkac 653904
-	    return ( 0L );
Adam Tkac 653904
+	    return ISC_R_FAILURE;
Adam Tkac 653904
 	}
Adam Tkac 653904
 	break;
Adam Tkac 653904
 
Adam Tkac 653904
@@ -1033,13 +1036,13 @@
Adam Tkac 653904
 	if ( session_bus_address == 0L )
Adam Tkac 653904
 	{
Adam Tkac 653904
 	    if(eh)(*eh)("dbus_svc_init failed: DBUS_SESSION_BUS_ADDRESS environment variable not set");
Adam Tkac 653904
-	    return ( 0L );
Adam Tkac 653904
+	    return ISC_R_FAILURE;
Adam Tkac 653904
 	}
Adam Tkac 653904
 
Adam Tkac 653904
 	if ( (connection = dbus_connection_open_private(session_bus_address, &error)) == 0L )
Adam Tkac 653904
 	{
Adam Tkac 653904
 	    if(eh)(*eh)("dbus_svc_init failed: %s %s",error.name, error.message);
Adam Tkac 653904
-	    return ( 0L );
Adam Tkac 653904
+	    return ISC_R_FAILURE;
Adam Tkac 653904
 	}
Adam Tkac 653904
 
Adam Tkac 653904
 	if ( ! dbus_bus_register(connection,&error) )
Adam Tkac 653904
@@ -1047,7 +1050,7 @@
Adam Tkac 653904
 	    if(eh)(*eh)("dbus_bus_register failed: %s %s", error.name, error.message);
Adam Tkac 653904
 	    dbus_connection_close(connection);
Adam Tkac 653904
 	    free(connection);
Adam Tkac 653904
-	    return ( 0L );
Adam Tkac 653904
+	    return ISC_R_FAILURE;
Adam Tkac 653904
 	}
Adam Tkac 653904
 	break;
Adam Tkac 653904
 
Adam Tkac 653904
@@ -1057,27 +1060,27 @@
Adam Tkac 653904
 	if ( (connection = dbus_bus_get (bus, &error)) == 0L )
Adam Tkac 653904
 	{
Adam Tkac 653904
 	    if(eh)(*eh)("dbus_svc_init failed: %s %s",error.name, error.message);
Adam Tkac 653904
-	    return ( 0L );
Adam Tkac 653904
+	    return ISC_R_FAILURE;
Adam Tkac 653904
 	}
Adam Tkac 653904
 	break;
Adam Tkac 653904
 
Adam Tkac 653904
     default:
Adam Tkac 653904
 	if(eh)(*eh)("dbus_svc_init failed: unknown bus type %d", bus);
Adam Tkac 653904
-	return ( 0L );
Adam Tkac 653904
+	return ISC_R_FAILURE;
Adam Tkac 653904
     }
Adam Tkac 653904
     
Adam Tkac 653904
     dbus_connection_set_exit_on_disconnect(connection, FALSE);
Adam Tkac 653904
 
Adam Tkac 653904
-    if ( (cs = connection_setup(connection, wh, eh, dh, wh_arg)) == 0L )
Adam Tkac 653904
+    if ( (connection_setup(connection, dbus, wh, eh, dh, wh_arg)) != ISC_R_SUCCESS)
Adam Tkac 653904
     {
Adam Tkac 653904
 	if(eh)(*eh)("dbus_svc_init failed: connection_setup failed");
Adam Tkac 653904
-	return( 0L );
Adam Tkac 653904
+	return ISC_R_FAILURE;
Adam Tkac 653904
     }
Adam Tkac 653904
 
Adam Tkac 653904
     if( name == 0L )
Adam Tkac 653904
-	return( cs );
Adam Tkac 653904
+	return ISC_R_SUCCESS;
Adam Tkac 653904
     
Adam Tkac 653904
-    cs->unique_name = dbus_bus_get_unique_name(connection);
Adam Tkac 653904
+    (*dbus)->unique_name = dbus_bus_get_unique_name(connection);
Adam Tkac 653904
 
Adam Tkac 653904
     switch
Adam Tkac 653904
 	(   dbus_bus_request_name 
Adam Tkac 653904
@@ -1102,19 +1105,19 @@
Adam Tkac 653904
 	if(eh)(*eh)("dbus_svc_init: dbus_bus_request_name failed: %s %s", error.name, error.message);
Adam Tkac 653904
 	goto give_up;
Adam Tkac 653904
     }
Adam Tkac 653904
-    return ( cs );
Adam Tkac 653904
+    return ISC_R_SUCCESS;
Adam Tkac 653904
 
Adam Tkac 653904
  give_up:
Adam Tkac 653904
     dbus_connection_close( connection );
Adam Tkac 653904
     dbus_connection_unref( connection );
Adam Tkac 653904
-    if( cs )
Adam Tkac 653904
+    if( *dbus )
Adam Tkac 653904
     {
Adam Tkac 653904
 	dbus_connection_set_dispatch_status_function (connection, NULL, NULL, NULL);
Adam Tkac 653904
 	dbus_connection_set_watch_functions (connection, NULL, NULL, NULL, NULL, NULL);
Adam Tkac 653904
 	dbus_connection_set_timeout_functions (connection, NULL, NULL, NULL, NULL, NULL);
Adam Tkac 653904
-	free(cs);    
Adam Tkac 653904
+	free(*dbus);    
Adam Tkac 653904
     }
Adam Tkac 653904
-    return ( 0L );
Adam Tkac 653904
+    return ISC_R_FAILURE;
Adam Tkac 653904
 }
Adam Tkac 653904
 
Adam Tkac 653904
 const char *dbus_svc_unique_name(DBusConnectionState *cs)
Adam Tkac 653904
--- bind-9.4.0/contrib/dbus/dbus_mgr.c.race-condition	2006-01-23 05:56:26.000000000 +0100
Adam Tkac 653904
+++ bind-9.4.0/contrib/dbus/dbus_mgr.c	2007-04-27 15:03:19.000000000 +0200
Adam Tkac 653904
@@ -4,6 +4,7 @@
Adam Tkac 653904
  *  response to D-BUS dhcp events or commands.
Adam Tkac 653904
  *
Adam Tkac 653904
  *  Copyright(C) Jason Vas Dias, Red Hat Inc., 2005
Adam Tkac 653904
+ *  Modified by Adam Tkac, Red Hat Inc., 2007
Adam Tkac 653904
  *
Adam Tkac 653904
  *  This program is free software; you can redistribute it and/or modify
Adam Tkac 653904
  *  it under the terms of the GNU General Public License as published by
Adam Tkac 653904
@@ -281,6 +282,7 @@
Adam Tkac 653904
 dbus_mgr_init_dbus(ns_dbus_mgr_t * mgr)
Adam Tkac 653904
 {
Adam Tkac 653904
     char destination[]=DBUSMGR_DESTINATION;
Adam Tkac 653904
+    isc_result_t result;
Adam Tkac 653904
 
Adam Tkac 653904
     if( mgr->sockets != 0L )
Adam Tkac 653904
     {
Adam Tkac 653904
@@ -296,14 +298,11 @@
Adam Tkac 653904
 	mgr->dbus = 0L;
Adam Tkac 653904
     }
Adam Tkac 653904
 
Adam Tkac 653904
-    mgr->dbus = 
Adam Tkac 653904
-	dbus_svc_init
Adam Tkac 653904
-	(   DBUS_PRIVATE_SYSTEM,
Adam Tkac 653904
-	    destination,
Adam Tkac 653904
-	    dbus_mgr_watch_handler,
Adam Tkac 653904
-	    0L, 0L,
Adam Tkac 653904
-	    mgr
Adam Tkac 653904
-	);
Adam Tkac 653904
+    result = dbus_svc_init(DBUS_PRIVATE_SYSTEM, destination, &mgr->dbus,
Adam Tkac 653904
+					dbus_mgr_watch_handler, 0L, 0L, mgr);
Adam Tkac 653904
+
Adam Tkac 653904
+    if(result != ISC_R_SUCCESS)
Adam Tkac 653904
+	goto cleanup;
Adam Tkac 653904
 
Adam Tkac 653904
     if( mgr->dbus == 0L )
Adam Tkac 653904
     {
Adam Tkac 653904
--- bind-9.4.0/contrib/dbus/dbus_service.h.race-condition	2006-01-23 05:56:26.000000000 +0100
Adam Tkac 653904
+++ bind-9.4.0/contrib/dbus/dbus_service.h	2007-04-27 15:03:19.000000000 +0200
Adam Tkac 653904
@@ -3,6 +3,7 @@
Adam Tkac 653904
  *  Provides utilities for construction of D-BUS "Services"  
Adam Tkac 653904
  *
Adam Tkac 653904
  *  Copyright(C) Jason Vas Dias, Red Hat Inc., 2005
Adam Tkac 653904
+ *  Modified by Adam Tkac, Red Hat Inc., 2007
Adam Tkac 653904
  *
Adam Tkac 653904
  *  This program is free software; you can redistribute it and/or modify
Adam Tkac 653904
  *  it under the terms of the GNU General Public License as published by
Adam Tkac 653904
@@ -22,6 +23,7 @@
Adam Tkac 653904
 
Adam Tkac 653904
 #include <stdint.h>
Adam Tkac 653904
 #include <stdarg.h>
Adam Tkac 653904
+#include <isc/types.h>
Adam Tkac 653904
 
Adam Tkac 653904
 typedef struct dbcs_s* DBUS_SVC;
Adam Tkac 653904
 
Adam Tkac 653904
@@ -124,9 +126,10 @@
Adam Tkac 653904
 
Adam Tkac 653904
 #define SHUTDOWN 255
Adam Tkac 653904
 
Adam Tkac 653904
-extern  DBUS_SVC dbus_svc_init
Adam Tkac 653904
+extern isc_result_t dbus_svc_init
Adam Tkac 653904
 ( dbus_svc_DBUS_TYPE bus, 
Adam Tkac 653904
   char *name,                         /* name to register with D-BUS */
Adam Tkac 653904
+  DBUS_SVC *dbus,                     /* dbus handle */
Adam Tkac 653904
   dbus_svc_WatchHandler wh,           /* optional handler for watch events */
Adam Tkac 653904
   dbus_svc_ErrorHandler eh,           /* optional error log message handler */
Adam Tkac 653904
   dbus_svc_ErrorHandler dh,           /* optional debug / info log message handler */