From a3e171f81bdc1478fa4970bb61cf7aa76ae9ce7c Mon Sep 17 00:00:00 2001 From: Alexey Tikhonov Date: Mon, 13 May 2024 16:39:50 +0200 Subject: [PATCH] TOOLS: don't overwrite config.ldb This partially reverts d2d8f342cd5e90bb9fd947c448492225f959aa86 There should be no reason for 'sssctl' to run if SSSD itself isn't running (ir wasn't run so 'config.ldb' is absent). Enforced recreation of 'config.ldb', on the other hand, might spoil file ownership, as 'sssct' is typically run under 'root', but SSSD itself might running under 'sssd' user. --- src/tools/common/sss_tools.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/tools/common/sss_tools.c b/src/tools/common/sss_tools.c index f8a7d280517..d4b3cb1d0d2 100644 --- a/src/tools/common/sss_tools.c +++ b/src/tools/common/sss_tools.c @@ -26,7 +26,6 @@ #include "config.h" #include "util/util.h" #include "confdb/confdb.h" -#include "confdb/confdb_setup.h" #include "db/sysdb.h" #include "tools/common/sss_tools.h" @@ -94,18 +93,25 @@ static errno_t sss_tool_confdb_init(TALLOC_CTX *mem_ctx, struct confdb_ctx *confdb; char *path; errno_t ret; + struct stat statbuf; path = talloc_asprintf(mem_ctx, "%s/%s", DB_PATH, CONFDB_FILE); if (path == NULL) { return ENOMEM; } - ret = confdb_setup(mem_ctx, path, - SSSD_CONFIG_FILE, CONFDB_DEFAULT_CONFIG_DIR, - NULL, false, &confdb); + ret = stat(path, &statbuf); + if (ret != 0) { + ret = errno; + DEBUG(SSSDBG_FATAL_FAILURE, + "Can't access '%s', probably SSSD isn't running\n", path); + return ret; + } + + ret = confdb_init(mem_ctx, &confdb, path); talloc_zfree(path); if (ret != EOK) { - DEBUG(SSSDBG_FATAL_FAILURE, "Unable to setup ConfDB [%d]: %s\n", + DEBUG(SSSDBG_FATAL_FAILURE, "Unable to connect to configDB [%d]: %s\n", ret, sss_strerror(ret)); return ret; }