diff options
author | Rich Megginson <rmeggins@redhat.com> | 2010-02-16 15:56:59 -0700 |
---|---|---|
committer | Rich Megginson <rmeggins@redhat.com> | 2010-02-17 15:05:40 -0700 |
commit | ecf93e699b04d45fdfa07b12094adaab0233c47a (patch) | |
tree | c8725f13871e4d45cd97aec529417289234c8676 /ldap/servers/slapd/attrsyntax.c | |
parent | 6adbad044ef95411882ec546281a0df6d0816673 (diff) | |
download | ds-ecf93e699b04d45fdfa07b12094adaab0233c47a.tar.gz ds-ecf93e699b04d45fdfa07b12094adaab0233c47a.tar.xz ds-ecf93e699b04d45fdfa07b12094adaab0233c47a.zip |
change syntax plugins to register required matching rule plugins
https://bugzilla.redhat.com/show_bug.cgi?id=559315
Resolves: 559315
Description: Searching some attributes are now case sensitive when they were previously case-insensitive
Reviewed by: nhosoi (Thanks!) - also added some suggested comments
I added code to allow the syntax plugins to register corresponding
matching rules. That is, the functions that the syntax plugins use
for filter matching and key generation can also be used for matching
rules with the new wrapper code. I added some convenience functions
and structures in the syntax plugin code to make it easier to add
matching rules in the future. I also added a new feature to the
matching rule code - in the LDAP spec definition of matching rule, the
syntax provided in the matching rule definition is the syntax for
the _assertion value_ used with the matching rule, which is not
necessarily the same as the syntax of the _attribute values_ to which
the matching rule can be applied. For example, matching rules that apply
to syntax DirectoryString can also be applied in some cases to
PrintableString, CountryString, and IA5String. There are several other
cases like this as well. I also introduced the concept of a compat
syntax that can be used with a matching rule. The server will now
check, when reading in the schema, if the syntax and matching rules
for an attribute are consistent.
Finally, for 05rfc4523.ldif, I changed the attributes to use
octetStringMatch instead of one of the unimplemented certificate
matching rules.
Diffstat (limited to 'ldap/servers/slapd/attrsyntax.c')
-rw-r--r-- | ldap/servers/slapd/attrsyntax.c | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/ldap/servers/slapd/attrsyntax.c b/ldap/servers/slapd/attrsyntax.c index 11b272a0..f39c0e96 100644 --- a/ldap/servers/slapd/attrsyntax.c +++ b/ldap/servers/slapd/attrsyntax.c @@ -546,6 +546,9 @@ attr_syntax_dup( struct asyntaxinfo *a ) newas->asi_flags = a->asi_flags; newas->asi_oid = slapi_ch_strdup( a->asi_oid); newas->asi_syntaxlength = a->asi_syntaxlength; + newas->asi_mr_eq_plugin = a->asi_mr_eq_plugin; + newas->asi_mr_ord_plugin = a->asi_mr_ord_plugin; + newas->asi_mr_sub_plugin = a->asi_mr_sub_plugin; return( newas ); } @@ -658,9 +661,11 @@ attr_syntax_create( { char *s; struct asyntaxinfo a; + int rc = LDAP_SUCCESS; /* XXXmcs: had to cast away const in many places below */ memset(&a, 0, sizeof(a)); + *asip = NULL; a.asi_name = slapi_ch_strdup(attr_names[0]); if ( NULL != attr_names[1] ) { a.asi_aliases = (char **)&attr_names[1]; /* all but the zero'th element */ @@ -674,8 +679,45 @@ attr_syntax_create( a.asi_origin = (char **)attr_origins; a.asi_plugin = plugin_syntax_find( attr_syntax ); a.asi_syntaxlength = syntaxlength; + /* ideally, we would report an error and fail to start if there was some problem + with the matching rule - but since this functionality is new, and we might + cause havoc if lots of servers failed to start because of bogus schema, we + just report an error here - at some point in the future, we should actually + report an error and exit, or allow the user to control the behavior - for + now, just log an error, and address each case + */ + if (mr_equality && !slapi_matchingrule_is_compat(mr_equality, attr_syntax)) { + slapi_log_error(SLAPI_LOG_FATAL, "attr_syntax_create", + "Error: the EQUALITY matching rule [%s] is not compatible " + "with the syntax [%s] for the attribute [%s]\n", + mr_equality, attr_syntax, attr_names[0]); +/* + rc = LDAP_INAPPROPRIATE_MATCHING; + goto done; +*/ + } a.asi_mr_eq_plugin = plugin_mr_find( mr_equality ); + if (mr_ordering && !slapi_matchingrule_is_compat(mr_ordering, attr_syntax)) { + slapi_log_error(SLAPI_LOG_FATAL, "attr_syntax_create", + "Error: the ORDERING matching rule [%s] is not compatible " + "with the syntax [%s] for the attribute [%s]\n", + mr_ordering, attr_syntax, attr_names[0]); +/* + rc = LDAP_INAPPROPRIATE_MATCHING; + goto done; +*/ + } a.asi_mr_ord_plugin = plugin_mr_find( mr_ordering ); + if (mr_substring && !slapi_matchingrule_is_compat(mr_substring, attr_syntax)) { + slapi_log_error(SLAPI_LOG_FATAL, "attr_syntax_create", + "Error: the SUBSTR matching rule [%s] is not compatible " + "with the syntax [%s] for the attribute [%s]\n", + mr_substring, attr_syntax, attr_names[0]); +/* + rc = LDAP_INAPPROPRIATE_MATCHING; + goto done; +*/ + } a.asi_mr_sub_plugin = plugin_mr_find( mr_substring ); a.asi_flags = flags; @@ -694,9 +736,10 @@ attr_syntax_create( } *asip = attr_syntax_dup(&a); +done: slapi_ch_free((void **)&a.asi_name); - return LDAP_SUCCESS; + return rc; } |