Skip to content

Commit

Permalink
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)
  • Loading branch information
alexey-tikhonov committed Aug 31, 2024
1 parent c78f328 commit b94f8cf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 21 deletions.
16 changes: 4 additions & 12 deletions src/tools/sss_cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -661,22 +662,13 @@ 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");
return ret;
ERROR("Can't find configuration db, was SSSD configured and run?\n")
return ERR_NO_DOMAIN_ENABLED;
}

if (domain) {
Expand Down
11 changes: 2 additions & 9 deletions src/tools/sss_seed.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -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");
Expand Down

0 comments on commit b94f8cf

Please sign in to comment.