summaryrefslogtreecommitdiff
path: root/source4/dsdb/repl
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2010-03-16 14:52:39 +1100
committerAndrew Bartlett <abartlet@samba.org>2010-03-16 19:26:03 +1100
commit2de07761e071ccf09c0ea9e0fdc6a61303356549 (patch)
tree8d95f00365a32c81e001768fc2aa0aa8c866accb /source4/dsdb/repl
parentbf0b4d7ee3f52f77d706ccea12abb2f033b4abd9 (diff)
downloadsamba-2de07761e071ccf09c0ea9e0fdc6a61303356549.tar.gz
samba-2de07761e071ccf09c0ea9e0fdc6a61303356549.tar.bz2
samba-2de07761e071ccf09c0ea9e0fdc6a61303356549.zip
s4:dsdb Change dsdb_get_schema() callers to use new talloc argument
This choses an appropriate talloc context to attach the schema too, long enough lived to ensure it does not go away before the operation compleates. Andrew Bartlett
Diffstat (limited to 'source4/dsdb/repl')
-rw-r--r--source4/dsdb/repl/replicated_objects.c30
1 files changed, 19 insertions, 11 deletions
diff --git a/source4/dsdb/repl/replicated_objects.c b/source4/dsdb/repl/replicated_objects.c
index 4d500e9637..5e69236416 100644
--- a/source4/dsdb/repl/replicated_objects.c
+++ b/source4/dsdb/repl/replicated_objects.c
@@ -215,17 +215,22 @@ WERROR dsdb_extended_replicated_objects_convert(struct ldb_context *ldb,
const struct drsuapi_DsReplicaObjectListItemEx *cur;
uint32_t i;
- schema = dsdb_get_schema(ldb);
+ out = talloc_zero(mem_ctx, struct dsdb_extended_replicated_objects);
+ W_ERROR_HAVE_NO_MEMORY(out);
+ out->version = DSDB_EXTENDED_REPLICATED_OBJECTS_VERSION;
+
+ /* Get the schema, and ensure it's kept valid for as long as 'out' which may contain pointers to it */
+ schema = dsdb_get_schema(ldb, out);
if (!schema) {
+ talloc_free(out);
return WERR_DS_SCHEMA_NOT_LOADED;
}
status = dsdb_schema_pfm_contains_drsuapi_pfm(schema->prefixmap, mapping_ctr);
- W_ERROR_NOT_OK_RETURN(status);
-
- out = talloc_zero(mem_ctx, struct dsdb_extended_replicated_objects);
- W_ERROR_HAVE_NO_MEMORY(out);
- out->version = DSDB_EXTENDED_REPLICATED_OBJECTS_VERSION;
+ if (!W_ERROR_IS_OK(status)) {
+ talloc_free(out);
+ return status;
+ }
out->partition_dn = ldb_dn_new(out, ldb, partition_dn);
W_ERROR_HAVE_NO_MEMORY(out->partition_dn);
@@ -246,6 +251,7 @@ WERROR dsdb_extended_replicated_objects_convert(struct ldb_context *ldb,
for (i=0, cur = first_object; cur; cur = cur->next_object, i++) {
if (i == out->num_objects) {
+ talloc_free(out);
return WERR_FOOBAR;
}
@@ -253,11 +259,13 @@ WERROR dsdb_extended_replicated_objects_convert(struct ldb_context *ldb,
cur, gensec_skey,
out->objects, &out->objects[i]);
if (!W_ERROR_IS_OK(status)) {
+ talloc_free(out);
DEBUG(0,("Failed to convert object %s\n", cur->object.identifier->dn));
return status;
}
}
if (i != out->num_objects) {
+ talloc_free(out);
return WERR_FOOBAR;
}
@@ -402,11 +410,6 @@ WERROR dsdb_origin_objects_commit(struct ldb_context *ldb,
struct ldb_result *res;
int ret;
- schema = dsdb_get_schema(ldb);
- if (!schema) {
- return WERR_DS_SCHEMA_NOT_LOADED;
- }
-
for (cur = first_object; cur; cur = cur->next_object) {
num_objects++;
}
@@ -427,6 +430,11 @@ WERROR dsdb_origin_objects_commit(struct ldb_context *ldb,
goto cancel;
}
+ schema = dsdb_get_schema(ldb, objects);
+ if (!schema) {
+ return WERR_DS_SCHEMA_NOT_LOADED;
+ }
+
for (i=0, cur = first_object; cur; cur = cur->next_object, i++) {
status = dsdb_convert_object(ldb, schema,
cur, objects, &objects[i]);