diff options
author | Simo Sorce <idra@samba.org> | 2008-11-19 14:17:27 -0500 |
---|---|---|
committer | Simo Sorce <idra@samba.org> | 2008-11-19 14:17:27 -0500 |
commit | b819da364c40fb79f4cab87d02c3dd4ec3fe8b50 (patch) | |
tree | 8134b81331bf5088727288f0c27bea8611ab5ae4 /server/sbus/sssd_dbus_server.c | |
parent | 18de263889a8cb71ff9d3087e5cef5777d0221b5 (diff) | |
download | sssd-b819da364c40fb79f4cab87d02c3dd4ec3fe8b50.tar.gz sssd-b819da364c40fb79f4cab87d02c3dd4ec3fe8b50.tar.xz sssd-b819da364c40fb79f4cab87d02c3dd4ec3fe8b50.zip |
Add method to get a connection's private data
Fix memory hierarchy, set the destructor on the server context so
that it is called before any memory attached to it is freed. Before
this change a talloc_free() on the event context would end in a double
free and and an abort() inside talloc.
Diffstat (limited to 'server/sbus/sssd_dbus_server.c')
-rw-r--r-- | server/sbus/sssd_dbus_server.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/server/sbus/sssd_dbus_server.c b/server/sbus/sssd_dbus_server.c index f8396b5c9..3b3f9f1ad 100644 --- a/server/sbus/sssd_dbus_server.c +++ b/server/sbus/sssd_dbus_server.c @@ -56,7 +56,7 @@ struct dbus_srv_timeout_ctx { struct sbus_srv_ctx *top; }; -static int sbus_server_destructor(void **server); +static int sbus_server_destructor(void *ctx); /* * dbus_server_read_write_handler @@ -209,7 +209,7 @@ static void sbus_server_init_new_connection(DBusServer *server, int ret; DEBUG(3,("Entering.\n")); - srv_ctx = talloc_get_type(data,struct sbus_srv_ctx); + srv_ctx = talloc_get_type(data, struct sbus_srv_ctx); if (srv_ctx == NULL) { return; } @@ -259,7 +259,6 @@ int sbus_new_server(struct event_context *ev, struct sbus_method_ctx *ctx, { struct sbus_srv_ctx *srv_ctx; DBusServer *dbus_server; - DBusServer **dbus_server_talloc; DBusError dbus_error; dbus_bool_t dbret; @@ -280,14 +279,14 @@ int sbus_new_server(struct event_context *ev, struct sbus_method_ctx *ctx, return ENOMEM; } - dbus_server_talloc = sssd_mem_takeover(ctx, dbus_server, - sbus_server_destructor); srv_ctx->ev = ev; srv_ctx->server = dbus_server; srv_ctx->sd_ctx = ctx; srv_ctx->init_fn = init_fn; srv_ctx->init_pvt_data = init_pvt_data; + talloc_set_destructor((TALLOC_CTX *)srv_ctx, sbus_server_destructor); + /* Set up D-BUS new connection handler */ dbus_server_set_new_connection_function(srv_ctx->server, sbus_server_init_new_connection, @@ -322,8 +321,9 @@ int sbus_new_server(struct event_context *ev, struct sbus_method_ctx *ctx, return EOK; } -static int sbus_server_destructor(void **server) +static int sbus_server_destructor(void *ctx) { - dbus_server_disconnect(*server); + struct sbus_srv_ctx *srv_ctx = talloc_get_type(ctx, struct sbus_srv_ctx); + dbus_server_disconnect(srv_ctx->server); return 0; } |