From 6539046350116dce7c206c7a35557ec13faf651b Mon Sep 17 00:00:00 2001 From: Adam Tkac Date: Fri, 27 Apr 2007 13:45:53 +0000 Subject: [PATCH] - fixed race-condition in dbus code (#235809) --- bind-9.4.0-dbus-race-condition.patch | 299 +++++++++++++++++++++++++++ bind.spec | 9 +- named.caching-nameserver.conf | 2 +- 3 files changed, 305 insertions(+), 5 deletions(-) create mode 100644 bind-9.4.0-dbus-race-condition.patch diff --git a/bind-9.4.0-dbus-race-condition.patch b/bind-9.4.0-dbus-race-condition.patch new file mode 100644 index 0000000..67892bc --- /dev/null +++ b/bind-9.4.0-dbus-race-condition.patch @@ -0,0 +1,299 @@ +--- 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 */ diff --git a/bind.spec b/bind.spec index 4f52c0b..cc43ba0 100644 --- a/bind.spec +++ b/bind.spec @@ -82,7 +82,7 @@ Patch64: bind-9.4.0-idnkit-autotools.patch Patch65: bind-9.4.0-dig-idn.patch %endif Patch66: bind-9.4.0-zone-freeze.patch -#Patch67: bind-9.4.0-dbus-race-condition.patch +Patch67: bind-9.4.0-dbus-race-condition.patch # Requires: bind-libs = %{epoch}:%{version}-%{release}, glibc >= 2.2, mktemp Requires(post): grep, chkconfig >= 1.3.26 @@ -288,7 +288,7 @@ cp -fp contrib/sdb/sqlite/zone2sqlite.c bin/sdb_tools # # this must follow all dbus patches: # -#%patch67 -p1 -b .race-condition +%patch67 -p1 -b .race-condition cp -fp contrib/dbus/{dbus_mgr.c,dbus_service.c} bin/named cp -fp contrib/dbus/{dbus_mgr.h,dbus_service.h} bin/named/include/named %if %{SDB} @@ -315,7 +315,7 @@ popd %build -export CFLAGS="$RPM_OPT_FLAGS" +export CFLAGS="$RPM_OPT_FLAGS -O0" %if %{IDN} pushd contrib/idn/idnkit-1.0-src @@ -808,10 +808,11 @@ rm -rf ${RPM_BUILD_ROOT} %changelog -* Tue Apr 24 2007 Adam Tkac 31:9.4.0-8.fc7 +* Fri Apr 27 2007 Adam Tkac 31:9.4.0-8.fc7 - improved "zone freeze patch" - if multiple zone with same name exists no zone is freezed - minor cleanup in caching-nameserver's config file +- fixed race-condition in dbus code (#235809) * Tue Apr 17 2007 Adam Tkac 31:9.4.0-7.fc7 - removed DEBUGINFO option because with this option (default) was bind diff --git a/named.caching-nameserver.conf b/named.caching-nameserver.conf index 03dbbef..bb06090 100644 --- a/named.caching-nameserver.conf +++ b/named.caching-nameserver.conf @@ -3,7 +3,7 @@ // // Provided by Red Hat caching-nameserver package to configure the // ISC BIND named(8) DNS server as a caching only nameserver -// (as a localhost DNS resolver only). +// (as a localhost DNS resolver only). // // See /usr/share/doc/bind*/sample/ for example named configuration files. //