diff options
author | Michael Adam <obnox@samba.org> | 2012-04-12 17:52:43 +0200 |
---|---|---|
committer | Andreas Schneider <asn@samba.org> | 2012-04-25 14:31:10 +0200 |
commit | 8d19ac7474e67eb8ffccb717c177c952e10e88e3 (patch) | |
tree | c6c3c7ae32c3be31462e0c4076426ec6219aea2a /source3/registry | |
parent | 97bf05871ad384fd53f04b92489934fef1e42d63 (diff) | |
download | samba-8d19ac7474e67eb8ffccb717c177c952e10e88e3.tar.gz samba-8d19ac7474e67eb8ffccb717c177c952e10e88e3.tar.bz2 samba-8d19ac7474e67eb8ffccb717c177c952e10e88e3.zip |
s3:registry: wrap reg_deletevalue() in a transaction
This is at the wrong layer, but if fixes a race potentially causing
data corruption by concurrent access.
Signed-off-by: Andreas Schneider <asn@samba.org>
Diffstat (limited to 'source3/registry')
-rw-r--r-- | source3/registry/reg_api.c | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/source3/registry/reg_api.c b/source3/registry/reg_api.c index 20ece83075..0bffbda502 100644 --- a/source3/registry/reg_api.c +++ b/source3/registry/reg_api.c @@ -802,24 +802,50 @@ WERROR reg_deletevalue(struct registry_key *key, const char *name) return WERR_ACCESS_DENIED; } - err = fill_value_cache(key); + err = regdb_transaction_start(); if (!W_ERROR_IS_OK(err)) { + DEBUG(0, ("reg_deletevalue: Failed to start transaction: %s\n", + win_errstr(err))); return err; } + err = fill_value_cache(key); + if (!W_ERROR_IS_OK(err)) { + DEBUG(0, ("reg_deletevalue; Error filling value cache: %s\n", + win_errstr(err))); + goto done; + } + err = reg_value_exists(key, name); if (!W_ERROR_IS_OK(err)) { - return err; + goto done; } regval_ctr_delvalue(key->values, name); if (!store_reg_values(key->key, key->values)) { TALLOC_FREE(key->values); - return WERR_REG_IO_FAILURE; + err = WERR_REG_IO_FAILURE; + DEBUG(0, ("reg_deletevalue: store_reg_values failed\n")); + goto done; } - return WERR_OK; + err = WERR_OK; + +done: + if (W_ERROR_IS_OK(err)) { + err = regdb_transaction_commit(); + if (!W_ERROR_IS_OK(err)) { + DEBUG(0, ("reg_deletevalue: Error committing transaction: %s\n", win_errstr(err))); + } + } else { + WERROR err1 = regdb_transaction_cancel(); + if (!W_ERROR_IS_OK(err1)) { + DEBUG(0, ("reg_deletevalue: Error cancelling transaction: %s\n", win_errstr(err1))); + } + } + + return err; } WERROR reg_getkeysecurity(TALLOC_CTX *mem_ctx, struct registry_key *key, |