summaryrefslogtreecommitdiffstats
path: root/server/tools/tools_util.c
diff options
context:
space:
mode:
authorSimo Sorce <ssorce@redhat.com>2009-09-29 10:14:36 -0400
committerStephen Gallagher <sgallagh@redhat.com>2009-10-01 08:42:36 -0400
commitf24c2dd7cc8414ea0a5c8c4ae7766ca71554480f (patch)
treecceff211fe8fc0c78c59b959af5367c0c4ce49f3 /server/tools/tools_util.c
parentbc58f5892d3a8f6b28e2148c5a0cca34b63ef354 (diff)
downloadsssd-f24c2dd7cc8414ea0a5c8c4ae7766ca71554480f.tar.gz
sssd-f24c2dd7cc8414ea0a5c8c4ae7766ca71554480f.tar.xz
sssd-f24c2dd7cc8414ea0a5c8c4ae7766ca71554480f.zip
Fix tools sync operations and mem hierarchy
Tools were using nested loops that are illegal. (and enforced in latest tevent with a nice abort()) Fix them by creating appropriate synchronous transaction calls. Also fix tools_ctx mem hierarchy setup.
Diffstat (limited to 'server/tools/tools_util.c')
-rw-r--r--server/tools/tools_util.c48
1 files changed, 17 insertions, 31 deletions
diff --git a/server/tools/tools_util.c b/server/tools/tools_util.c
index a6ccbc943..777217213 100644
--- a/server/tools/tools_util.c
+++ b/server/tools/tools_util.c
@@ -28,19 +28,13 @@
#include "confdb/confdb.h"
#include "db/sysdb.h"
#include "tools/tools_util.h"
+#include "tools/sss_sync_ops.h"
-static int setup_db(TALLOC_CTX *mem_ctx, struct tools_ctx **tools_ctx)
+static int setup_db(struct tools_ctx *ctx)
{
char *confdb_path;
- struct tools_ctx *ctx;
int ret;
- ctx = talloc_zero(mem_ctx, struct tools_ctx);
- if (ctx == NULL) {
- DEBUG(1, ("Could not allocate memory for tools context\n"));
- return ENOMEM;
- }
-
/* Create the event context */
ctx->ev = tevent_context_init(ctx);
if (ctx->ev == NULL) {
@@ -79,7 +73,6 @@ static int setup_db(TALLOC_CTX *mem_ctx, struct tools_ctx **tools_ctx)
}
talloc_free(confdb_path);
- *tools_ctx = ctx;
return EOK;
}
@@ -238,18 +231,15 @@ int init_sss_tools(struct tools_ctx **_tctx)
{
int ret;
struct tools_ctx *tctx;
- struct ops_ctx *octx;
- octx = talloc_zero(NULL, struct ops_ctx);
- if (octx == NULL) {
- DEBUG(1, ("Could not allocate memory for data context\n"));
- ERROR("Out of memory\n");
- ret = ENOMEM;
- goto fini;
+ tctx = talloc_zero(NULL, struct tools_ctx);
+ if (tctx == NULL) {
+ DEBUG(1, ("Could not allocate memory for tools context\n"));
+ return ENOMEM;
}
/* Connect to the database */
- ret = setup_db(octx, &tctx);
+ ret = setup_db(tctx);
if (ret != EOK) {
DEBUG(1, ("Could not set up database\n"));
goto fini;
@@ -261,24 +251,20 @@ int init_sss_tools(struct tools_ctx **_tctx)
goto fini;
}
- octx->domain = tctx->local;
- tctx->octx = octx;
+ tctx->octx = talloc_zero(tctx, struct ops_ctx);
+ if (!tctx->octx) {
+ DEBUG(1, ("Could not allocate memory for data context\n"));
+ ERROR("Out of memory\n");
+ ret = ENOMEM;
+ goto fini;
+ }
+ tctx->octx->domain = tctx->local;
*_tctx = tctx;
ret = EOK;
+
fini:
+ if (ret != EOK) talloc_free(tctx);
return ret;
}
-/*
- * Common transaction finish
- */
-void tools_transaction_done(struct tevent_req *req)
-{
- struct tools_ctx *tctx = tevent_req_callback_data(req,
- struct tools_ctx);
-
- tctx->error = sysdb_transaction_commit_recv(req);
- tctx->transaction_done = true;
-}
-