From f8dd082b741c25575a248dcf088bd336145f53fb Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Sat, 27 May 2000 21:41:04 +0000 Subject: [PATCH] SLAPD_SCHEMA_NOT_COMPAT: framework for substring searching --- servers/slapd/filterentry.c | 43 ++++++++++++++++++++++++++++++++----- servers/slapd/proto-slap.h | 2 +- servers/slapd/value.c | 4 ++-- 3 files changed, 41 insertions(+), 8 deletions(-) diff --git a/servers/slapd/filterentry.c b/servers/slapd/filterentry.c index fe4e1c1b54..a751cca054 100644 --- a/servers/slapd/filterentry.c +++ b/servers/slapd/filterentry.c @@ -501,27 +501,59 @@ test_substring_filter( Filter *f ) { -#ifndef SLAPD_SCHEMA_NOT_COMPAT Attribute *a; +#ifndef SLAPD_SCHEMA_NOT_COMPAT int i, rc; char *p, *end, *realval, *tmp; char pat[BUFSIZ]; char buf[BUFSIZ]; struct berval *val; regex_t re; +#endif Debug( LDAP_DEBUG_FILTER, "begin test_substring_filter\n", 0, 0, 0 ); if ( be != NULL && ! access_allowed( be, conn, op, e, - f->f_sub_type, NULL, ACL_SEARCH ) ) + f->f_sub_desc, NULL, ACL_SEARCH ) ) { return LDAP_INSUFFICIENT_ACCESS; } - if ( (a = attr_find( e->e_attrs, f->f_sub_type )) == NULL ) { - return LDAP_COMPARE_FALSE; - } +#ifdef SLAPD_SCHEMA_NOT_COMPAT + for(a = attrs_find( e->e_attrs, f->f_sub_desc ); + a != NULL; + a = attrs_find( a->a_next, f->f_sub_desc ) ) +#else + a = attr_find( e->e_attrs, f->f_sub_type ); + if ( a != NULL ) +#endif + { +#ifdef SLAPD_SCHEMA_NOT_COMPAT + int i; + MatchingRule *mr = a->a_desc->ad_type->sat_substr; + + if( mr == NULL ) { + continue; + } + + for ( i = 0; a->a_vals[i] != NULL; i++ ) { + int ret; + int rc; + const char *text; + + rc = value_match( &ret, a->a_desc, mr, + a->a_vals[i], f->f_sub, + &text ); + + if( rc != LDAP_SUCCESS ) { + return rc; + } + if ( ret == 0 ) { + return LDAP_COMPARE_TRUE; + } + } +#else if ( a->a_syntax & SYNTAX_BIN ) { Debug( LDAP_DEBUG_FILTER, "test_substring_filter bin attr\n", 0, 0, 0 ); @@ -616,6 +648,7 @@ test_substring_filter( regfree(&re); #endif + } Debug( LDAP_DEBUG_FILTER, "end test_substring_filter 1\n", 0, 0, 0 ); return LDAP_COMPARE_FALSE; diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index bf73fc435b..f6f6c76fa6 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -703,7 +703,7 @@ LIBSLAPD_F (int) value_match LDAP_P(( AttributeDescription *ad, MatchingRule *mr, struct berval *v1, - struct berval *v2, + void *v2, const char ** text )); LIBSLAPD_F (int) value_find LDAP_P(( AttributeDescription *ad, diff --git a/servers/slapd/value.c b/servers/slapd/value.c index b901414340..05af2ff085 100644 --- a/servers/slapd/value.c +++ b/servers/slapd/value.c @@ -190,8 +190,8 @@ value_match( int *match, AttributeDescription *ad, MatchingRule *mr, - struct berval *v1, /* (unnormalized) stored value */ - struct berval *v2, /* (normalized) asserted value */ + struct berval *v1, /* stored value */ + void *v2, /* assertion */ const char ** text ) { int rc; -- 2.39.5