From: Kurt Zeilenga Date: Wed, 17 May 2000 20:08:13 +0000 (+0000) Subject: SLAP_SCHEMA_NOT_COMPAT: add calls to dummy value_normalize() X-Git-Tag: LDBM_PRE_GIANT_RWLOCK~2926 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=1f22c52b8ac8ad6e4a78b90b7473baebf86fcbd7;p=openldap SLAP_SCHEMA_NOT_COMPAT: add calls to dummy value_normalize() SLAP_SCHEMA_NOT_COMPAT: Need to sort out normalization of substring components --- diff --git a/servers/slapd/ava.c b/servers/slapd/ava.c index 6b11ba04a8..35fba72bfd 100644 --- a/servers/slapd/ava.c +++ b/servers/slapd/ava.c @@ -33,6 +33,7 @@ int get_ava( BerElement *ber, AttributeAssertion **ava, + unsigned usage, char **text ) { @@ -60,6 +61,16 @@ get_ava( return rc; } + rc = value_normalize( aa->aa_desc, usage, value, text ); + + if( rc != LDAP_SUCCESS ) { + ch_free( type.bv_val ); + ber_bvfree( value ); + ad_free( aa->aa_desc, 1 ); + ch_free( aa ); + return rc; + } + aa->aa_value = value; *ava = aa; diff --git a/servers/slapd/compare.c b/servers/slapd/compare.c index 86a7d9bdc9..4e228a618c 100644 --- a/servers/slapd/compare.c +++ b/servers/slapd/compare.c @@ -105,6 +105,15 @@ do_compare( text, NULL, NULL ); goto cleanup; } + + rc = value_normalize( ava.aa_desc, SLAP_MR_EQUALITY, &value, &text ); + + if( rc != LDAP_SUCCESS ) { + send_ldap_result( conn, op, rc, NULL, + text, NULL, NULL ); + goto cleanup; + } + ava.aa_value = &value; Debug( LDAP_DEBUG_ARGS, "do_compare: dn (%s) attr (%s) value (%s)\n", diff --git a/servers/slapd/filter.c b/servers/slapd/filter.c index 02817d2442..fac3aee18d 100644 --- a/servers/slapd/filter.c +++ b/servers/slapd/filter.c @@ -94,11 +94,15 @@ get_filter( case LDAP_FILTER_EQUALITY: Debug( LDAP_DEBUG_FILTER, "EQUALITY\n", 0, 0, 0 ); - if ( (err = get_ava( ber, &f->f_ava, text )) != LDAP_SUCCESS ) { +#ifdef SLAPD_SCHEMA_NOT_COMPAT + err = get_ava( ber, &f->f_ava, SLAP_MR_EQUALITY, text ); +#else + err = get_ava( ber, &f->f_ava, text ); +#endif + if ( err != LDAP_SUCCESS ) { break; } - #ifdef SLAPD_SCHEMA_NOT_COMPAT assert( f->f_ava != NULL ); @@ -127,7 +131,12 @@ get_filter( case LDAP_FILTER_GE: Debug( LDAP_DEBUG_FILTER, "GE\n", 0, 0, 0 ); - if ( (err = get_ava( ber, &f->f_ava, text )) != LDAP_SUCCESS ) { +#ifdef SLAPD_SCHEMA_NOT_COMPAT + err = get_ava( ber, &f->f_ava, SLAP_MR_ORDERING, text ); +#else + err = get_ava( ber, &f->f_ava, text ); +#endif + if ( err != LDAP_SUCCESS ) { break; } @@ -152,10 +161,16 @@ get_filter( case LDAP_FILTER_LE: Debug( LDAP_DEBUG_FILTER, "LE\n", 0, 0, 0 ); - if ( (err = get_ava( ber, &f->f_ava, text )) != LDAP_SUCCESS ) { +#ifdef SLAPD_SCHEMA_NOT_COMPAT + err = get_ava( ber, &f->f_ava, SLAP_MR_ORDERING, text ); +#else + err = get_ava( ber, &f->f_ava, text ); +#endif + if ( err != LDAP_SUCCESS ) { break; } + #ifdef SLAPD_SCHEMA_NOT_COMPAT *fstr = ch_malloc( sizeof("(<=)") + f->f_av_desc->ad_cname->bv_len @@ -214,7 +229,12 @@ get_filter( case LDAP_FILTER_APPROX: Debug( LDAP_DEBUG_FILTER, "APPROX\n", 0, 0, 0 ); - if ( (err = get_ava( ber, &f->f_ava, text )) != LDAP_SUCCESS ) { +#ifdef SLAPD_SCHEMA_NOT_COMPAT + err = get_ava( ber, &f->f_ava, SLAP_MR_APPROX, text ); +#else + err = get_ava( ber, &f->f_ava, text ); +#endif + if ( err != LDAP_SUCCESS ) { break; } diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index 7acb5aedcb..8c01755157 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -112,10 +112,6 @@ LIBSLAPD_F (char *) at_canonical_name LDAP_P(( const char * a_type )); LIBSLAPD_F (void) attr_free LDAP_P(( Attribute *a )); LIBSLAPD_F (Attribute *) attr_dup LDAP_P(( Attribute *a )); -LIBSLAPD_F (char *) attr_normalize LDAP_P(( char *s )); -LIBSLAPD_F (int) attr_merge_fast LDAP_P(( Entry *e, const char *type, - struct berval **vals, int nvals, int naddvals, int *maxvals, - Attribute ***a )); #ifdef SLAPD_SCHEMA_NOT_COMPAT LIBSLAPD_F (int) attr_merge LDAP_P(( Entry *e, @@ -125,8 +121,12 @@ LIBSLAPD_F (Attribute *) attrs_find LDAP_P(( Attribute *a, AttributeDescription LIBSLAPD_F (Attribute *) attr_find LDAP_P(( Attribute *a, AttributeDescription *desc )); LIBSLAPD_F (int) attr_delete LDAP_P(( Attribute **attrs, AttributeDescription *desc )); #else +LIBSLAPD_F (char *) attr_normalize LDAP_P(( char *s )); LIBSLAPD_F (int) attr_merge LDAP_P(( Entry *e, const char *type, struct berval **vals )); +LIBSLAPD_F (int) attr_merge_fast LDAP_P(( Entry *e, const char *type, + struct berval **vals, int nvals, int naddvals, int *maxvals, + Attribute ***a )); LIBSLAPD_F (Attribute *) attr_find LDAP_P(( Attribute *a, const char *type )); LIBSLAPD_F (int) attr_delete LDAP_P(( Attribute **attrs, const char *type )); LIBSLAPD_F (int) attr_syntax LDAP_P(( const char *type )); @@ -143,6 +143,7 @@ LIBSLAPD_F (Attribute *) attrs_dup LDAP_P(( Attribute *a )); LIBSLAPD_F (int) get_ava LDAP_P(( BerElement *ber, AttributeAssertion **ava, + unsigned usage, char **text )); LIBSLAPD_F (void) ava_free LDAP_P(( AttributeAssertion *ava, @@ -662,11 +663,19 @@ LIBSLAPD_F (char *) suffix_alias LDAP_P(( Backend *be, char *ndn )); * value.c */ +#ifdef SLAPD_SCHEMA_NOT_COMPAT +LIBSLAPD_F (int) value_normalize LDAP_P(( + AttributeDescription *ad, + unsigned usage, + struct berval *val, + char ** text )); +#else LIBSLAPD_F (int) value_add_fast LDAP_P(( struct berval ***vals, struct berval **addvals, int nvals, int naddvals, int *maxvals )); LIBSLAPD_F (int) value_add LDAP_P(( struct berval ***vals, struct berval **addvals )); LIBSLAPD_F (void) value_normalize LDAP_P(( char *s, int syntax )); LIBSLAPD_F (int) value_cmp LDAP_P(( struct berval *v1, struct berval *v2, int syntax, int normalize )); LIBSLAPD_F (int) value_find LDAP_P(( struct berval **vals, struct berval *v, int syntax, int normalize )); +#endif /* * user.c diff --git a/servers/slapd/value.c b/servers/slapd/value.c index 40b5612c99..cc42578a64 100644 --- a/servers/slapd/value.c +++ b/servers/slapd/value.c @@ -18,6 +18,42 @@ #include "slap.h" +int +value_add( + struct berval ***vals, + struct berval **addvals +) +{ + int n, nn, i, j; + + for ( nn = 0; addvals != NULL && addvals[nn] != NULL; nn++ ) + ; /* NULL */ + + if ( *vals == NULL ) { + *vals = (struct berval **) ch_malloc( (nn + 1) + * sizeof(struct berval *) ); + n = 0; + } else { + for ( n = 0; (*vals)[n] != NULL; n++ ) + ; /* NULL */ + *vals = (struct berval **) ch_realloc( (char *) *vals, + (n + nn + 1) * sizeof(struct berval *) ); + } + + for ( i = 0, j = 0; i < nn; i++ ) { + if ( addvals[i]->bv_len > 0 ) { + (*vals)[n + j] = ber_bvdup( addvals[i] ); + if( (*vals)[n + j++] == NULL ) break; + } + } + (*vals)[n + j] = NULL; + + return( 0 ); +} + +#ifdef SLAPD_SCHEMA_NOT_COMPAT + /* not yet implemented */ +#else int value_add_fast( struct berval ***vals, @@ -49,42 +85,20 @@ value_add_fast( return( 0 ); } +#endif +#ifdef SLAPD_SCHEMA_NOT_COMPAT int -value_add( - struct berval ***vals, - struct berval **addvals -) +value_normalize( + AttributeDescription *ad, + unsigned usage, + struct berval *val, + char **text ) { - int n, nn, i, j; - - for ( nn = 0; addvals != NULL && addvals[nn] != NULL; nn++ ) - ; /* NULL */ - - if ( *vals == NULL ) { - *vals = (struct berval **) ch_malloc( (nn + 1) - * sizeof(struct berval *) ); - n = 0; - } else { - for ( n = 0; (*vals)[n] != NULL; n++ ) - ; /* NULL */ - *vals = (struct berval **) ch_realloc( (char *) *vals, - (n + nn + 1) * sizeof(struct berval *) ); - } - - for ( i = 0, j = 0; i < nn; i++ ) { - if ( addvals[i]->bv_len > 0 ) { - (*vals)[n + j] = ber_bvdup( addvals[i] ); - if( (*vals)[n + j++] == NULL ) break; - } - } - (*vals)[n + j] = NULL; - - return( 0 ); + /* not yet implemented */ + return LDAP_SUCCESS; } -#ifdef SLAPD_SCHEMA_NOT_COMPAT - /* not yet implemented */ #else void value_normalize( @@ -112,7 +126,11 @@ value_normalize( } *d = '\0'; } +#endif +#ifdef SLAPD_SCHEMA_NOT_COMPAT + /* not yet implemented */ +#else int value_cmp( struct berval *v1,