summaryrefslogtreecommitdiffstats
path: root/server/tools/tools_util.c
diff options
context:
space:
mode:
authorSimo Sorce <ssorce@redhat.com>2009-09-04 17:46:13 -0400
committerStephen Gallagher <sgallagh@redhat.com>2009-09-08 15:10:50 -0400
commit889efbe608251def17c7ba6131fc9aa36c462dc2 (patch)
tree4fcd6274b37c45294a12b6cd9bc62a70bf878e7e /server/tools/tools_util.c
parent28d9dcbeabdf919506fe59e9d1cbed84fbd6e649 (diff)
downloadsssd-889efbe608251def17c7ba6131fc9aa36c462dc2.tar.gz
sssd-889efbe608251def17c7ba6131fc9aa36c462dc2.tar.xz
sssd-889efbe608251def17c7ba6131fc9aa36c462dc2.zip
Tools are allowed to touch only the 'local' domain
Diffstat (limited to 'server/tools/tools_util.c')
-rw-r--r--server/tools/tools_util.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/server/tools/tools_util.c b/server/tools/tools_util.c
index 3b16f5931..6845735c2 100644
--- a/server/tools/tools_util.c
+++ b/server/tools/tools_util.c
@@ -130,6 +130,7 @@ int get_domain_by_id(struct tools_ctx *ctx,
int setup_db(struct tools_ctx **tools_ctx)
{
+ struct sss_domain_info *dom;
TALLOC_CTX *tmp_ctx;
char *confdb_path;
struct tools_ctx *ctx;
@@ -137,14 +138,14 @@ int setup_db(struct tools_ctx **tools_ctx)
ctx = talloc_zero(NULL, struct tools_ctx);
if (ctx == NULL) {
- DEBUG(1, ("Could not allocate memory for tools context"));
+ 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) {
- DEBUG(1, ("Could not create event context"));
+ DEBUG(1, ("Could not create event context\n"));
talloc_free(ctx);
return EIO;
}
@@ -162,22 +163,29 @@ int setup_db(struct tools_ctx **tools_ctx)
/* Connect to the conf db */
ret = confdb_init(ctx, ctx->ev, &ctx->confdb, confdb_path);
if (ret != EOK) {
- DEBUG(1, ("Could not initialize connection to the confdb"));
+ DEBUG(1, ("Could not initialize connection to the confdb\n"));
talloc_free(ctx);
return ret;
}
ret = confdb_get_domains(ctx->confdb, &ctx->domains);
if (ret != EOK) {
- DEBUG(1, ("Could not get domains"));
+ DEBUG(1, ("Could not get domains\n"));
+ talloc_free(ctx);
+ return ret;
+ }
+
+ ret = confdb_get_domain(ctx->confdb, "local", &dom);
+ if (ret != EOK) {
+ DEBUG(1, ("Could not get 'local' domain\n"));
talloc_free(ctx);
return ret;
}
- /* open sysdb at default path */
- ret = sysdb_init(ctx, ctx->ev, ctx->confdb, NULL, false, &ctx->db_list);
+ /* open 'local' sysdb at default path */
+ ret = sysdb_domain_init(ctx, ctx->ev, dom, DB_PATH, &ctx->sysdb);
if (ret != EOK) {
- DEBUG(1, ("Could not initialize connection to the sysdb"));
+ DEBUG(1, ("Could not initialize connection to the sysdb\n"));
talloc_free(ctx);
return ret;
}