Skip to content

Commit

Permalink
Get rid of --genconf and --genconf-section monitor options.
Browse files Browse the repository at this point in the history
The only usage was 'sssd-kcm.service', but it was wrong since 'sssd_kcm'
should be usable without other SSSD packages being installed (see #6926)
Instead 'sssd_kcm' should take care of parsing/preparing configuration
on its own (to be taken care of in separate PR).
  • Loading branch information
alexey-tikhonov committed Sep 13, 2023
1 parent 393f8d2 commit d016385
Show file tree
Hide file tree
Showing 13 changed files with 69 additions and 503 deletions.
1 change: 0 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -5666,7 +5666,6 @@ dist_noinst_DATA += \
src/tests/multihost/conftest.py \
src/tests/multihost/basic/mhc.yaml \
src/tests/multihost/basic/test_basic.py \
src/tests/multihost/basic/test_config.py \
src/tests/multihost/basic/test_files.py \
src/tests/multihost/basic/test_ifp.py \
src/tests/multihost/basic/test_kcm.py \
Expand Down
57 changes: 26 additions & 31 deletions src/confdb/confdb_setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,22 @@
#include "confdb_setup.h"
#include "util/sss_ini.h"

#define CONFDB_BASE_LDIF \
"dn: @ATTRIBUTES\n" \
"cn: CASE_INSENSITIVE\n" \
"dc: CASE_INSENSITIVE\n" \
"dn: CASE_INSENSITIVE\n" \
"name: CASE_INSENSITIVE\n" \
"objectclass: CASE_INSENSITIVE\n" \
"\n" \
"dn: @INDEXLIST\n" \
"@IDXATTR: cn\n" \
"\n" \
"dn: @MODULES\n" \
"@LIST: server_sort\n" \
"\n"


static int confdb_purge(struct confdb_ctx *cdb)
{
int ret;
Expand Down Expand Up @@ -87,7 +103,6 @@ static int confdb_create_base(struct confdb_ctx *cdb)
static int confdb_ldif_from_ini_file(TALLOC_CTX *mem_ctx,
const char *config_file,
const char *config_dir,
const char *only_section,
struct sss_ini *init_data,
const char **_ldif)
{
Expand All @@ -107,7 +122,7 @@ static int confdb_ldif_from_ini_file(TALLOC_CTX *mem_ctx,
/* This is not fatal, continue */
}

ret = sss_confdb_create_ldif(mem_ctx, init_data, only_section, _ldif);
ret = sss_confdb_create_ldif(mem_ctx, init_data, _ldif);
if (ret != EOK) {
DEBUG(SSSDBG_FATAL_FAILURE, "Could not create LDIF for confdb\n");
return ret;
Expand All @@ -116,9 +131,7 @@ static int confdb_ldif_from_ini_file(TALLOC_CTX *mem_ctx,
return EOK;
}

static int confdb_write_ldif(struct confdb_ctx *cdb,
const char *config_ldif,
bool replace_whole_db)
static int confdb_write_ldif(struct confdb_ctx *cdb, const char *config_ldif)
{
int ret;
struct ldb_ldif *ldif;
Expand All @@ -133,21 +146,11 @@ static int confdb_write_ldif(struct confdb_ctx *cdb,
}
} else {
ret = ldb_add(cdb->ldb, ldif->msg);
if (ret != LDB_SUCCESS && replace_whole_db == false) {
/* This section already existed, remove and re-add it. We
* really want to replace the whole thing instead of messing
* around with changetypes and flags on individual elements
*/
ret = ldb_delete(cdb->ldb, ldif->msg->dn);
if (ret == LDB_SUCCESS) {
ret = ldb_add(cdb->ldb, ldif->msg);
}
}
}

if (ret != LDB_SUCCESS) {
DEBUG(SSSDBG_FATAL_FAILURE,
"Failed to initialize DB (%d,[%s]), aborting!\n",
"Failed to update DB (%d,[%s]), aborting!\n",
ret, ldb_errstring(cdb->ldb));
return EIO;
}
Expand All @@ -159,7 +162,6 @@ static int confdb_write_ldif(struct confdb_ctx *cdb,

static int confdb_init_db(const char *config_file,
const char *config_dir,
const char *only_section,
struct confdb_ctx *cdb)
{
TALLOC_CTX *tmp_ctx;
Expand All @@ -185,7 +187,6 @@ static int confdb_init_db(const char *config_file,
ret = confdb_ldif_from_ini_file(tmp_ctx,
config_file,
config_dir,
only_section,
init_data,
&config_ldif);
if (ret != EOK) {
Expand All @@ -208,19 +209,14 @@ static int confdb_init_db(const char *config_file,
}
in_transaction = true;

/* Purge existing database, if we are reinitializing the confdb completely */
if (only_section == NULL) {
ret = confdb_purge(cdb);
if (ret != EOK) {
DEBUG(SSSDBG_FATAL_FAILURE,
"Could not purge existing configuration\n");
goto done;
}
ret = confdb_purge(cdb);
if (ret != EOK) {
DEBUG(SSSDBG_FATAL_FAILURE,
"Could not purge existing configuration\n");
goto done;
}

ret = confdb_write_ldif(cdb,
config_ldif,
only_section == NULL ? true : false);
ret = confdb_write_ldif(cdb, config_ldif);
if (ret != EOK) {
goto done;
}
Expand Down Expand Up @@ -250,7 +246,6 @@ errno_t confdb_setup(TALLOC_CTX *mem_ctx,
const char *cdb_file,
const char *config_file,
const char *config_dir,
const char *only_section,
struct confdb_ctx **_cdb)
{
TALLOC_CTX *tmp_ctx;
Expand Down Expand Up @@ -295,7 +290,7 @@ errno_t confdb_setup(TALLOC_CTX *mem_ctx,
}

/* Initialize the CDB from the configuration file */
ret = confdb_init_db(config_file, config_dir, only_section, cdb);
ret = confdb_init_db(config_file, config_dir, cdb);
if (ret != EOK) {
DEBUG(SSSDBG_FATAL_FAILURE, "ConfDB initialization has failed "
"[%d]: %s\n", ret, sss_strerror(ret));
Expand Down
16 changes: 0 additions & 16 deletions src/confdb/confdb_setup.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,10 @@
#ifndef CONFDB_SETUP_H_
#define CONFDB_SETUP_H_

#define CONFDB_BASE_LDIF \
"dn: @ATTRIBUTES\n" \
"cn: CASE_INSENSITIVE\n" \
"dc: CASE_INSENSITIVE\n" \
"dn: CASE_INSENSITIVE\n" \
"name: CASE_INSENSITIVE\n" \
"objectclass: CASE_INSENSITIVE\n" \
"\n" \
"dn: @INDEXLIST\n" \
"@IDXATTR: cn\n" \
"\n" \
"dn: @MODULES\n" \
"@LIST: server_sort\n" \
"\n"

errno_t confdb_setup(TALLOC_CTX *mem_ctx,
const char *cdb_file,
const char *config_file,
const char *config_dir,
const char *only_section,
struct confdb_ctx **_cdb);

#endif /* CONFDB_SETUP_H_ */
27 changes: 0 additions & 27 deletions src/man/sssd.8.xml
Original file line number Diff line number Diff line change
Expand Up @@ -145,33 +145,6 @@
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>-g</option>,<option>--genconf</option>
</term>
<listitem>
<para>
Do not start the SSSD, but refresh the configuration
database from the contents of
<filename>/etc/sssd/sssd.conf</filename> and exit.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>-s</option>,<option>--genconf-section</option>
</term>
<listitem>
<para>
Similar to <quote>--genconf</quote>, but only refresh
a single section from the configuration file. This
option is useful mainly to be called from systemd
unit files to allow socket-activated responders
to refresh their configuration without requiring
the administrator to restart the whole SSSD.
</para>
</listitem>
</varlistentry>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="include/param_help.xml" />
<varlistentry>
<term>
Expand Down
Loading

0 comments on commit d016385

Please sign in to comment.