From 124083f5801312aeef6f97402dba181d98eb708c Mon Sep 17 00:00:00 2001 From: Stephen Gallagher Date: Mon, 15 Dec 2008 10:12:43 -0500 Subject: Disconnected client SBUS connections would delete the master set of sbus_method_ctx entries, meaning that the next connection to attempt to disconnect would receive a segmentation fault also trying to delete them. They are now talloc_reference()-ed to their connection context and talloc_unlink()-ed upon deletion. I have also modified the sbus_new_server() call to take a reference to an sbus_srv_ctx object as a return argument, so that the calling function can keep track of the SBUS server context if it so chooses. --- server/sbus/sssd_dbus.h | 3 ++- server/sbus/sssd_dbus_connection.c | 3 ++- server/sbus/sssd_dbus_server.c | 7 +++++-- 3 files changed, 9 insertions(+), 4 deletions(-) (limited to 'server/sbus') diff --git a/server/sbus/sssd_dbus.h b/server/sbus/sssd_dbus.h index 75567ac04..398469945 100644 --- a/server/sbus/sssd_dbus.h +++ b/server/sbus/sssd_dbus.h @@ -23,6 +23,7 @@ #define _SSSD_DBUS_H_ struct sbus_conn_ctx; +struct sbus_srv_ctx; #include "dbus/dbus.h" @@ -67,7 +68,7 @@ struct sbus_message_handler_ctx { /* Server Functions */ int sbus_new_server(struct event_context *ev, struct sbus_method_ctx *ctx, - const char *address, + struct sbus_srv_ctx **server_ctx, const char *address, sbus_server_conn_init_fn init_fn, void *init_pvt_data); /* Connection Functions */ diff --git a/server/sbus/sssd_dbus_connection.c b/server/sbus/sssd_dbus_connection.c index b1c765562..e4e122648 100644 --- a/server/sbus/sssd_dbus_connection.c +++ b/server/sbus/sssd_dbus_connection.c @@ -548,6 +548,7 @@ int sbus_conn_add_method_ctx(struct sbus_conn_ctx *dct_ctx, } DLIST_ADD(dct_ctx->method_ctx_list, method_ctx); + talloc_reference(dct_ctx, method_ctx); /* Set up the vtable for the object path */ connection_vtable = talloc_zero(dct_ctx, DBusObjectPathVTable); @@ -603,7 +604,7 @@ static void sbus_unreg_object_paths(struct sbus_conn_ctx *dct_ctx) DLIST_REMOVE(dct_ctx->method_ctx_list, iter); purge = iter; iter = iter->next; - talloc_free(purge); + talloc_unlink(dct_ctx, purge); } } diff --git a/server/sbus/sssd_dbus_server.c b/server/sbus/sssd_dbus_server.c index 182e31010..d1d937393 100644 --- a/server/sbus/sssd_dbus_server.c +++ b/server/sbus/sssd_dbus_server.c @@ -254,8 +254,8 @@ static void sbus_server_init_new_connection(DBusServer *server, * for handling file descriptor and timed events */ int sbus_new_server(struct event_context *ev, struct sbus_method_ctx *ctx, - const char *address, sbus_server_conn_init_fn init_fn, - void *init_pvt_data) + struct sbus_srv_ctx **server_ctx, const char *address, + sbus_server_conn_init_fn init_fn, void *init_pvt_data) { struct sbus_srv_ctx *srv_ctx; DBusServer *dbus_server; @@ -263,6 +263,8 @@ int sbus_new_server(struct event_context *ev, struct sbus_method_ctx *ctx, dbus_bool_t dbret; char *tmp; + *server_ctx = NULL; + /* Set up D-BUS server */ dbus_error_init(&dbus_error); dbus_server = dbus_server_listen(address, &dbus_error); @@ -320,6 +322,7 @@ int sbus_new_server(struct event_context *ev, struct sbus_method_ctx *ctx, return EIO; } + *server_ctx = srv_ctx; return EOK; } -- cgit