mirror of
https://github.com/samba-team/samba.git
synced 2025-01-11 05:18:09 +03:00
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>
This commit is contained in:
parent
32ac4f4b34
commit
8c7047b0e7
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user