From 3af32f011436727b4c4615b20c0b0913ab7e9e12 Mon Sep 17 00:00:00 2001 From: Stephen Gallagher Date: Wed, 13 Apr 2011 15:48:24 -0400 Subject: Reopen the LDB after modifying it If we change any of the special entries such as indexes or plugins, we need to close and reopen the LDB to ensure that they take effect. --- src/db/sysdb.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'src/db/sysdb.c') diff --git a/src/db/sysdb.c b/src/db/sysdb.c index 4b2b3035..07a6cc13 100644 --- a/src/db/sysdb.c +++ b/src/db/sysdb.c @@ -1688,8 +1688,15 @@ static int sysdb_domain_init_internal(TALLOC_CTX *mem_ctx, * SSSD. */ if (strcmp(version, SYSDB_VERSION) == 0) { - /* all fine, return */ - ret = EOK; + /* The cache has been upgraded. + * We need to reopen the LDB to ensure that + * any changes made above take effect. + */ + talloc_zfree(ctx->ldb); + ret = sysdb_ldb_connect(ctx, ctx->ldb_file, &ctx->ldb); + if (ret != EOK) { + DEBUG(1, ("sysdb_ldb_connect failed.\n")); + } goto done; } } @@ -1797,7 +1804,17 @@ static int sysdb_domain_init_internal(TALLOC_CTX *mem_ctx, } talloc_zfree(msg); - ret = EOK; + /* The cache has been newly created. + * We need to reopen the LDB to ensure that + * all of the special values take effect + * (such as enabling the memberOf plugin and + * the various indexes). + */ + talloc_zfree(ctx->ldb); + ret = sysdb_ldb_connect(ctx, ctx->ldb_file, &ctx->ldb); + if (ret != EOK) { + DEBUG(1, ("sysdb_ldb_connect failed.\n")); + } done: if (ret == EOK) { -- cgit