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