Signed-off-by: Michael Adam <obnox@samba.org>
+ if (regdb->transaction_start(regdb) != 0) {
+ DEBUG(0, ("create_sorted_subkeys: transaction_start "
+ "failed\n"));
+ return false;
+ }
+
ctr = talloc(talloc_tos(), REGSUBKEY_CTR);
if (ctr == NULL) {
ctr = talloc(talloc_tos(), REGSUBKEY_CTR);
if (ctr == NULL) {
}
res = regdb_fetch_keys(key, ctr);
}
res = regdb_fetch_keys(key, ctr);
p += strlen(sorted_subkeys[i]) + 1;
}
p += strlen(sorted_subkeys[i]) + 1;
}
- status = dbwrap_trans_store_bystring(
+ status = dbwrap_store_bystring(
regdb, sorted_keyname, make_tdb_data((uint8_t *)buf, len),
TDB_REPLACE);
if (!NT_STATUS_IS_OK(status)) {
regdb, sorted_keyname, make_tdb_data((uint8_t *)buf, len),
TDB_REPLACE);
if (!NT_STATUS_IS_OK(status)) {
+ /*
+ * Don't use a "goto fail;" here, this would commit the broken
+ * transaction. See below for an explanation.
+ */
+ if (regdb->transaction_cancel(regdb) == -1) {
+ DEBUG(0, ("create_sorted_subkeys: transaction_cancel "
+ "failed\n"));
+ }
+ TALLOC_FREE(ctr);
+ return false;
+ /*
+ * We only get here via the "goto fail" when we did not write anything
+ * yet. Using transaction_commit even in a failure case is necessary
+ * because this (disposable) call might be nested in other
+ * transactions. Doing a cancel here would destroy the possibility of
+ * a transaction_commit for transactions that we might be wrapped in.
+ */
+ if (regdb->transaction_commit(regdb) == -1) {
+ DEBUG(0, ("create_sorted_subkeys: transaction_start "
+ "failed\n"));
+ goto fail;
+ }
+
TALLOC_FREE(ctr);
return result;
}
TALLOC_FREE(ctr);
return result;
}