diff --git a/src/db/sysdb.h b/src/db/sysdb.h index 1c7c8f5e8c7..710a51eee92 100644 --- a/src/db/sysdb.h +++ b/src/db/sysdb.h @@ -804,6 +804,7 @@ struct sysdb_upgrade_ctx { int sysdb_init_ext(TALLOC_CTX *mem_ctx, struct sss_domain_info *domains, + bool dont_create_cache, struct sysdb_upgrade_ctx *upgrade_ctx); /* used to initialize only one domain database. diff --git a/src/db/sysdb_init.c b/src/db/sysdb_init.c index dd983697cda..0cf9646e7e1 100644 --- a/src/db/sysdb_init.c +++ b/src/db/sysdb_init.c @@ -776,10 +776,12 @@ static int sysdb_timestamp_cache_connect(struct sysdb_ctx *sysdb, static int sysdb_domain_init_internal(TALLOC_CTX *mem_ctx, struct sss_domain_info *domain, const char *db_path, + bool dont_create_cache, struct sysdb_dom_upgrade_ctx *upgrade_ctx, struct sysdb_ctx **_ctx) { TALLOC_CTX *tmp_ctx = NULL; + bool ldb_file_missing; struct sysdb_ctx *sysdb; int ret; @@ -799,6 +801,11 @@ static int sysdb_domain_init_internal(TALLOC_CTX *mem_ctx, if (ret != EOK) { goto done; } + ldb_file_missing = (access(sysdb->ldb_file, F_OK) == -1 && errno == ENOENT); + if (ldb_file_missing && dont_create_cache) { + ret = ENOENT; + goto done; + } DEBUG(SSSDBG_FUNC_DATA, "DB File for %s: %s\n", domain->name, sysdb->ldb_file); if (sysdb->ldb_ts_file) { @@ -833,11 +840,12 @@ static int sysdb_domain_init_internal(TALLOC_CTX *mem_ctx, int sysdb_init(TALLOC_CTX *mem_ctx, struct sss_domain_info *domains) { - return sysdb_init_ext(mem_ctx, domains, NULL); + return sysdb_init_ext(mem_ctx, domains, true, NULL); } int sysdb_init_ext(TALLOC_CTX *mem_ctx, struct sss_domain_info *domains, + bool dont_create_cache, struct sysdb_upgrade_ctx *upgrade_ctx) { struct sss_domain_info *dom; @@ -868,7 +876,7 @@ int sysdb_init_ext(TALLOC_CTX *mem_ctx, dom_upgrade_ctx = NULL; } - ret = sysdb_domain_init_internal(tmp_ctx, dom, DB_PATH, + ret = sysdb_domain_init_internal(tmp_ctx, dom, DB_PATH, dont_create_cache, dom_upgrade_ctx, &sysdb); if (ret != EOK) { DEBUG(SSSDBG_CRIT_FAILURE, @@ -892,5 +900,5 @@ int sysdb_domain_init(TALLOC_CTX *mem_ctx, struct sysdb_ctx **_ctx) { return sysdb_domain_init_internal(mem_ctx, domain, - db_path, NULL, _ctx); + db_path, true, NULL, _ctx); } diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c index eebef40040e..6a921251e40 100644 --- a/src/monitor/monitor.c +++ b/src/monitor/monitor.c @@ -1556,7 +1556,7 @@ static int monitor_process_init(struct mt_ctx *ctx) } db_up_ctx.cdb = ctx->cdb; - ret = sysdb_init_ext(tmp_ctx, ctx->domains, &db_up_ctx); + ret = sysdb_init_ext(tmp_ctx, ctx->domains, false, &db_up_ctx); if (ret != EOK) { DEBUG(SSSDBG_TRACE_FUNC, "sysdb_init_ext() failed: '%s'\n", sss_strerror(ret));