diff options
author | Martin Hedenfal <martinh@cvs.openbsd.org> | 2010-09-03 09:53:25 +0000 |
---|---|---|
committer | Martin Hedenfal <martinh@cvs.openbsd.org> | 2010-09-03 09:53:25 +0000 |
commit | 4b5e69ad10e703677e85fa6a2a320e96424b747f (patch) | |
tree | f98797c7a8a73466e18c9e6dd628e53fbebff453 /usr.sbin | |
parent | 90235b6a389342833e0d0274e26e329442fc5afd (diff) |
Resolve matching rules from superior attribute types at schema load time
instead of when each attribute is validated.
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/ldapd/schema.c | 23 | ||||
-rw-r--r-- | usr.sbin/ldapd/validate.c | 14 |
2 files changed, 24 insertions, 13 deletions
diff --git a/usr.sbin/ldapd/schema.c b/usr.sbin/ldapd/schema.c index 2daca246015..7b3c24f37e1 100644 --- a/usr.sbin/ldapd/schema.c +++ b/usr.sbin/ldapd/schema.c @@ -1,4 +1,4 @@ -/* $OpenBSD: schema.c,v 1.10 2010/09/03 09:39:17 martinh Exp $ */ +/* $OpenBSD: schema.c,v 1.11 2010/09/03 09:53:24 martinh Exp $ */ /* * Copyright (c) 2010 Martin Hedenfalk <martinh@openbsd.org> @@ -799,6 +799,27 @@ schema_parse_attributetype(struct schema *schema) goto fail; } + /* If the attribute type doesn't explicitly define equality, check + * if any superior attribute type does. + */ + sup = attr->sup; + while (attr->equality == NULL && sup != NULL) { + attr->equality = sup->equality; + sup = sup->sup; + } + /* Same thing with ordering matching rule. */ + sup = attr->sup; + while (attr->ordering == NULL && sup != NULL) { + attr->ordering = sup->ordering; + sup = sup->sup; + } + /* ...and substring matching rule. */ + sup = attr->sup; + while (attr->substr == NULL && sup != NULL) { + attr->substr = sup->substr; + sup = sup->sup; + } + return 0; fail: diff --git a/usr.sbin/ldapd/validate.c b/usr.sbin/ldapd/validate.c index 8df2c710180..ab4b15d8714 100644 --- a/usr.sbin/ldapd/validate.c +++ b/usr.sbin/ldapd/validate.c @@ -1,4 +1,4 @@ -/* $OpenBSD: validate.c,v 1.8 2010/09/03 09:39:17 martinh Exp $ */ +/* $OpenBSD: validate.c,v 1.9 2010/09/03 09:53:24 martinh Exp $ */ /* * Copyright (c) 2010 Martin Hedenfalk <martin@bzero.se> @@ -95,16 +95,6 @@ validate_attribute(struct attr_type *at, struct ber_element *vals) return LDAP_SUCCESS; } -static const char * -attribute_equality(struct attr_type *at) -{ - if (at == NULL) - return NULL; - if (at->equality != NULL) - return at->equality; - return attribute_equality(at->sup); -} - /* FIXME: doesn't handle escaped characters. */ static int @@ -158,7 +148,7 @@ validate_dn(const char *dn, struct ber_element *entry) log_debug("naming attribute %s is obsolete", na); goto fail; } - if (attribute_equality(at) == NULL) { + if (at->equality == NULL) { log_debug("naming attribute %s doesn't define equality", na); goto fail; |