Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TOOLS: use sss_tool_confdb_init() everywhere
Browse files Browse the repository at this point in the history
Take a note this also enforces check for existance of config.ldb in additional
code paths (this is intentional side effect, see a008acc)
alexey-tikhonov committed Aug 30, 2024
1 parent c78f328 commit 8289db3
Showing 2 changed files with 4 additions and 18 deletions.
11 changes: 2 additions & 9 deletions src/tools/sss_cache.c
Original file line number Diff line number Diff line change
@@ -27,6 +27,7 @@

#include "util/util.h"
#include "tools/tools_util.h"
#include "tools/common/sss_tools.h"
#include "db/sysdb.h"
#include "db/sysdb_services.h"
#include "db/sysdb_autofs.h"
@@ -661,18 +662,10 @@ static errno_t invalidate_entry(TALLOC_CTX *ctx,
static errno_t init_domains(struct cache_tool_ctx *ctx,
const char *domain)
{
char *confdb_path;
int ret;
struct sss_domain_info *dinfo;

confdb_path = talloc_asprintf(ctx, "%s/%s", DB_PATH, CONFDB_FILE);
if (confdb_path == NULL) {
return ENOMEM;
}

/* Connect to the conf db */
ret = confdb_init(ctx, &ctx->confdb, confdb_path);
talloc_free(confdb_path);
ret = sss_tool_confdb_init(ctx, &ctx->confdb);
if (ret != EOK) {
DEBUG(SSSDBG_CRIT_FAILURE,
"Could not initialize connection to the confdb\n");
11 changes: 2 additions & 9 deletions src/tools/sss_seed.c
Original file line number Diff line number Diff line change
@@ -33,6 +33,7 @@
#include "util/util.h"
#include "db/sysdb.h"
#include "tools/tools_util.h"
#include "tools/common/sss_tools.h"
#include "confdb/confdb.h"

#ifndef BUFSIZE
@@ -628,7 +629,6 @@ static int seed_init_db(TALLOC_CTX *mem_ctx,
struct sysdb_ctx **_sysdb)
{
TALLOC_CTX *tmp_ctx = NULL;
char *confdb_path = NULL;
struct confdb_ctx *confdb = NULL;
struct sss_domain_info *domain = NULL;
int ret = EOK;
@@ -639,14 +639,7 @@ static int seed_init_db(TALLOC_CTX *mem_ctx,
goto done;
}

/* setup confdb */
confdb_path = talloc_asprintf(tmp_ctx, "%s/%s", DB_PATH, CONFDB_FILE);
if (confdb_path == NULL) {
ret = ENOMEM;
goto done;
}

ret = confdb_init(tmp_ctx, &confdb, confdb_path);
ret = sss_tool_confdb_init(tmp_ctx, &confdb);
if (ret != EOK) {
DEBUG(SSSDBG_CRIT_FAILURE,
"Could not initialize connection to the confdb\n");

0 comments on commit 8289db3

Please sign in to comment.