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 (or 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.

This also reverts f405a4a
` confdb_expand_app_domains()` in `sss_tool_domains_init()` isn't
needed anymore, because 'sssctl' now uses 'config.ldb' created by
'monitor' where this expansion was already done.
  • Loading branch information
alexey-tikhonov committed May 13, 2024
1 parent 5531e1d commit 94dba2a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/tests/intg/test_sssctl.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ def test_debug_level_no_sssd(conf_stub_domain, portable_LC_ALL):
stderr_output=subprocess.STDOUT)
except subprocess.CalledProcessError as cpe:
assert cpe.returncode == 1
assert "SSSD is not running" in cpe.output
assert "SSSD isn't configured" in cpe.output

try:
get_call_output(["sssctl", "debug-level", "0x70"], check=True,
Expand Down
24 changes: 11 additions & 13 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 configured\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 All @@ -125,14 +131,6 @@ static errno_t sss_tool_domains_init(TALLOC_CTX *mem_ctx,
struct sss_domain_info *dom;
errno_t ret;

ret = confdb_expand_app_domains(confdb);
if (ret != EOK) {
DEBUG(SSSDBG_CRIT_FAILURE,
"Unable to expand application domains [%d]: %s\n",
ret, sss_strerror(ret));
return ret;
}

ret = confdb_get_domains(confdb, &domains);
if (ret != EOK) {
DEBUG(SSSDBG_CRIT_FAILURE, "Unable to setup domains [%d]: %s\n",
Expand Down

0 comments on commit 94dba2a

Please sign in to comment.