From 566dcf1f4f6a443eebfbc07f5b68f9fb649a5361 Mon Sep 17 00:00:00 2001 From: Stephen Gallagher Date: Mon, 9 Mar 2009 07:38:33 -0400 Subject: [PATCH] Fix SIGSEGV in InfoPipe startup If the user that starts InfoPipe is not permitted by the system bus to request the InfoPipe name, the sssd_info process would segfault, since the destructor for the connection object was called before it was completely created. I have moved the initialization of the destructor to later in the setup routine. --- server/infopipe/sysbus.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) diff --git a/server/infopipe/sysbus.c b/server/infopipe/sysbus.c index a90f92d..efb43b3 100644 --- a/server/infopipe/sysbus.c +++ b/server/infopipe/sysbus.c @@ -113,8 +113,6 @@ int sysbus_init(TALLOC_CTX *mem_ctx, struct sysbus_ctx **sysbus, return EIO; } dbus_connection_set_exit_on_disconnect(conn, FALSE); - talloc_set_destructor((TALLOC_CTX *)system_bus, - sysbus_destructor); ret = dbus_bus_request_name(conn, dbus_name, @@ -126,6 +124,7 @@ int sysbus_init(TALLOC_CTX *mem_ctx, struct sysbus_ctx **sysbus, /* We were unable to register on the system bus */ DEBUG(0, ("Unable to request name on the system bus. Error: %s\n", dbus_error.message)); if (dbus_error_is_set(&dbus_error)) dbus_error_free(&dbus_error); + dbus_connection_unref(conn); talloc_free(system_bus); return EIO; } @@ -136,9 +135,12 @@ int sysbus_init(TALLOC_CTX *mem_ctx, struct sysbus_ctx **sysbus, ret = sbus_add_connection(system_bus, ev, conn, &system_bus->sconn, SBUS_CONN_TYPE_SHARED); if (ret != EOK) { DEBUG(0, ("Could not integrate D-BUS into mainloop.\n")); + dbus_connection_unref(conn); talloc_free(system_bus); return ret; } + talloc_set_destructor((TALLOC_CTX *)system_bus, + sysbus_destructor); /* Set up methods */ ret = sysbus_init_methods(system_bus, system_bus, interface, path, -- 1.6.0.6