diff options
authorJakub Hrozek <>2016-06-29 17:03:51 +0200
committerJakub Hrozek <>2016-07-07 10:29:56 +0200
commitee71456b887c82ff6aa2581cbb6ddb3607bba51e (patch)
parent6d66c2c465861ff2558f2574eddf8315628ccc6d (diff)
SYSDB: Fix small issues during db upgrade
This patch fixes several issues introduced during the recent sysdb upgrade: 1) The upgrade code often accesses sysdb->ldb, but at this point, the ldb pointer might not be initialized yet. As a kind of an ugly, yet functional workaround, we pass in the ldb pointer that we received from the caller as part of the sysdb structure. 2) the version that sysdb_domain_cache_upgrade() returns is not a talloc pointer, so the upgrade was crashing when we tried to steal it. 3) the ldb pointer sysdb_cache_connect() returns was kept allocated on the tmp_ctx. We need to steal it instead. Reviewed-by: Sumit Bose <>
1 files changed, 3 insertions, 1 deletions
diff --git a/src/db/sysdb_init.c b/src/db/sysdb_init.c
index babd8ab..fc7e13a 100644
--- a/src/db/sysdb_init.c
+++ b/src/db/sysdb_init.c
@@ -386,6 +386,7 @@ static errno_t sysdb_domain_cache_upgrade(TALLOC_CTX *mem_ctx,
* ldb pointer here and restore in the 'done' handler
save_ldb = sysdb->ldb;
+ sysdb->ldb = ldb;
version = talloc_strdup(tmp_ctx, cur_version);
if (version == NULL) {
@@ -498,7 +499,7 @@ static errno_t sysdb_domain_cache_upgrade(TALLOC_CTX *mem_ctx,
ret = EOK;
sysdb->ldb = save_ldb;
- *_new_version = talloc_steal(mem_ctx, version);
+ *_new_version = version;
return ret;
@@ -573,6 +574,7 @@ static errno_t sysdb_cache_connect(TALLOC_CTX *mem_ctx,
/* This is not the latest version. Return what version it is
* and appropriate error
+ *_ldb = talloc_steal(mem_ctx, ldb);
*_version = talloc_steal(mem_ctx, version);
goto done;