summaryrefslogtreecommitdiff
path: root/source4/dsdb
diff options
context:
space:
mode:
authorGarming Sam <garming@catalyst.net.nz>2017-03-09 12:22:13 +1300
committerAndreas Schneider <asn@cryptomilk.org>2017-03-10 15:34:38 +0100
commit49c9ef641d82fd09faa6a7ce405e5b8aa1aeda69 (patch)
treef4e64efdec0099061d347a04e34f937347603044 /source4/dsdb
parent3314bf52aaef60ef5cc1110587b53064df7c475d (diff)
downloadsamba-49c9ef641d82fd09faa6a7ce405e5b8aa1aeda69.tar.gz
objectclass_attrs: Remove schema copy shallow from attr_handler2
This appears quite expensive (particularly in provision), and also unnecessary. Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org> Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org> Autobuild-Date(master): Fri Mar 10 15:34:39 CET 2017 on sn-devel-144
Diffstat (limited to 'source4/dsdb')
-rw-r--r--source4/dsdb/samdb/ldb_modules/objectclass_attrs.c14
-rw-r--r--source4/dsdb/schema/schema_init.c22
2 files changed, 15 insertions, 21 deletions
diff --git a/source4/dsdb/samdb/ldb_modules/objectclass_attrs.c b/source4/dsdb/samdb/ldb_modules/objectclass_attrs.c
index e239fb946e7..c144578f227 100644
--- a/source4/dsdb/samdb/ldb_modules/objectclass_attrs.c
+++ b/source4/dsdb/samdb/ldb_modules/objectclass_attrs.c
@@ -456,25 +456,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 199ee28053c..256c4677452 100644
--- a/source4/dsdb/schema/schema_init.c
+++ b/source4/dsdb/schema/schema_init.c
@@ -621,9 +621,15 @@ static int dsdb_schema_setup_ldb_schema_attribute(struct ldb_context *ldb,
} while (0)
/** Create an dsdb_attribute out of ldb message, attr must be already talloced
+ *
+ * If supplied the attribute will be checked against the prefixmap to
+ * ensure it can be mapped. However we can't have this attribute
+ * const as dsdb_schema_pfm_attid_from_oid calls
+ * dsdb_schema_pfm_make_attid_impl() which may modify prefixmap in
+ * other situations.
*/
-WERROR dsdb_attribute_from_ldb(const struct dsdb_schema *schema,
+WERROR dsdb_attribute_from_ldb(struct dsdb_schema_prefixmap *prefixmap,
struct ldb_message *msg,
struct dsdb_attribute *attr)
{
@@ -646,13 +652,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 +682,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 +729,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;
}