s4-dsdb: ensure that new partitions inherit any transaction
[ira/wip.git] / source4 / dsdb / samdb / ldb_modules / partition.c
index 779b8b5a35b2737756fe855fc2d2ce1295de8a25..64015ed7b16e0f7d22981557d3fa4f233a91c50f 100644 (file)
@@ -690,6 +690,9 @@ static int partition_start_trans(struct ldb_module *module)
                        return ret;
                }
        }
+
+       data->in_transaction++;
+
        return LDB_SUCCESS;
 }
 
@@ -737,6 +740,12 @@ static int partition_end_trans(struct ldb_module *module)
                }
        }
 
+       if (data->in_transaction == 0) {
+               DEBUG(0,("partition end transaction mismatch\n"));
+               return LDB_ERR_OPERATIONS_ERROR;
+       }
+       data->in_transaction--;
+
        return ldb_next_end_trans(module);
 }
 
@@ -756,6 +765,12 @@ static int partition_del_trans(struct ldb_module *module)
                }
        }       
 
+       if (data->in_transaction == 0) {
+               DEBUG(0,("partition del transaction mismatch\n"));
+               return LDB_ERR_OPERATIONS_ERROR;
+       }
+       data->in_transaction--;
+
        ret = ldb_next_del_trans(module);
        if (ret != LDB_SUCCESS) {
                final_ret = ret;