From ee71456b887c82ff6aa2581cbb6ddb3607bba51e Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Wed, 29 Jun 2016 17:03:51 +0200 Subject: 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 --- src/db/sysdb_init.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/db/sysdb_init.c b/src/db/sysdb_init.c index babd8ab92..fc7e13ac1 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; done: sysdb->ldb = save_ldb; - *_new_version = talloc_steal(mem_ctx, version); + *_new_version = version; talloc_free(tmp_ctx); 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; } -- cgit