From c02f448a160332407f32f06816d3f6aa397a44fb Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Mon, 11 Mar 2002 01:48:37 +0000 Subject: [PATCH] Misc extensible match clean up. --- servers/slapd/filter.c | 18 ++++++++++++++++++ servers/slapd/filterentry.c | 19 +++++++++++++------ servers/slapd/schema_init.c | 8 ++++++-- 3 files changed, 37 insertions(+), 8 deletions(-) diff --git a/servers/slapd/filter.c b/servers/slapd/filter.c index 701a614093..1242a6091f 100644 --- a/servers/slapd/filter.c +++ b/servers/slapd/filter.c @@ -736,6 +736,24 @@ filter2bv( Filter *f, struct berval *fstr ) break; + case LDAP_FILTER_EXT: + filter_escape_value( &f->f_mr_value, &tmp ); + + fstr->bv_len = f->f_mr_desc->ad_cname.bv_len + + ( f->f_mr_dnattrs ? sizeof(":dn")-1 : 0 ) + + ( f->f_mr_rule_text.bv_len ? f->f_mr_rule_text.bv_len+1 : 0 ) + + tmp.bv_len + ( sizeof("(:=)") - 1 ); + fstr->bv_val = malloc( fstr->bv_len + 1 ); + + snprintf( fstr->bv_val, fstr->bv_len + 1, "(%s%s%s%s:=%s)", + f->f_mr_desc->ad_cname.bv_val, + f->f_mr_dnattrs ? ":dn" : "", + f->f_mr_rule_text.bv_len ? ":" : "", + f->f_mr_rule_text.bv_len ? f->f_mr_rule_text.bv_val : "", + tmp.bv_val ); + ber_memfree( tmp.bv_val ); + break; + case SLAPD_FILTER_COMPUTED: ber_str2bv( f->f_result == LDAP_COMPARE_FALSE ? "(?=false)" : diff --git a/servers/slapd/filterentry.c b/servers/slapd/filterentry.c index d808ea7154..34bc6f1b77 100644 --- a/servers/slapd/filterentry.c +++ b/servers/slapd/filterentry.c @@ -227,23 +227,30 @@ static int test_mra_filter( { Attribute *a; + if( mra->ma_desc == NULL || mra->ma_dnattrs ) { + return LDAP_INAPPROPRIATE_MATCHING; + } + if( !access_allowed( be, conn, op, e, mra->ma_desc, &mra->ma_value, ACL_SEARCH, NULL ) ) { return LDAP_INSUFFICIENT_ACCESS; } + if( mra->ma_rule == NULL ) { + mra->ma_rule = mra->ma_desc->ad_type->sat_equality; + } + + if( mra->ma_rule == NULL ) { + return LDAP_INAPPROPRIATE_MATCHING; + } + if( strcmp(mra->ma_rule->smr_syntax->ssyn_oid, mra->ma_desc->ad_type->sat_syntax->ssyn_oid) != 0) { return LDAP_INVALID_SYNTAX; } - if( mra->ma_rule == NULL ) - { - return LDAP_INAPPROPRIATE_MATCHING; - } - for(a = attrs_find( e->e_attrs, mra->ma_desc ); a != NULL; a = attrs_find( a->a_next, mra->ma_desc ) ) @@ -263,7 +270,7 @@ static int test_mra_filter( return rc; } - if ( ret ) { + if ( ret == 0 ) { return LDAP_COMPARE_TRUE; } } diff --git a/servers/slapd/schema_init.c b/servers/slapd/schema_init.c index ca94bbb14e..3b18558142 100644 --- a/servers/slapd/schema_init.c +++ b/servers/slapd/schema_init.c @@ -999,7 +999,9 @@ caseExactMatch( struct berval *value, void *assertedValue ) { - *matchp = UTF8bvnormcmp( value, (struct berval *) assertedValue, LDAP_UTF8_NOCASEFOLD ); + *matchp = UTF8bvnormcmp( value, + (struct berval *) assertedValue, + LDAP_UTF8_NOCASEFOLD ); return LDAP_SUCCESS; } @@ -1645,7 +1647,9 @@ caseIgnoreMatch( struct berval *value, void *assertedValue ) { - *matchp = UTF8bvnormcmp( value, (struct berval *) assertedValue, LDAP_UTF8_CASEFOLD ); + *matchp = UTF8bvnormcmp( value, + (struct berval *) assertedValue, + LDAP_UTF8_CASEFOLD ); return LDAP_SUCCESS; } -- 2.39.5