Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only create sysdb cache files from 'monitor' (and tests) #7558

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/db/sysdb.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@

#define CACHE_SYSDB_FILE "cache_%s.ldb"
#define CACHE_TIMESTAMPS_FILE "timestamps_%s.ldb"
#define LOCAL_SYSDB_FILE "sssd.ldb"

#define SYSDB_INDEXES "@INDEXLIST"
#define SYSDB_IDXATTR "@IDXATTR"
Expand Down Expand Up @@ -804,6 +803,7 @@ struct sysdb_upgrade_ctx {

int sysdb_init_ext(TALLOC_CTX *mem_ctx,
struct sss_domain_info *domains,
bool create_missing_cache,
struct sysdb_upgrade_ctx *upgrade_ctx);

/* used to initialize only one domain database.
Expand Down
133 changes: 31 additions & 102 deletions src/db/sysdb_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,26 @@ static errno_t sysdb_domain_cache_upgrade(TALLOC_CTX *mem_ctx,
const char *version;
struct ldb_context *save_ldb;

if ((strcmp(cur_version, SYSDB_VERSION_0_1) == 0) ||
(strcmp(cur_version, SYSDB_VERSION_0_2) == 0) ||
(strcmp(cur_version, SYSDB_VERSION_0_3) == 0) ||
(strcmp(cur_version, SYSDB_VERSION_0_4) == 0) ||
(strcmp(cur_version, SYSDB_VERSION_0_5) == 0) ||
(strcmp(cur_version, SYSDB_VERSION_0_6) == 0) ||
(strcmp(cur_version, SYSDB_VERSION_0_7) == 0) ||
(strcmp(cur_version, SYSDB_VERSION_0_8) == 0) ||
(strcmp(cur_version, SYSDB_VERSION_0_9) == 0) ||
(strcmp(cur_version, SYSDB_VERSION_0_10) == 0) ||
(strcmp(cur_version, SYSDB_VERSION_0_11) == 0) ||
(strcmp(cur_version, SYSDB_VERSION_0_12) == 0) ||
(strcmp(cur_version, SYSDB_VERSION_0_13) == 0) ||
(strcmp(cur_version, SYSDB_VERSION_0_14) == 0) ||
(strcmp(cur_version, SYSDB_VERSION_0_15) == 0)) {
DEBUG(SSSDBG_FATAL_FAILURE,
"Cache version is way too old and must be deleted manually\n");
return EIO;
}

tmp_ctx = talloc_new(NULL);
if (tmp_ctx == NULL) {
return ENOMEM;
Expand All @@ -384,97 +404,6 @@ static errno_t sysdb_domain_cache_upgrade(TALLOC_CTX *mem_ctx,
"Upgrading DB [%s] from version: %s\n",
domain->name, version);

if (strcmp(version, SYSDB_VERSION_0_3) == 0) {
ret = sysdb_upgrade_03(sysdb, &version);
if (ret != EOK) {
goto done;
}
}

if (strcmp(version, SYSDB_VERSION_0_4) == 0) {
ret = sysdb_upgrade_04(sysdb, &version);
if (ret != EOK) {
goto done;
}
}

if (strcmp(version, SYSDB_VERSION_0_5) == 0) {
ret = sysdb_upgrade_05(sysdb, &version);
if (ret != EOK) {
goto done;
}
}

if (strcmp(version, SYSDB_VERSION_0_6) == 0) {
ret = sysdb_upgrade_06(sysdb, &version);
if (ret != EOK) {
goto done;
}
}

if (strcmp(version, SYSDB_VERSION_0_7) == 0) {
ret = sysdb_upgrade_07(sysdb, &version);
if (ret != EOK) {
goto done;
}
}

if (strcmp(version, SYSDB_VERSION_0_8) == 0) {
ret = sysdb_upgrade_08(sysdb, &version);
if (ret != EOK) {
goto done;
}
}

if (strcmp(version, SYSDB_VERSION_0_9) == 0) {
ret = sysdb_upgrade_09(sysdb, &version);
if (ret != EOK) {
goto done;
}
}

if (strcmp(version, SYSDB_VERSION_0_10) == 0) {
ret = sysdb_upgrade_10(sysdb, domain, &version);
if (ret != EOK) {
goto done;
}
}

if (strcmp(version, SYSDB_VERSION_0_11) == 0) {
ret = sysdb_upgrade_11(sysdb, domain, &version);
if (ret != EOK) {
goto done;
}
}

if (strcmp(version, SYSDB_VERSION_0_12) == 0) {
ret = sysdb_upgrade_12(sysdb, &version);
if (ret != EOK) {
goto done;
}
}

if (strcmp(version, SYSDB_VERSION_0_13) == 0) {
ret = sysdb_upgrade_13(sysdb, &version);
if (ret != EOK) {
goto done;
}
}

if (strcmp(version, SYSDB_VERSION_0_14) == 0) {
ret = sysdb_upgrade_14(sysdb, &version);
if (ret != EOK) {
goto done;
}
}

if (strcmp(version, SYSDB_VERSION_0_15) == 0) {
ret = sysdb_upgrade_15(sysdb, &version);
if (ret != EOK) {
goto done;
}
}

if (strcmp(version, SYSDB_VERSION_0_16) == 0) {
ret = sysdb_upgrade_16(sysdb, &version);
if (ret != EOK) {
Expand Down Expand Up @@ -847,10 +776,12 @@ static int sysdb_timestamp_cache_connect(struct sysdb_ctx *sysdb,
int sysdb_domain_init_internal(TALLOC_CTX *mem_ctx,
struct sss_domain_info *domain,
const char *db_path,
bool create_missing_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;

Expand All @@ -870,6 +801,11 @@ 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 && !create_missing_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) {
Expand Down Expand Up @@ -904,11 +840,12 @@ 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, false, NULL);
}

int sysdb_init_ext(TALLOC_CTX *mem_ctx,
struct sss_domain_info *domains,
bool create_missing_cache,
struct sysdb_upgrade_ctx *upgrade_ctx)
{
struct sss_domain_info *dom;
Expand All @@ -917,14 +854,6 @@ int sysdb_init_ext(TALLOC_CTX *mem_ctx,
TALLOC_CTX *tmp_ctx;
struct sysdb_dom_upgrade_ctx *dom_upgrade_ctx;

if (upgrade_ctx != NULL) {
/* check if we have an old sssd.ldb to upgrade */
ret = sysdb_check_upgrade_02(domains, DB_PATH);
if (ret != EOK) {
return ret;
}
}

tmp_ctx = talloc_new(mem_ctx);
if (tmp_ctx == NULL) {
return ENOMEM;
Expand All @@ -947,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, create_missing_cache,
dom_upgrade_ctx, &sysdb);
if (ret != EOK) {
DEBUG(SSSDBG_CRIT_FAILURE,
Expand All @@ -971,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, false, NULL, _ctx);
}
19 changes: 1 addition & 18 deletions src/db/sysdb_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,28 +164,11 @@ struct sysdb_dom_upgrade_ctx {
int sysdb_domain_init_internal(TALLOC_CTX *mem_ctx,
struct sss_domain_info *domain,
const char *db_path,
bool create_missing_cache,
struct sysdb_dom_upgrade_ctx *upgrade_ctx,
struct sysdb_ctx **_ctx);

/* Upgrade routines */
int sysdb_upgrade_01(struct ldb_context *ldb, const char **ver);
int sysdb_check_upgrade_02(struct sss_domain_info *domains,
const char *db_path);
int sysdb_upgrade_03(struct sysdb_ctx *sysdb, const char **ver);
int sysdb_upgrade_04(struct sysdb_ctx *sysdb, const char **ver);
int sysdb_upgrade_05(struct sysdb_ctx *sysdb, const char **ver);
int sysdb_upgrade_06(struct sysdb_ctx *sysdb, const char **ver);
int sysdb_upgrade_07(struct sysdb_ctx *sysdb, const char **ver);
int sysdb_upgrade_08(struct sysdb_ctx *sysdb, const char **ver);
int sysdb_upgrade_09(struct sysdb_ctx *sysdb, const char **ver);
int sysdb_upgrade_10(struct sysdb_ctx *sysdb, struct sss_domain_info *domain,
const char **ver);
int sysdb_upgrade_11(struct sysdb_ctx *sysdb, struct sss_domain_info *domain,
const char **ver);
int sysdb_upgrade_12(struct sysdb_ctx *sysdb, const char **ver);
int sysdb_upgrade_13(struct sysdb_ctx *sysdb, const char **ver);
int sysdb_upgrade_14(struct sysdb_ctx *sysdb, const char **ver);
int sysdb_upgrade_15(struct sysdb_ctx *sysdb, const char **ver);
int sysdb_upgrade_16(struct sysdb_ctx *sysdb, const char **ver);
int sysdb_upgrade_17(struct sysdb_ctx *sysdb,
struct sysdb_dom_upgrade_ctx *upgrade_ctx,
Expand Down
Loading
Loading