Skip to content

Commit

Permalink
TOOLS: don't overwrite config.ldb
Browse files Browse the repository at this point in the history
This partially reverts d2d8f34
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.
  • Loading branch information
alexey-tikhonov committed May 13, 2024
1 parent 5531e1d commit a3e171f
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/tools/common/sss_tools.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit a3e171f

Please sign in to comment.