The branch, master has been updated via 399c0db s3:registry: remove unused function regdb_key_is_base_key() via 86f8eb9 s3:registry: replace use of deprecated talloc_destroy by talloc_free. via 17b091b s3:registry: remove superfluous check for success of talloc_stackframe() via cc384c1 s3:registry: add debug-level-10 verbosity to regdb_upgrade_v2_v3_fn() via 340be35 s3:registry: adapt a debug message to be more systematic via c8c5d8c s3:registry: set registry version to 3 and add upgrade code via f36ee63 s3:registry: add db_context argument to regdb_upgrade_v1_to_v2() via 1621aab s3:registry: wrap the whole db upgrade in one transaction via caf9c99 s3:registry: change regdb_store_regdb_version() to take db_context argument. via 2273650 s3:registry: fix a comment typo via a836071 s3:registry: remove unused regdb_delete_sorted_subkeys() via a0f83ec s3:registry: don't delete the unused subkeys cache record any more via 50add40 s3:registry: remove the code to create and search the sorted subkeys cache records via 18973fa s3:registry: adapt the comment explaining the definition of the existence of a key. via a255630 s3:registry: regdb_key_exists now checks only for the list-of-subkeys-record via 9e2b2c1 s3:registry: rewrite init_registry_key_internal via 747c67c s3:registry: add regdb_create_basekey() via 144c8d7 s3:registry: add regdb_create_subkey_internal() taking additional db context argument via 15a50ef s3:registry: add new mode to regdb_store_subkey_list() for handing in NULL parent key via fc4d79d s3:registry: create the empty list of subkeys of the new key in regdb_create_subkey via 322eaf1 s3:registry: refactor creation of subkey list out into regdb_store_subkey_list() via 394ca14 s3:registry: remove redundant write of zero-lentgh subkey list record via eb797bd s3:registry: don't update the sorted subkeys cache any more in regdb_store_keys_internal2() via 5b01a34 s3:registry: don't skip base key in existence check in regdb_store_keys_internal() via da2e64b s3:registry: don't skip base keys from existence check in regdb_create_subkey() via 6b99aa4 s3:registry: don't skip base keys from existence check in regdb_delete_subkey() via a60c94d selftest: remove invalid use of the globbing operator <> via b6f2565 selftest: eliminate perl warnings (my $cmd masks earlier definition...) via 65f4d33 selftest: eliminate a perl warning from ad4a10d s3:smb2 fix smbd crash on premature end of smb2 conn (Bug 8286)
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit 399c0dba01b4337f5483bf03c99d28a3486e7981 Author: Michael Adam <ob...@samba.org> Date: Mon Jul 4 17:45:30 2011 +0200 s3:registry: remove unused function regdb_key_is_base_key() Autobuild-User: Michael Adam <ob...@samba.org> Autobuild-Date: Mon Jul 4 21:11:32 CEST 2011 on sn-devel-104 commit 86f8eb98fe76b4b65f903e1792cdb2eb9b195ee5 Author: Michael Adam <ob...@samba.org> Date: Mon Jul 4 17:22:01 2011 +0200 s3:registry: replace use of deprecated talloc_destroy by talloc_free. commit 17b091b7c7f57a041c5e90c653f1ee46572d4668 Author: Michael Adam <ob...@samba.org> Date: Mon Jul 4 17:21:23 2011 +0200 s3:registry: remove superfluous check for success of talloc_stackframe() commit cc384c15969cdc395bfd3fcee10b5c04233df290 Author: Michael Adam <ob...@samba.org> Date: Mon Jul 4 17:20:28 2011 +0200 s3:registry: add debug-level-10 verbosity to regdb_upgrade_v2_v3_fn() commit 340be35b9b068360b5fec5a0ea43dc8a3b294ba4 Author: Michael Adam <ob...@samba.org> Date: Mon Jul 4 17:13:58 2011 +0200 s3:registry: adapt a debug message to be more systematic commit c8c5d8c89e3cf9b71a917de83ad68d4d3c18b117 Author: Michael Adam <ob...@samba.org> Date: Mon Jul 4 16:23:08 2011 +0200 s3:registry: set registry version to 3 and add upgrade code Pair-Programmed-With: Gregor Beck <gb...@sernet.de> commit f36ee63df28a2c49e8661a28237b97fe60f872c4 Author: Michael Adam <ob...@samba.org> Date: Mon Jul 4 16:21:26 2011 +0200 s3:registry: add db_context argument to regdb_upgrade_v1_to_v2() commit 1621aab139f0104cb2c7183c28c52cb6605abb09 Author: Michael Adam <ob...@samba.org> Date: Mon Jul 4 16:15:11 2011 +0200 s3:registry: wrap the whole db upgrade in one transaction The purpose of this is to prepare for multiple upgrade steps to be performed in a single transaction, so that no change at all is made to that database if one step fails. Pair-Programmed-With: Gregor Beck <gb...@sernet.de> commit caf9c9996952e72e61f9c9f0efd27936f38eefda Author: Michael Adam <ob...@samba.org> Date: Mon Jul 4 16:09:33 2011 +0200 s3:registry: change regdb_store_regdb_version() to take db_context argument. commit 2273650ca89c4042d073257383d0e5d28a8a555f Author: Michael Adam <ob...@samba.org> Date: Mon Jul 4 15:23:39 2011 +0200 s3:registry: fix a comment typo commit a8360712e1356a347f49a5208c1388dc5ab96d31 Author: Michael Adam <ob...@samba.org> Date: Fri Jul 1 13:49:12 2011 +0200 s3:registry: remove unused regdb_delete_sorted_subkeys() Pair-Programmed-With: Gregor Beck <gb...@sernet.de> commit a0f83ecbb9697d4aa9c47b7b61001996a934ecee Author: Michael Adam <ob...@samba.org> Date: Fri Jul 1 13:48:16 2011 +0200 s3:registry: don't delete the unused subkeys cache record any more Pair-Programmed-With: Gregor Beck <gb...@sernet.de> commit 50add4091aff69e70263fbb46d30bad8f420759c Author: Michael Adam <ob...@samba.org> Date: Fri Jul 1 13:37:41 2011 +0200 s3:registry: remove the code to create and search the sorted subkeys cache records This is not needed any more. Pair-Programmed-With: Gregor Beck <gb...@sernet.de> commit 18973fa109132bab8cb22a6757dbe4a206ea1a33 Author: Michael Adam <ob...@samba.org> Date: Fri Jul 1 13:33:44 2011 +0200 s3:registry: adapt the comment explaining the definition of the existence of a key. Pair-Programmed-With: Gregor Beck <gb...@sernet.de> commit a25563035823e720a068c3021e01b0556feb7f18 Author: Michael Adam <ob...@samba.org> Date: Fri Jul 1 13:18:51 2011 +0200 s3:registry: regdb_key_exists now checks only for the list-of-subkeys-record Pair-Programmed-With: Gregor Beck <gb...@sernet.de> commit 9e2b2c1fcc6d0bd852df715fdae7854b3ae77027 Author: Michael Adam <ob...@samba.org> Date: Mon Jul 4 13:19:13 2011 +0200 s3:registry: rewrite init_registry_key_internal This rewrites init_registry_key_internal() to correctly also create base keys. It makes use of the existing create functions instead of duplicating the code. Pair-Programmed-With: Gregor Beck <gb...@sernet.de> commit 747c67cf309a5127e78bd78f0d17e3fc094115d2 Author: Michael Adam <ob...@samba.org> Date: Mon Jul 4 13:14:43 2011 +0200 s3:registry: add regdb_create_basekey() Function to create a base key in the registry db, i.e. one that has no parent key. Pair-Programmed-With: Gregor Beck <gb...@sernet.de> commit 144c8d77d8dcde0b85cef28b6515360aa0c55b85 Author: Michael Adam <ob...@samba.org> Date: Mon Jul 4 13:09:31 2011 +0200 s3:registry: add regdb_create_subkey_internal() taking additional db context argument Pair-Programmed-With: Gregor Beck <gb...@sernet.de> commit 15a50ef8f856d83508ece3a8294dfaffbadc3b41 Author: Michael Adam <ob...@samba.org> Date: Mon Jul 4 13:06:20 2011 +0200 s3:registry: add new mode to regdb_store_subkey_list() for handing in NULL parent key Standard behaviour is to concatenate parent and key path (parent\key). This new mode allows for storing subkey lists for base keys using a NULL parent argument. Pair-Programmed-With: Gregor Beck <gb...@sernet.de> commit fc4d79d41a18ed3c2a2f8a831e5dcc3002423ab1 Author: Michael Adam <ob...@samba.org> Date: Fri Jul 1 15:50:05 2011 +0200 s3:registry: create the empty list of subkeys of the new key in regdb_create_subkey Pair-Programmed-With: Gregor Beck <gb...@sernet.de> commit 322eaf1e9ef927bdec7fca947e894470196c1049 Author: Michael Adam <ob...@samba.org> Date: Fri Jul 1 15:47:50 2011 +0200 s3:registry: refactor creation of subkey list out into regdb_store_subkey_list() Pair-Programmed-With: Gregor Beck <gb...@sernet.de> commit 394ca1446e712c9cb3649c8a2c4fd2ebe638d8cd Author: Michael Adam <ob...@samba.org> Date: Fri Jul 1 15:18:12 2011 +0200 s3:registry: remove redundant write of zero-lentgh subkey list record In this case, the zero-lenght list has already been written in step #2. Pair-Programmed-With: Gregor Beck <gb...@sernet.de> commit eb797bd2060732bca06cda3dfd5eabec5e7c8ab0 Author: Michael Adam <ob...@samba.org> Date: Fri Jul 1 14:34:08 2011 +0200 s3:registry: don't update the sorted subkeys cache any more in regdb_store_keys_internal2() Pair-Programmed-With: Gregor Beck <gb...@sernet.de> commit 5b01a34ad734a772e52c50ccd8ffbb461f986af7 Author: Michael Adam <ob...@samba.org> Date: Fri Jul 1 14:23:19 2011 +0200 s3:registry: don't skip base key in existence check in regdb_store_keys_internal() Pair-Programmed-With: Gregor Beck <gb...@sernet.de> commit da2e64b63f6bbb2faa93f621e14992e38aa37354 Author: Michael Adam <ob...@samba.org> Date: Fri Jul 1 13:58:45 2011 +0200 s3:registry: don't skip base keys from existence check in regdb_create_subkey() Pair-Programmed-With: Gregor Beck <gb...@sernet.de> commit 6b99aa496fe653f6bb7dcd7720f5a2c736779af6 Author: Michael Adam <ob...@samba.org> Date: Fri Jul 1 13:57:19 2011 +0200 s3:registry: don't skip base keys from existence check in regdb_delete_subkey() Pair-Programmed-With: Gregor Beck <gb...@sernet.de> commit a60c94d55980c62ca281507c8d1960b5ab233dba Author: Michael Adam <ob...@samba.org> Date: Mon Jul 4 17:01:29 2011 +0200 selftest: remove invalid use of the globbing operator <> commit b6f25650f1adcc75f0a97e31c31c9980326b7ab6 Author: Michael Adam <ob...@samba.org> Date: Mon Jul 4 10:28:43 2011 +0200 selftest: eliminate perl warnings (my $cmd masks earlier definition...) commit 65f4d33d9b5ee80ef768c0479a6782807b18e518 Author: Michael Adam <ob...@samba.org> Date: Mon Jul 4 10:24:19 2011 +0200 selftest: eliminate a perl warning In perl, %binary_mapping should be initialized as a hash, not a hash reference. ----------------------------------------------------------------------- Summary of changes: selftest/selftest.pl | 6 +- selftest/target/Samba4.pm | 4 +- source3/registry/reg_backend_db.c | 795 ++++++++++++++----------------------- source3/registry/reg_db.h | 2 + 4 files changed, 305 insertions(+), 502 deletions(-) Changeset truncated at 500 lines: diff --git a/selftest/selftest.pl b/selftest/selftest.pl index af45c71..d72c409 100755 --- a/selftest/selftest.pl +++ b/selftest/selftest.pl @@ -463,7 +463,7 @@ if ($opt_socket_wrapper) { my $target; my $testenv_default = "none"; -my %binary_mapping = {}; +my %binary_mapping = (); if ($opt_binary_mapping) { my @binmapping_list = split(/,/, $opt_binary_mapping); foreach my $mapping (@binmapping_list) { @@ -603,11 +603,11 @@ sub write_clientconf($$$) umask 0022; if ( -d "$clientdir/ncalrpcdir/np" ) { unlink <$clientdir/ncalrpcdir/np/*>; - rmdir <$clientdir/ncalrpcdir/np>; + rmdir "$clientdir/ncalrpcdir/np"; } if ( -d "$clientdir/ncalrpcdir" ) { unlink <$clientdir/ncalrpcdir/*>; - rmdir <$clientdir/ncalrpcdir>; + rmdir "$clientdir/ncalrpcdir"; } mkdir("$clientdir/ncalrpcdir", 0755); umask $mask; diff --git a/selftest/target/Samba4.pm b/selftest/target/Samba4.pm index 70e3cf7..f238e14 100644 --- a/selftest/target/Samba4.pm +++ b/selftest/target/Samba4.pm @@ -929,7 +929,7 @@ sub provision_rpc_proxy($$$) } # Setting up delegation runs in the context of the DC for now - my $cmd = ""; + $cmd = ""; $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$dcvars->{SOCKET_WRAPPER_DEFAULT_IFACE}\" "; $cmd .= "KRB5_CONFIG=\"$dcvars->{KRB5_CONFIG}\" "; $cmd .= "$samba_tool delegation for-any-protocol '$ret->{NETBIOSNAME}\$' on"; @@ -941,7 +941,7 @@ sub provision_rpc_proxy($$$) } # Setting up delegation runs in the context of the DC for now - my $cmd = ""; + $cmd = ""; $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$dcvars->{SOCKET_WRAPPER_DEFAULT_IFACE}\" "; $cmd .= "KRB5_CONFIG=\"$dcvars->{KRB5_CONFIG}\" "; $cmd .= "$samba_tool delegation add-service '$ret->{NETBIOSNAME}\$' cifs/$dcvars->{SERVER}"; diff --git a/source3/registry/reg_backend_db.c b/source3/registry/reg_backend_db.c index 2fda238..88ac393 100644 --- a/source3/registry/reg_backend_db.c +++ b/source3/registry/reg_backend_db.c @@ -39,7 +39,6 @@ static struct db_context *regdb = NULL; static int regdb_refcount; static bool regdb_key_exists(struct db_context *db, const char *key); -static bool regdb_key_is_base_key(const char *key); static WERROR regdb_fetch_keys_internal(struct db_context *db, const char *key, struct regsubkey_ctr *ctr); static bool regdb_store_keys_internal(struct db_context *db, const char *key, @@ -48,8 +47,13 @@ static int regdb_fetch_values_internal(struct db_context *db, const char* key, struct regval_ctr *values); static bool regdb_store_values_internal(struct db_context *db, const char *key, struct regval_ctr *values); +static WERROR regdb_store_subkey_list(struct db_context *db, const char *parent, + const char *key); -static NTSTATUS create_sorted_subkeys(const char *key); +static WERROR regdb_create_basekey(struct db_context *db, const char *key); +static WERROR regdb_create_subkey_internal(struct db_context *db, + const char *key, + const char *subkey); /* List the deepest path into the registry. All part components will be created.*/ @@ -114,113 +118,72 @@ static struct builtin_regkey_value builtin_registry_values[] = { { NULL, NULL, 0, { NULL } } }; -/** - * Initialize a key in the registry: - * create each component key of the specified path. - */ -static WERROR init_registry_key_internal(struct db_context *db, - const char *add_path) +static WERROR create_key_recursive(struct db_context *db, + char *path, + const char *subkey) { WERROR werr; - TALLOC_CTX *frame = talloc_stackframe(); - char *path = NULL; - char *base = NULL; - char *remaining = NULL; - char *keyname; - char *subkeyname; - struct regsubkey_ctr *subkeys; - const char *p, *p2; - - DEBUG(6, ("init_registry_key: Adding [%s]\n", add_path)); + char *p; - path = talloc_strdup(frame, add_path); - base = talloc_strdup(frame, ""); - if (!path || !base) { - werr = WERR_NOMEM; - goto fail; + if (subkey == NULL) { + return WERR_INVALID_PARAM; } - p = path; - - while (next_token_talloc(frame, &p, &keyname, "\\")) { - /* build up the registry path from the components */ + if (path == NULL) { + return regdb_create_basekey(db, subkey); + } - if (*base) { - base = talloc_asprintf(frame, "%s\\", base); - if (!base) { - werr = WERR_NOMEM; - goto fail; - } - } - base = talloc_asprintf_append(base, "%s", keyname); - if (!base) { - werr = WERR_NOMEM; - goto fail; - } + p = strrchr_m(path, '\\'); - /* get the immediate subkeyname (if we have one ) */ + if (p == NULL) { + werr = create_key_recursive(db, NULL, path); + } else { + *p = '\0'; + werr = create_key_recursive(db, path, p+1); + *p = '\\'; + } - subkeyname = talloc_strdup(frame, ""); - if (!subkeyname) { - werr = WERR_NOMEM; - goto fail; - } - if (*p) { - remaining = talloc_strdup(frame, p); - if (!remaining) { - werr = WERR_NOMEM; - goto fail; - } - p2 = remaining; + if (!W_ERROR_IS_OK(werr)) { + goto done; + } - if (!next_token_talloc(frame, &p2, - &subkeyname, "\\")) - { - subkeyname = talloc_strdup(frame,p2); - if (!subkeyname) { - werr = WERR_NOMEM; - goto fail; - } - } - } + werr = regdb_create_subkey_internal(db, path, subkey); - DEBUG(10,("init_registry_key: Storing key [%s] with " - "subkey [%s]\n", base, - *subkeyname ? subkeyname : "NULL")); +done: + return werr; +} - /* we don't really care if the lookup succeeds or not - * since we are about to update the record. - * We just want any subkeys already present */ +/** + * Initialize a key in the registry: + * create each component key of the specified path. + */ +static WERROR init_registry_key_internal(struct db_context *db, + const char *add_path) +{ + char *subkey, *key; + WERROR werr; + TALLOC_CTX *frame = talloc_stackframe(); - werr = regsubkey_ctr_init(frame, &subkeys); - if (!W_ERROR_IS_OK(werr)) { - DEBUG(0,("talloc() failure!\n")); - goto fail; - } + if (add_path == NULL) { + werr = WERR_INVALID_PARAM; + goto done; + } - werr = regdb_fetch_keys_internal(db, base, subkeys); - if (!W_ERROR_IS_OK(werr) && - !W_ERROR_EQUAL(werr, WERR_NOT_FOUND)) - { - goto fail; - } + key = talloc_strdup(frame, add_path); - if (*subkeyname) { - werr = regsubkey_ctr_addkey(subkeys, subkeyname); - if (!W_ERROR_IS_OK(werr)) { - goto fail; - } - } - if (!regdb_store_keys_internal(db, base, subkeys)) { - werr = WERR_CAN_NOT_COMPLETE; - goto fail; - } + subkey = strrchr_m(key, '\\'); + if (subkey == NULL) { + subkey = key; + key = NULL; + } else { + *subkey = '\0'; + subkey++; } - werr = WERR_OK; + werr = create_key_recursive(db, key, subkey); -fail: - TALLOC_FREE(frame); +done: + talloc_free(frame); return werr; } @@ -446,16 +409,16 @@ static int regdb_normalize_keynames_fn(struct db_record *rec, return 0; } -static WERROR regdb_store_regdb_version(uint32_t version) +static WERROR regdb_store_regdb_version(struct db_context *db, uint32_t version) { NTSTATUS status; const char *version_keyname = "INFO/version"; - if (!regdb) { + if (db == NULL) { return WERR_CAN_NOT_COMPLETE; } - status = dbwrap_trans_store_int32(regdb, version_keyname, version); + status = dbwrap_trans_store_int32(db, version_keyname, version); if (!NT_STATUS_IS_OK(status)) { DEBUG(1, ("regdb_store_regdb_version: error storing %s = %d: %s\n", version_keyname, version, nt_errstr(status))); @@ -467,26 +430,119 @@ static WERROR regdb_store_regdb_version(uint32_t version) } } -static WERROR regdb_upgrade_v1_to_v2(void) +static WERROR regdb_upgrade_v1_to_v2(struct db_context *db) { TALLOC_CTX *mem_ctx; int rc; WERROR werr; mem_ctx = talloc_stackframe(); - if (mem_ctx == NULL) { - return WERR_NOMEM; - } - rc = regdb->traverse(regdb, regdb_normalize_keynames_fn, mem_ctx); + rc = regdb->traverse(db, regdb_normalize_keynames_fn, mem_ctx); - talloc_destroy(mem_ctx); + talloc_free(mem_ctx); if (rc < 0) { return WERR_REG_IO_FAILURE; } - werr = regdb_store_regdb_version(REGVER_V2); + werr = regdb_store_regdb_version(db, REGVER_V2); + return werr; +} + +static int regdb_upgrade_v2_to_v3_fn(struct db_record *rec, void *private_data) +{ + const char *keyname; + fstring subkeyname; + NTSTATUS status; + WERROR werr; + uint8_t *buf; + uint32_t buflen, len; + uint32_t num_items; + uint32_t i; + + if (rec->key.dptr == NULL || rec->key.dsize == 0) { + return 0; + } + + keyname = (const char *)rec->key.dptr; + + if (strncmp(keyname, REG_SORTED_SUBKEYS_PREFIX, + strlen(REG_SORTED_SUBKEYS_PREFIX)) == 0) + { + /* Delete the deprecated sorted subkeys cache. */ + + DEBUG(10, ("regdb_upgrade_v2_to_v3: deleting [%s]\n", keyname)); + + status = rec->delete_rec(rec); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(0, ("regdb_upgrade_v2_to_v3: tdb_delete for [%s] " + "failed!\n", keyname)); + return 1; + } + + return 0; + } + + if (strncmp(keyname, REG_VALUE_PREFIX, strlen(REG_VALUE_PREFIX)) == 0) { + DEBUG(10, ("regdb_upgrade_v2_to_v3: skipping [%s]\n", keyname)); + return 0; + } + + if (strncmp(keyname, REG_SECDESC_PREFIX, + strlen(REG_SECDESC_PREFIX)) == 0) + { + DEBUG(10, ("regdb_upgrade_v2_to_v3: skipping [%s]\n", keyname)); + return 0; + } + + /* + * Found a regular subkey list record. + * Walk the list and create the list record for those + * subkeys that don't already have one. + */ + DEBUG(10, ("regdb_upgrade_v2_to_v3: scanning subkey list of [%s]\n", + keyname)); + + buf = rec->value.dptr; + buflen = rec->value.dsize; + + len = tdb_unpack(buf, buflen, "d", &num_items); + if (len == (uint32_t)-1) { + /* invalid or empty - skip */ + return 0; + } + + for (i=0; i<num_items; i++) { + len += tdb_unpack(buf+len, buflen-len, "f", subkeyname); + DEBUG(10, ("regdb_upgrade_v2_to_v3: " + "writing subkey list for [%s\\%s]\n", + keyname, subkeyname)); + werr = regdb_store_subkey_list(regdb, keyname, subkeyname); + if (!W_ERROR_IS_OK(werr)) { + return 1; + } + } + + return 0; +} + +static WERROR regdb_upgrade_v2_to_v3(struct db_context *db) +{ + int rc; + WERROR werr; + TALLOC_CTX *frame = talloc_stackframe(); + + rc = regdb->traverse(db, regdb_upgrade_v2_to_v3_fn, frame); + if (rc < 0) { + werr = WERR_REG_IO_FAILURE; + goto done; + } + + werr = regdb_store_regdb_version(db, REGVER_V3); + +done: + talloc_free(frame); return werr; } @@ -526,7 +582,7 @@ WERROR regdb_init(void) DEBUG(10, ("regdb_init: registry db openend. refcount reset (%d)\n", regdb_refcount)); - expected_version = REGVER_V2; + expected_version = REGVER_V3; vers_id = dbwrap_fetch_int32(regdb, vstring); if (vers_id == -1) { @@ -534,7 +590,7 @@ WERROR regdb_init(void) "(got %d), initializing to version %d\n", vers_id, expected_version)); - werr = regdb_store_regdb_version(expected_version); + werr = regdb_store_regdb_version(regdb, expected_version); return werr; } @@ -545,29 +601,42 @@ WERROR regdb_init(void) return WERR_CAN_NOT_COMPLETE; } - if (vers_id == REGVER_V1) { - DEBUG(10, ("regdb_init: got registry db version %d, upgrading " - "to version %d\n", REGVER_V1, REGVER_V2)); + if (regdb->transaction_start(regdb) != 0) { + return WERR_REG_IO_FAILURE; + } - if (regdb->transaction_start(regdb) != 0) { - return WERR_REG_IO_FAILURE; - } + if (vers_id == REGVER_V1) { + DEBUG(10, ("regdb_init: upgrading registry fromversion %d " + "to %d\n", REGVER_V1, REGVER_V2)); - werr = regdb_upgrade_v1_to_v2(); + werr = regdb_upgrade_v1_to_v2(regdb); if (!W_ERROR_IS_OK(werr)) { regdb->transaction_cancel(regdb); return werr; } - if (regdb->transaction_commit(regdb) != 0) { - return WERR_REG_IO_FAILURE; + vers_id = REGVER_V2; + } + + if (vers_id == REGVER_V2) { + DEBUG(10, ("regdb_init: upgrading registry from version %d " + "to %d\n", REGVER_V2, REGVER_V3)); + + werr = regdb_upgrade_v2_to_v3(regdb); + if (!W_ERROR_IS_OK(werr)) { + regdb->transaction_cancel(regdb); + return werr; } - vers_id = REGVER_V2; + vers_id = REGVER_V3; } /* future upgrade code should go here */ + if (regdb->transaction_commit(regdb) != 0) { + return WERR_REG_IO_FAILURE; + } + return WERR_OK; } @@ -686,7 +755,7 @@ static WERROR regdb_delete_key_with_prefix(struct db_context *db, werr = ntstatus_to_werror(dbwrap_delete_bystring(db, path)); - /* treat "not" found" as ok */ + /* treat "not found" as ok */ if (W_ERROR_EQUAL(werr, WERR_NOT_FOUND)) { werr = WERR_OK; } @@ -712,12 +781,6 @@ static WERROR regdb_delete_subkeylist(struct db_context *db, const char *keyname return regdb_delete_key_with_prefix(db, keyname, NULL); } -static WERROR regdb_delete_sorted_subkeys(struct db_context *db, - const char *keyname) -{ - return regdb_delete_key_with_prefix(db, keyname, REG_SORTED_SUBKEYS_PREFIX); -} - static WERROR regdb_delete_key_lists(struct db_context *db, const char *keyname) { @@ -737,14 +800,6 @@ static WERROR regdb_delete_key_lists(struct db_context *db, const char *keyname) goto done; } - werr = regdb_delete_sorted_subkeys(db, keyname); - if (!W_ERROR_IS_OK(werr)) { - DEBUG(1, (__location__ " Deleting %s\\%s failed: %s\n", - REG_SORTED_SUBKEYS_PREFIX, keyname, - win_errstr(werr))); - goto done; - } - werr = regdb_delete_subkeylist(db, keyname); if (!W_ERROR_IS_OK(werr)) { DEBUG(1, (__location__ " Deleting %s failed: %s\n", @@ -847,12 +902,6 @@ static WERROR regdb_store_keys_internal2(struct db_context *db, dbuf.dsize = len; werr = ntstatus_to_werror(dbwrap_store_bystring(db, keyname, dbuf, TDB_REPLACE)); - W_ERROR_NOT_OK_GOTO_DONE(werr); - -- Samba Shared Repository