From 66eefde53b68b0665557095158411c89d44a1934 Mon Sep 17 00:00:00 2001 From: Björn Baumbach Date: Wed, 2 Nov 2011 13:40:36 +0100 Subject: s3-registry: fix upgrade code Assume REGDB_VERSION_V1 if no version key found in registry.tdb Signed-off-by: Michael Adam --- source3/registry/reg_backend_db.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'source3/registry') diff --git a/source3/registry/reg_backend_db.c b/source3/registry/reg_backend_db.c index fad6c08b5e..7fa6249cec 100644 --- a/source3/registry/reg_backend_db.c +++ b/source3/registry/reg_backend_db.c @@ -667,10 +667,24 @@ WERROR regdb_init(void) if (!NT_STATUS_IS_OK(status)) { DEBUG(10, ("regdb_init: registry version uninitialized " "(got %d), initializing to version %d\n", - vers_id, REGDB_CODE_VERSION)); - - werr = regdb_store_regdb_version(regdb, REGDB_CODE_VERSION); - return werr; + vers_id, REGDB_VERSION_V1)); + + /* + * There was a regdb format version prior to version 1 + * which did not store a INFO/version key. The format + * of this version was identical to version 1 except for + * the lack of the sorted subkey cache records. + * Since these are disposable, we can safely assume version + * 1 if no INFO/version key is found and run the db through + * the whole chain of upgrade. If the database was not + * initialized, this does not harm. If it was the unversioned + * version ("0"), then it do the right thing with the records. + */ + werr = regdb_store_regdb_version(regdb, REGDB_VERSION_V1); + if (!W_ERROR_IS_OK(werr)) { + return werr; + } + vers_id = REGDB_VERSION_V1; } if (vers_id > REGDB_CODE_VERSION || vers_id == 0) { -- cgit