diff --git a/src/confdb/confdb_setup.c b/src/confdb/confdb_setup.c index 3cf345e86a8..5b459262ea2 100644 --- a/src/confdb/confdb_setup.c +++ b/src/confdb/confdb_setup.c @@ -160,7 +160,8 @@ 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) + struct confdb_ctx *cdb, + bool allow_missing_file) { TALLOC_CTX *tmp_ctx; int ret; @@ -189,10 +190,16 @@ static int confdb_init_db(const char *config_file, init_data, &config_ldif); if (ret != EOK) { - DEBUG(SSSDBG_CRIT_FAILURE, - "Cannot convert INI to LDIF [%d]: [%s]\n", - ret, sss_strerror(ret)); - goto done; + if (ret == ERR_INI_EMPTY_CONFIG && allow_missing_file) { + DEBUG(SSSDBG_TRACE_FUNC, "Empty configuration. Using the defaults.\n"); + ret = EOK; + goto done; + } else { + DEBUG(SSSDBG_CRIT_FAILURE, + "Cannot convert INI to LDIF [%d]: [%s]\n", + ret, sss_strerror(ret)); + goto done; + } } DEBUG(SSSDBG_CONF_SETTINGS, "LDIF file to import: \n%s\n", config_ldif); @@ -251,6 +258,7 @@ errno_t confdb_setup(TALLOC_CTX *mem_ctx, const char *config_file, const char *config_dir, const char *only_section, + bool allow_missing_file, struct confdb_ctx **_cdb) { TALLOC_CTX *tmp_ctx; @@ -295,7 +303,8 @@ 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, only_section, cdb, + allow_missing_file); if (ret != EOK) { DEBUG(SSSDBG_FATAL_FAILURE, "ConfDB initialization has failed " "[%d]: %s\n", ret, sss_strerror(ret)); diff --git a/src/confdb/confdb_setup.h b/src/confdb/confdb_setup.h index d12441165c4..84b29b01fe9 100644 --- a/src/confdb/confdb_setup.h +++ b/src/confdb/confdb_setup.h @@ -22,6 +22,8 @@ #ifndef CONFDB_SETUP_H_ #define CONFDB_SETUP_H_ +#include + #define CONFDB_BASE_LDIF \ "dn: @ATTRIBUTES\n" \ "cn: CASE_INSENSITIVE\n" \ @@ -42,6 +44,7 @@ errno_t confdb_setup(TALLOC_CTX *mem_ctx, const char *config_file, const char *config_dir, const char *only_section, + bool allow_missing_file, struct confdb_ctx **_cdb); #endif /* CONFDB_SETUP_H_ */ diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c index 68d36b91c2c..14978396105 100644 --- a/src/monitor/monitor.c +++ b/src/monitor/monitor.c @@ -1502,7 +1502,7 @@ errno_t load_configuration(TALLOC_CTX *mem_ctx, } ret = confdb_setup(ctx, cdb_file, config_file, config_dir, only_section, - &ctx->cdb); + false, &ctx->cdb); if (ret != EOK) { DEBUG(SSSDBG_FATAL_FAILURE, "Unable to setup ConfDB [%d]: %s\n", ret, sss_strerror(ret)); diff --git a/src/tools/common/sss_tools.c b/src/tools/common/sss_tools.c index e67de3a66ab..fd8075421fc 100644 --- a/src/tools/common/sss_tools.c +++ b/src/tools/common/sss_tools.c @@ -102,8 +102,7 @@ static errno_t sss_tool_confdb_init(TALLOC_CTX *mem_ctx, ret = confdb_setup(mem_ctx, path, SSSD_CONFIG_FILE, CONFDB_DEFAULT_CONFIG_DIR, - NULL, - &confdb); + NULL, false, &confdb); talloc_zfree(path); if (ret != EOK) { DEBUG(SSSDBG_FATAL_FAILURE, "Unable to setup ConfDB [%d]: %s\n",