summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2009-07-09 11:04:20 +0200
committerMichael Adam <obnox@samba.org>2009-07-15 14:01:55 +0200
commit2d6dbcd0b13da469f8b7dc6ed65e51d91ce1ab9c (patch)
treecc261e1bcc7c5c3b6fcd21a5e8ee7ce13414c36e
parenta48d8353c79685371dbd2cc73b6c9032c5166a5b (diff)
downloadsamba-2d6dbcd0b13da469f8b7dc6ed65e51d91ce1ab9c.tar.gz
samba-2d6dbcd0b13da469f8b7dc6ed65e51d91ce1ab9c.tar.bz2
samba-2d6dbcd0b13da469f8b7dc6ed65e51d91ce1ab9c.zip
s3:registry: use transaction wrapper in regdb_delete_subkey().
Michael
-rw-r--r--source3/registry/reg_backend_db.c86
1 files changed, 49 insertions, 37 deletions
diff --git a/source3/registry/reg_backend_db.c b/source3/registry/reg_backend_db.c
index 8cd79b15b2..095b0c5b22 100644
--- a/source3/registry/reg_backend_db.c
+++ b/source3/registry/reg_backend_db.c
@@ -1019,11 +1019,53 @@ done:
* create a subkey of a given key
*/
-static WERROR regdb_delete_subkey(const char *key, const char *subkey)
+struct regdb_delete_subkey_context {
+ const char *key;
+ const char *subkey;
+ const char *path;
+};
+
+static NTSTATUS regdb_delete_subkey_action(struct db_context *db,
+ void *private_data)
{
WERROR werr;
+ struct regdb_delete_subkey_context *delete_ctx;
struct regsubkey_ctr *subkeys;
+ TALLOC_CTX *mem_ctx = talloc_stackframe();
+
+ delete_ctx = (struct regdb_delete_subkey_context *)private_data;
+
+ werr = regdb_delete_key_lists(db, delete_ctx->path);
+ W_ERROR_NOT_OK_GOTO_DONE(werr);
+
+ werr = regsubkey_ctr_init(mem_ctx, &subkeys);
+ W_ERROR_NOT_OK_GOTO_DONE(werr);
+
+ if (regdb_fetch_keys_internal(db, delete_ctx->key, subkeys) < 0) {
+ werr = WERR_REG_IO_FAILURE;
+ goto done;
+ }
+
+ werr = regsubkey_ctr_delkey(subkeys, delete_ctx->subkey);
+ W_ERROR_NOT_OK_GOTO_DONE(werr);
+
+ werr = regdb_store_keys_internal2(db, delete_ctx->key, subkeys);
+ if (!W_ERROR_IS_OK(werr)) {
+ DEBUG(0, (__location__ " failed to store new subkey_list for "
+ "parent key %s: %s\n", delete_ctx->key,
+ win_errstr(werr)));
+ }
+
+done:
+ talloc_free(mem_ctx);
+ return werror_to_ntstatus(werr);
+}
+
+static WERROR regdb_delete_subkey(const char *key, const char *subkey)
+{
+ WERROR werr;
char *path;
+ struct regdb_delete_subkey_context delete_ctx;
TALLOC_CTX *mem_ctx = talloc_stackframe();
if (!regdb_key_is_base_key(key) && !regdb_key_exists(regdb, key)) {
@@ -1042,43 +1084,13 @@ static WERROR regdb_delete_subkey(const char *key, const char *subkey)
goto done;
}
- if (regdb->transaction_start(regdb) != 0) {
- werr = WERR_REG_IO_FAILURE;
- goto done;
- }
-
- werr = regdb_delete_key_lists(regdb, path);
- W_ERROR_NOT_OK_GOTO(werr, cancel);
-
- werr = regsubkey_ctr_init(mem_ctx, &subkeys);
- W_ERROR_NOT_OK_GOTO(werr, cancel);
-
- if (regdb_fetch_keys_internal(regdb, key, subkeys) < 0) {
- werr = WERR_REG_IO_FAILURE;
- goto cancel;
- }
-
- werr = regsubkey_ctr_delkey(subkeys, subkey);
- W_ERROR_NOT_OK_GOTO(werr, cancel);
-
- werr = regdb_store_keys_internal2(regdb, key, subkeys);
- if (!W_ERROR_IS_OK(werr)) {
- DEBUG(0, (__location__ " failed to store new subkey_list for "
- "parent key %s: %s\n", key, win_errstr(werr)));
- goto cancel;
- }
-
- if (regdb->transaction_commit(regdb) != 0) {
- DEBUG(0, (__location__ " failed to commit transaction\n"));
- werr = WERR_REG_IO_FAILURE;
- }
+ delete_ctx.key = key;
+ delete_ctx.subkey = subkey;
+ delete_ctx.path = path;
- goto done;
-
-cancel:
- if (regdb->transaction_cancel(regdb) != 0) {
- smb_panic("regdb_delete_subkey: transaction_cancel failed\n");
- }
+ werr = ntstatus_to_werror(dbwrap_trans_do(regdb,
+ regdb_delete_subkey_action,
+ &delete_ctx));
done:
talloc_free(mem_ctx);