From 8dde2f75d3e21ebf0048385086ad30854f6a7684 Mon Sep 17 00:00:00 2001 From: Garming Sam Date: Thu, 9 Mar 2017 12:22:13 +1300 Subject: [PATCH] objectclass_attrs: Remove schema copy shallow from attr_handler2 This appears quite expensive (particularly in provision), and also unnecessary. Signed-off-by: Garming Sam --- source4/dsdb/samdb/ldb_modules/objectclass_attrs.c | 14 +------------- source4/dsdb/schema/schema_init.c | 16 ++++++++-------- 2 files changed, 9 insertions(+), 21 deletions(-) diff --git a/source4/dsdb/samdb/ldb_modules/objectclass_attrs.c b/source4/dsdb/samdb/ldb_modules/objectclass_attrs.c index f28c7fb..cfacaf5 100644 --- a/source4/dsdb/samdb/ldb_modules/objectclass_attrs.c +++ b/source4/dsdb/samdb/ldb_modules/objectclass_attrs.c @@ -496,25 +496,13 @@ static int attr_handler2(struct oc_context *ac) struct dsdb_attribute *att = talloc(ac, struct dsdb_attribute); const struct dsdb_syntax *attrSyntax; WERROR status; - struct dsdb_schema *tmp_schema = NULL; - /* - * We temporary remove the prefix map from the schema, - * a new prefix map is added by dsdb_create_prefix_mapping() - * via the "schema_data" module. - */ - tmp_schema = dsdb_schema_copy_shallow(ac, ldb, ac->schema); - if (tmp_schema == NULL) { - return ldb_module_oom(ac->module); - } - TALLOC_FREE(tmp_schema->prefixmap); - status= dsdb_attribute_from_ldb(tmp_schema, msg, att); + status = dsdb_attribute_from_ldb(NULL, msg, att); if (!W_ERROR_IS_OK(status)) { ldb_set_errstring(ldb, "objectclass: failed to translate the schemaAttribute to a dsdb_attribute"); return LDB_ERR_UNWILLING_TO_PERFORM; } - TALLOC_FREE(tmp_schema); attrSyntax = dsdb_syntax_for_attribute(att); if (!attrSyntax) { diff --git a/source4/dsdb/schema/schema_init.c b/source4/dsdb/schema/schema_init.c index 199ee28..d738b29 100644 --- a/source4/dsdb/schema/schema_init.c +++ b/source4/dsdb/schema/schema_init.c @@ -623,7 +623,7 @@ static int dsdb_schema_setup_ldb_schema_attribute(struct ldb_context *ldb, /** Create an dsdb_attribute out of ldb message, attr must be already talloced */ -WERROR dsdb_attribute_from_ldb(const struct dsdb_schema *schema, +WERROR dsdb_attribute_from_ldb(const struct dsdb_schema_prefixmap *prefixmap, struct ldb_message *msg, struct dsdb_attribute *attr) { @@ -646,13 +646,13 @@ WERROR dsdb_attribute_from_ldb(const struct dsdb_schema *schema, GET_STRING_LDB(msg, "lDAPDisplayName", attr, attr, lDAPDisplayName, true); GET_STRING_LDB(msg, "attributeID", attr, attr, attributeID_oid, true); - if (!schema->prefixmap || schema->prefixmap->length == 0) { + if (!prefixmap || prefixmap->length == 0) { /* set an invalid value */ attr->attributeID_id = DRSUAPI_ATTID_INVALID; } else { - status = dsdb_schema_pfm_attid_from_oid(schema->prefixmap, - attr->attributeID_oid, - &attr->attributeID_id); + status = dsdb_schema_pfm_attid_from_oid(prefixmap, + attr->attributeID_oid, + &attr->attributeID_id); if (!W_ERROR_IS_OK(status)) { DEBUG(0,("%s: '%s': unable to map attributeID %s: %s\n", __location__, attr->lDAPDisplayName, attr->attributeID_oid, @@ -676,11 +676,11 @@ WERROR dsdb_attribute_from_ldb(const struct dsdb_schema *schema, GET_UINT32_LDB(msg, "linkID", attr, linkID); GET_STRING_LDB(msg, "attributeSyntax", attr, attr, attributeSyntax_oid, true); - if (!schema->prefixmap || schema->prefixmap->length == 0) { + if (!prefixmap || prefixmap->length == 0) { /* set an invalid value */ attr->attributeSyntax_id = DRSUAPI_ATTID_INVALID; } else { - status = dsdb_schema_pfm_attid_from_oid(schema->prefixmap, + status = dsdb_schema_pfm_attid_from_oid(prefixmap, attr->attributeSyntax_oid, &attr->attributeSyntax_id); if (!W_ERROR_IS_OK(status)) { @@ -723,7 +723,7 @@ WERROR dsdb_set_attribute_from_ldb_dups(struct ldb_context *ldb, return WERR_NOT_ENOUGH_MEMORY; } - status = dsdb_attribute_from_ldb(schema, msg, attr); + status = dsdb_attribute_from_ldb(schema->prefixmap, msg, attr); if (!W_ERROR_IS_OK(status)) { return status; } -- 1.9.1