summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2012-04-12 22:53:24 +0200
committerAndreas Schneider <asn@samba.org>2012-04-25 14:31:11 +0200
commit8c7047b0e7b1ee25a6a5535cf495c9afded2d924 (patch)
tree5fe516e0056b0bde81f9d663d3cef08c1311137c
parent32ac4f4b34dd2788498f0c09c946532165d6af74 (diff)
downloadsamba-8c7047b0e7b1ee25a6a5535cf495c9afded2d924.tar.gz
s3:registry: wrap reg_deletekey() into a transaction
This is wrong layering but fixes a race condition. Signed-off-by: Andreas Schneider <asn@samba.org>
-rw-r--r--source3/registry/reg_api.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/source3/registry/reg_api.c b/source3/registry/reg_api.c
index 405a10591ca..7ae84ed5f06 100644
--- a/source3/registry/reg_api.c
+++ b/source3/registry/reg_api.c
@@ -726,14 +726,37 @@ WERROR reg_deletekey(struct registry_key *parent, const char *path)
err = reg_openkey(mem_ctx, parent, path, REG_KEY_READ, &key);
W_ERROR_NOT_OK_GOTO_DONE(err);
+ err = regdb_transaction_start();
+ if (!W_ERROR_IS_OK(err)) {
+ DEBUG(0, ("reg_deletekey: Error starting transaction: %s\n",
+ win_errstr(err)));
+ goto done;
+ }
+
err = fill_subkey_cache(key);
- W_ERROR_NOT_OK_GOTO_DONE(err);
+ if (!W_ERROR_IS_OK(err)) {
+ goto trans_done;
+ }
if (regsubkey_ctr_numkeys(key->subkeys) > 0) {
err = WERR_ACCESS_DENIED;
- goto done;
+ goto trans_done;
}
err = reg_deletekey_internal(mem_ctx, parent, path, false);
+
+trans_done:
+ if (W_ERROR_IS_OK(err)) {
+ err = regdb_transaction_commit();
+ if (!W_ERROR_IS_OK(err)) {
+ DEBUG(0, ("reg_deletekey: Error committing transaction: %s\n", win_errstr(err)));
+ }
+ } else {
+ WERROR err1 = regdb_transaction_cancel();
+ if (!W_ERROR_IS_OK(err1)) {
+ DEBUG(0, ("reg_deletekey: Error cancelling transaction: %s\n", win_errstr(err1)));
+ }
+ }
+
done:
TALLOC_FREE(mem_ctx);
return err;