From: Kurt Zeilenga Date: Mon, 29 May 2000 01:08:09 +0000 (+0000) Subject: SLAPD_SCHEMA_NOT_COMPAT: working tests 1-4! X-Git-Tag: LDBM_PRE_GIANT_RWLOCK~2815 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=287de3517ded79fa8d5f3c7c071b317589a164a8;p=openldap SLAPD_SCHEMA_NOT_COMPAT: working tests 1-4! --- diff --git a/servers/slapd/back-ldbm/modify.c b/servers/slapd/back-ldbm/modify.c index 613880ef55..7b47a71d90 100644 --- a/servers/slapd/back-ldbm/modify.c +++ b/servers/slapd/back-ldbm/modify.c @@ -358,17 +358,31 @@ add_values( if ( a != NULL ) { for ( i = 0; mod->sm_bvalues[i] != NULL; i++ ) { #ifdef SLAPD_SCHEMA_NOT_COMPAT + int rc; int j; + const char *text = NULL; + struct berval *asserted; + + rc = value_normalize( mod->sm_desc, + SLAP_MR_EQUALITY, + mod->sm_bvalues[i], + &asserted, + &text ); + + if( rc != LDAP_SUCCESS ) return rc; + for ( j = 0; a->a_vals[j] != NULL; j++ ) { int match; - const char *text = NULL; int rc = value_match( &match, mod->sm_desc, mr, - mod->sm_bvalues[i], a->a_vals[j], &text ); + a->a_vals[j], asserted, &text ); if( rc == LDAP_SUCCESS && match == 0 ) { + ber_bvfree( asserted ); return LDAP_TYPE_OR_VALUE_EXISTS; } } + + ber_bvfree( asserted ); #else if ( value_find( a->a_vals, mod->sm_bvalues[i], a->a_syntax, 3 ) == 0 ) { @@ -417,21 +431,35 @@ delete_values( /* delete specific values - find the attribute first */ if ( (a = attr_find( e->e_attrs, mod->sm_desc )) == NULL ) { - Debug( LDAP_DEBUG_ARGS, "could not find attribute %s\n", + Debug( LDAP_DEBUG_ARGS, "ldap_modify_delete: " + "could not find attribute %s\n", desc, 0, 0 ); return( LDAP_NO_SUCH_ATTRIBUTE ); } /* find each value to delete */ for ( i = 0; mod->sm_bvalues[i] != NULL; i++ ) { +#ifdef SLAPD_SCHEMA_NOT_COMPAT + int rc; + const char *text = NULL; + + struct berval *asserted; + + rc = value_normalize( mod->sm_desc, + SLAP_MR_EQUALITY, + mod->sm_bvalues[i], + &asserted, + &text ); + + if( rc != LDAP_SUCCESS ) return rc; +#endif + found = 0; for ( j = 0; a->a_vals[j] != NULL; j++ ) { #ifdef SLAPD_SCHEMA_NOT_COMPAT int match; - const char *text = NULL; - int rc = value_match( &match, mod->sm_desc, - mr, - mod->sm_bvalues[i], a->a_vals[j], &text ); + int rc = value_match( &match, mod->sm_desc, mr, + a->a_vals[j], asserted, &text ); if( rc == LDAP_SUCCESS && match != 0 ) #else @@ -456,6 +484,9 @@ delete_values( "removing entire attribute %s\n", desc, 0, 0 ); if ( attr_delete( &e->e_attrs, mod->sm_desc ) ) { +#ifdef SLAPD_SCHEMA_NOT_COMPAT + ber_bvfree( asserted ); +#endif return LDAP_NO_SUCH_ATTRIBUTE; } } @@ -463,10 +494,14 @@ delete_values( break; } +#ifdef SLAPD_SCHEMA_NOT_COMPAT + ber_bvfree( asserted ); +#endif + /* looked through them all w/o finding it */ if ( ! found ) { Debug( LDAP_DEBUG_ARGS, - "could not find value for attr %s\n", + "ldbm_modify_delete: could not find value for attr %s\n", desc, 0, 0 ); return LDAP_NO_SUCH_ATTRIBUTE; } diff --git a/servers/slapd/schema_init.c b/servers/slapd/schema_init.c index 79867ec929..d572a2c165 100644 --- a/servers/slapd/schema_init.c +++ b/servers/slapd/schema_init.c @@ -66,24 +66,31 @@ dnNormalize( static int dnMatch( - int *match, + int *matchp, unsigned use, Syntax *syntax, MatchingRule *mr, struct berval *value, void *assertedValue ) { + int match; struct berval *asserted = (struct berval *) assertedValue; - ber_slen_t diff; - - diff = value->bv_len - asserted->bv_len; - if( diff ) return diff; + match = value->bv_len - asserted->bv_len; + + if( match == 0 ) { #ifdef USE_DN_NORMALIZE - return strcmp( value->bv_val, asserted->bv_val ); + match = strcmp( value->bv_val, asserted->bv_val ); #else - return strcasecmp( value->bv_val, asserted->bv_val ); + match = strcasecmp( value->bv_val, asserted->bv_val ); #endif + } + + Debug( LDAP_DEBUG_ARGS, "dnMatch %d\n\t\"%s\"\n\t\"%s\"\n", + match, value->bv_val, asserted->bv_val ); + + *matchp = match; + return LDAP_SUCCESS; } static int