diff options
author | Michael Adam <obnox@samba.org> | 2011-08-25 17:12:33 +0200 |
---|---|---|
committer | Michael Adam <obnox@samba.org> | 2011-08-25 23:55:06 +0200 |
commit | 48f08011e56664bf91570499d38e5e4d39e8ed38 (patch) | |
tree | 6a949ed1a01d611154d737b1e671b890e090f468 | |
parent | faa769ec19b6486675048734837a6e2237d6f0a4 (diff) | |
download | samba-48f08011e56664bf91570499d38e5e4d39e8ed38.tar.gz samba-48f08011e56664bf91570499d38e5e4d39e8ed38.tar.bz2 samba-48f08011e56664bf91570499d38e5e4d39e8ed38.zip |
s3:registry: fix broken use of dbwrap store record in v1_to_v2 upgrade code
This also fixes broken private_data parameter for the traverse function
(making use of it): Originally a memory context was handed in but was not used.
-rw-r--r-- | source3/registry/reg_backend_db.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/source3/registry/reg_backend_db.c b/source3/registry/reg_backend_db.c index 4e10bf652a..4ca4a79cb8 100644 --- a/source3/registry/reg_backend_db.c +++ b/source3/registry/reg_backend_db.c @@ -368,15 +368,20 @@ static int regdb_normalize_keynames_fn(struct db_record *rec, TALLOC_CTX *mem_ctx = talloc_tos(); const char *keyname; NTSTATUS status; + struct db_context *db = (struct db_context *)private_data; if (rec->key.dptr == NULL || rec->key.dsize == 0) { return 0; } + if (db == NULL) { + DEBUG(0, ("regdb_normalize_keynames_fn: ERROR: " + "NULL db context handed in via private_data\n")); + return 1; + } + keyname = strchr((const char *) rec->key.dptr, '/'); if (keyname) { - struct db_record new_rec; - keyname = talloc_string_sub(mem_ctx, (const char *) rec->key.dptr, "/", @@ -386,10 +391,6 @@ static int regdb_normalize_keynames_fn(struct db_record *rec, (const char *) rec->key.dptr, keyname)); - new_rec.value = rec->value; - new_rec.key = string_term_tdb_data(keyname); - new_rec.private_data = rec->private_data; - /* Delete the original record and store the normalized key */ status = rec->delete_rec(rec); if (!NT_STATUS_IS_OK(status)) { @@ -399,7 +400,8 @@ static int regdb_normalize_keynames_fn(struct db_record *rec, return 1; } - status = rec->store(&new_rec, new_rec.value, TDB_REPLACE); + status = dbwrap_store_bystring(db, keyname, rec->value, + TDB_REPLACE); if (!NT_STATUS_IS_OK(status)) { DEBUG(0,("regdb_normalize_keynames_fn: " "failed to store new record for [%s]!\n", @@ -440,7 +442,7 @@ static WERROR regdb_upgrade_v1_to_v2(struct db_context *db) mem_ctx = talloc_stackframe(); - rc = regdb->traverse(db, regdb_normalize_keynames_fn, mem_ctx); + rc = db->traverse(db, regdb_normalize_keynames_fn, db); talloc_free(mem_ctx); |