Commit 152829be authored by Kurt Zeilenga's avatar Kurt Zeilenga
Browse files

SLAP_NVALUES:

	schema engine updated (but not schema routines so things don't run yet)
	nvalues mostly populated, enough for tests 0-2 to pass
	schema routines needs lots of work
	modify/mods codes needs lots of work
parent dd687051
......@@ -889,8 +889,8 @@ dn_match_cleanup:;
at = attrs_find( at->a_next, b->a_dn_at ) )
{
if( value_find_ex( b->a_dn_at,
SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH, at->a_vals, &bv )
== 0 )
SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH,
at->a_vals, &bv ) == 0 )
{
/* found it */
match = 1;
......
......@@ -845,3 +845,25 @@ ad_find_option_definition( const char *opt, int optlen )
}
return NULL;
}
MatchingRule *ad_mr(
AttributeDescription *ad,
unsigned usage )
{
switch( usage & SLAP_MR_TYPE_MASK ) {
case SLAP_MR_NONE:
case SLAP_MR_EQUALITY:
return ad->ad_type->sat_equality;
break;
case SLAP_MR_ORDERING:
return ad->ad_type->sat_ordering;
break;
case SLAP_MR_SUBSTR:
return ad->ad_type->sat_substr;
break;
case SLAP_MR_EXT:
default:
assert( 0 /* ad_mr: bad usage */);
}
return NULL;
}
......@@ -485,6 +485,11 @@ at_add(
}
if ( sat->sat_ordering_oid ) {
if( !sat->sat_equality ) {
*err = sat->sat_ordering_oid;
return SLAP_SCHERR_ATTR_BAD_MR;
}
mr = mr_find(sat->sat_ordering_oid);
if( mr == NULL ) {
......@@ -520,6 +525,11 @@ at_add(
}
if ( sat->sat_substr_oid ) {
if( !sat->sat_equality ) {
*err = sat->sat_substr_oid;
return SLAP_SCHERR_ATTR_BAD_MR;
}
mr = mr_find(sat->sat_substr_oid);
if( mr == NULL ) {
......@@ -537,9 +547,7 @@ at_add(
* syntax and compat syntaxes instead of those
* associated with the substrings rule.
*/
if( sat->sat_equality &&
sat->sat_syntax != sat->sat_equality->smr_syntax )
{
if( sat->sat_syntax != sat->sat_equality->smr_syntax ) {
if( sat->sat_equality->smr_compat_syntaxes == NULL ) {
*err = sat->sat_substr_oid;
return SLAP_SCHERR_ATTR_BAD_MR;
......
......@@ -63,8 +63,14 @@ get_ava(
return rc;
}
#ifdef SLAP_NVALUES
rc = asserted_value_validate_normalize(
aa->aa_desc, ad_mr(aa->aa_desc, usage),
usage, &value, &aa->aa_value, text );
#else
rc = value_validate_normalize( aa->aa_desc, usage,
&value, &aa->aa_value, text );
#endif
if( rc != LDAP_SUCCESS ) {
ch_free( aa );
......
......@@ -125,7 +125,14 @@ dn2entry_retry:
{
rc = LDAP_COMPARE_FALSE;
if ( value_find( ava->aa_desc, a->a_vals, &ava->aa_value ) == 0 ) {
#ifdef SLAP_NVALUES
if ( value_find_ex( ava->aa_desc,
SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH,
a->a_vals, &ava->aa_value ) == 0 )
#else
if ( value_find( ava->aa_desc, a->a_vals, &ava->aa_value ) == 0 )
#endif
{
rc = LDAP_COMPARE_TRUE;
break;
}
......
......@@ -216,10 +216,7 @@ dn2entry_retry:
group_oc_name, group_at_name, 0 );
#endif
if( value_find_ex( group_at,
SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH,
attr->a_vals, op_ndn ) != LDAP_SUCCESS )
{
if( value_find_ex( group_at, 0, attr->a_vals, op_ndn ) != LDAP_SUCCESS ) {
#ifdef NEW_LOGGING
LDAP_LOG( BACK_BDB, DETAIL1,
"bdb_group: \"%s\" not in \"%s\": %s\n",
......
......@@ -1226,8 +1226,7 @@ bdb_build_lcup_update_ctrl(
ber_dupbv( latest_entrycsn_bv, &entrycsn_bv );
} else {
res = value_match( &ret, desc,
desc->ad_type->sat_ordering,
SLAP_MR_ASSERTION_SYNTAX_MATCH,
desc->ad_type->sat_ordering, 0,
&entrycsn_bv, latest_entrycsn_bv, &text );
if ( res != LDAP_SUCCESS ) {
ret = 0;
......@@ -1368,8 +1367,7 @@ bdb_build_sync_state_ctrl(
ber_dupbv( latest_entrycsn_bv, &entrycsn_bv );
} else {
res = value_match( &ret, desc,
desc->ad_type->sat_ordering,
SLAP_MR_ASSERTION_SYNTAX_MATCH,
desc->ad_type->sat_ordering, 0,
&entrycsn_bv, latest_entrycsn_bv, &text );
if ( res != LDAP_SUCCESS ) {
ret = 0;
......
......@@ -178,9 +178,7 @@ ldbm_back_group(
#endif
if( value_find_ex( group_at, SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH,
attr->a_vals, op_ndn ) != LDAP_SUCCESS )
{
if( value_find_ex( group_at, 0, attr->a_vals, op_ndn ) != LDAP_SUCCESS ) {
#ifdef NEW_LOGGING
LDAP_LOG( BACK_LDBM, DETAIL1,
"ldbm_back_group: \"%s\" not in \"%s\": %s\n",
......
......@@ -332,7 +332,11 @@ add_values( Entry *e, Modification *mod, int *newlevel )
for ( j = 0; a->a_vals[j].bv_val != NULL; j++ ) {
int match;
int rc = value_match( &match, mod->sm_desc, mr,
#ifdef SLAP_NVALUES
0,
#else
SLAP_MR_ATTRIBUTE_SYNTAX_MATCH,
#endif
&a->a_vals[j], &asserted, &text );
if ( rc == LDAP_SUCCESS && match == 0 ) {
......@@ -411,7 +415,11 @@ delete_values( Entry *e, Modification *mod, int *newlevel )
for ( j = 0; a->a_vals[j].bv_val != NULL; j++ ) {
int match;
int rc = value_match( &match, mod->sm_desc, mr,
#ifdef SLAP_NVALUES
0,
#else
SLAP_MR_ATTRIBUTE_SYNTAX_MATCH,
#endif
&a->a_vals[j], &asserted, &text );
if( rc == LDAP_SUCCESS && match != 0 ) {
......
......@@ -143,8 +143,15 @@ do_compare(
goto cleanup;
}
#ifdef SLAP_NVALUES
rc = asserted_value_validate_normalize( ava.aa_desc,
ava.aa_desc->ad_type->sat_equality,
SLAP_MR_EQUALITY|SLAP_MR_VALUE_OF_ASSERTION_SYNTAX,
&value, &ava.aa_value, &text );
#else
rc = value_validate_normalize( ava.aa_desc, SLAP_MR_EQUALITY,
&value, &ava.aa_value, &text );
#endif
if( rc != LDAP_SUCCESS ) {
send_ldap_result( conn, op, rc, NULL, text, NULL, NULL );
goto cleanup;
......@@ -347,7 +354,15 @@ static int compare_entry(
{
rc = LDAP_COMPARE_FALSE;
if ( value_find( ava->aa_desc, a->a_vals, &ava->aa_value ) == 0 ) {
#ifdef SLAP_NVALUES
if ( value_find_ex( ava->aa_desc,
SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH,
a->a_nvals ? a->a_nvals : a->a_vals,
&ava->aa_value ) == 0 )
#else
if ( value_find( ava->aa_desc, a->a_vals, &ava->aa_value ) == 0 )
#endif
{
rc = LDAP_COMPARE_TRUE;
break;
}
......
......@@ -241,8 +241,11 @@ LDAPDN_rewrite( LDAPDN *dn, unsigned flags )
LDAPAVA *ava = rdn[ 0 ][ iAVA ];
AttributeDescription *ad;
slap_syntax_validate_func *validf = NULL;
#ifdef SLAP_NVALUES
slap_mr_normalize_func *normf = NULL;
#endif
slap_syntax_transform_func *transf = NULL;
MatchingRule *mr;
MatchingRule *mr = NULL;
struct berval bv = { 0, NULL };
int do_sort = 0;
......@@ -267,17 +270,19 @@ LDAPDN_rewrite( LDAPDN *dn, unsigned flags )
if( ava->la_flags & LDAP_AVA_BINARY ) {
/* AVA is binary encoded, don't muck with it */
validf = NULL;
transf = NULL;
mr = NULL;
} else if( flags & SLAP_LDAPDN_PRETTY ) {
validf = NULL;
transf = ad->ad_type->sat_syntax->ssyn_pretty;
mr = NULL;
} else {
if( !transf ) {
validf = ad->ad_type->sat_syntax->ssyn_validate;
}
} else { /* normalization */
validf = ad->ad_type->sat_syntax->ssyn_validate;
transf = ad->ad_type->sat_syntax->ssyn_normalize;
mr = ad->ad_type->sat_equality;
#ifdef SLAP_NVALUES
if( mr ) normf = mr->smr_normalize;
#else
transf = ad->ad_type->sat_syntax->ssyn_normalize;
#endif
}
if ( validf ) {
......@@ -294,7 +299,11 @@ LDAPDN_rewrite( LDAPDN *dn, unsigned flags )
if ( transf ) {
/*
#ifdef SLAP_NVALUES
* transform value by pretty function
#else
* transform value by normalize/pretty function
#endif
* if value is empty, use empty_bv
*/
rc = ( *transf )( ad->ad_type->sat_syntax,
......@@ -308,6 +317,27 @@ LDAPDN_rewrite( LDAPDN *dn, unsigned flags )
}
}
#ifdef SLAP_NVALUES
if ( normf ) {
/*
* normalize value
* if value is empty, use empty_bv
*/
rc = ( *normf )(
0,
ad->ad_type->sat_syntax,
mr,
ava->la_value.bv_len
? &ava->la_value
: (struct berval *) &slap_empty_bv,
&bv );
if ( rc != LDAP_SUCCESS ) {
return LDAP_INVALID_SYNTAX;
}
}
#else
if( mr && ( mr->smr_usage & SLAP_MR_DN_FOLD ) ) {
char *s = bv.bv_val;
......@@ -317,6 +347,7 @@ LDAPDN_rewrite( LDAPDN *dn, unsigned flags )
}
free( s );
}
#endif
if( bv.bv_val ) {
free( ava->la_value.bv_val );
......
......@@ -244,20 +244,21 @@ str2entry( char *s )
nvals[0].bv_val = NULL;
if( ad->ad_type->sat_equality &&
ad->ad_type->sat_equality->smr_match &&
ad->ad_type->sat_syntax->ssyn_normalize )
ad->ad_type->sat_equality->smr_normalize )
{
rc = ad->ad_type->sat_syntax->ssyn_normalize(
rc = ad->ad_type->sat_equality->smr_normalize(
SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX,
ad->ad_type->sat_syntax,
ad->ad_type->sat_equality,
&vals[0], &nvals[0] );
if( rc ) {
#ifdef NEW_LOGGING
LDAP_LOG( OPERATION, DETAIL1,
"str2entry: NULL (ssyn_normalize %d)\n" , rc, 0, 0 );
"str2entry: NULL (smr_normalize %d)\n" , rc, 0, 0 );
#else
Debug( LDAP_DEBUG_ANY,
"<= str2entry NULL (ssyn_normalize %d)\n", rc, 0, 0 );
"<= str2entry NULL (smr_normalize %d)\n", rc, 0, 0 );
#endif
entry_free( e );
......@@ -683,24 +684,25 @@ int entry_decode(struct berval *bv, Entry **e)
#ifdef SLAP_NVALUES
if( count && ad->ad_type->sat_equality &&
ad->ad_type->sat_equality->smr_match &&
ad->ad_type->sat_syntax->ssyn_normalize )
ad->ad_type->sat_equality->smr_normalize )
{
a->a_nvals = ch_malloc((count+1)*sizeof(struct berval));
for(j=0; j<count; j++) {
rc = ad->ad_type->sat_syntax->ssyn_normalize(
rc = ad->ad_type->sat_equality->smr_normalize(
SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX,
ad->ad_type->sat_syntax,
ad->ad_type->sat_equality,
&a->a_vals[j], &a->a_nvals[j] );
if( rc ) {
#ifdef NEW_LOGGING
LDAP_LOG( OPERATION, DETAIL1,
"entry_decode: NULL (ssyn_normalize %d)\n",
"entry_decode: NULL (smr_normalize %d)\n",
rc, 0, 0 );
#else
Debug( LDAP_DEBUG_ANY,
"<= entry_decode NULL (ssyn_normalize %d)\n",
"<= entry_decode NULL (smr_normalize %d)\n",
rc, 0, 0 );
#endif
......
......@@ -414,6 +414,15 @@ get_substring_filter(
goto return_error;
}
#ifdef SLAP_NVALUES
/* validate using equality matching rule validator! */
rc = asserted_value_validate_normalize(
f->f_sub_desc, f->f_sub_desc->ad_type->sat_substr,
usage, &value, &bv, text );
if( rc != LDAP_SUCCESS ) {
goto return_error;
}
#else
/* validate using equality matching rule validator! */
rc = value_validate( f->f_sub_desc->ad_type->sat_equality,
&value, text );
......@@ -426,6 +435,7 @@ get_substring_filter(
if( rc != LDAP_SUCCESS ) {
goto return_error;
}
#endif
value = bv;
......@@ -1423,6 +1433,15 @@ get_substring_vrFilter(
goto return_error;
}
#ifdef SLAP_NVALUES
/* validate using equality matching rule validator! */
rc = asserted_value_validate_normalize(
vrf->vrf_sub_desc, vrf->vrf_sub_desc->ad_type->sat_substr,
usage, &value, &bv, text );
if( rc != LDAP_SUCCESS ) {
goto return_error;
}
#else
/* valiate using equality matching rule validator! */
rc = value_validate( vrf->vrf_sub_desc->ad_type->sat_equality,
&value, text );
......@@ -1435,6 +1454,7 @@ get_substring_vrFilter(
if( rc != LDAP_SUCCESS ) {
goto return_error;
}
#endif
value = bv;
......
......@@ -237,8 +237,7 @@ static int test_mra_filter(
int rc;
const char *text;
rc = value_match( &ret, a->a_desc, mra->ma_rule,
SLAP_MR_ASSERTION_SYNTAX_MATCH,
rc = value_match( &ret, a->a_desc, mra->ma_rule, 0,
bv, &mra->ma_value, &text );
if( rc != LDAP_SUCCESS ) {
......@@ -266,9 +265,15 @@ static int test_mra_filter(
}
/* normalize for equality */
#ifdef SLAP_NVALUES
rc = asserted_value_validate_normalize( a->a_desc, mra->ma_rule,
SLAP_MR_EXT|SLAP_MR_VALUE_OF_ASSERTION_SYNTAX,
&mra->ma_value, &value, &text );
#else
rc = value_validate_normalize( a->a_desc,
SLAP_MR_EQUALITY,
&mra->ma_value, &value, &text );
#endif
if ( rc != LDAP_SUCCESS ) {
continue;
}
......@@ -284,8 +289,7 @@ static int test_mra_filter(
int ret;
int rc;
rc = value_match( &ret, a->a_desc, mra->ma_rule,
SLAP_MR_ASSERTION_SYNTAX_MATCH,
rc = value_match( &ret, a->a_desc, mra->ma_rule, 0,
bv, &value, &text );
if( rc != LDAP_SUCCESS ) {
......@@ -341,8 +345,15 @@ static int test_mra_filter(
}
/* normalize for equality */
#ifdef SLAP_NVALUES
rc = asserted_value_validate_normalize( ad,
mra->ma_rule,
SLAP_MR_EXT|SLAP_MR_VALUE_OF_ASSERTION_SYNTAX,
&mra->ma_value, &value, &text );
#else
rc = value_validate_normalize( ad, SLAP_MR_EQUALITY,
&mra->ma_value, &value, &text );
#endif
if ( rc != LDAP_SUCCESS ) {
continue;
}
......@@ -355,8 +366,7 @@ static int test_mra_filter(
}
/* check match */
rc = value_match( &ret, ad, mra->ma_rule,
SLAP_MR_ASSERTION_SYNTAX_MATCH,
rc = value_match( &ret, ad, mra->ma_rule, 0,
bv, &value, &text );
if( rc != LDAP_SUCCESS ) {
......@@ -429,8 +439,7 @@ test_ava_filter(
int rc;
const char *text;
rc = value_match( &ret, a->a_desc, mr,
SLAP_MR_ASSERTION_SYNTAX_MATCH,
rc = value_match( &ret, a->a_desc, mr, 0,
bv, &ava->aa_value, &text );
if( rc != LDAP_SUCCESS ) {
......@@ -661,8 +670,7 @@ test_substrings_filter(
int rc;
const char *text;
rc = value_match( &ret, a->a_desc, mr,
SLAP_MR_ASSERTION_SYNTAX_MATCH,
rc = value_match( &ret, a->a_desc, mr, 0,
bv, f->f_sub, &text );
if( rc != LDAP_SUCCESS ) {
......
......@@ -240,8 +240,8 @@ test_ava_vrFilter(
int rc;
const char *text;
rc = value_match( &ret, a->a_desc, mr,
SLAP_MR_ASSERTION_SYNTAX_MATCH, bv, &ava->aa_value, &text );
rc = value_match( &ret, a->a_desc, mr, 0,
bv, &ava->aa_value, &text );
if( rc != LDAP_SUCCESS ) {
return rc;
}
......@@ -326,8 +326,7 @@ test_substrings_vrFilter(
int rc;
const char *text;
rc = value_match( &ret, a->a_desc, mr,
SLAP_MR_ASSERTION_SYNTAX_MATCH,
rc = value_match( &ret, a->a_desc, mr, 0,
bv, vrf->vrf_sub, &text );
if( rc != LDAP_SUCCESS ) {
......@@ -365,6 +364,7 @@ test_mra_vrFilter(
value = mra->ma_value;
} else {
int rc;
const char *text = NULL;
/* check if matching is appropriate */
......@@ -373,14 +373,19 @@ test_mra_vrFilter(
continue;
}
#ifdef SLAP_NVALUES
rc = asserted_value_validate_normalize( a->a_desc, mra->ma_rule,
SLAP_MR_EXT|SLAP_MR_VALUE_OF_ASSERTION_SYNTAX,
&mra->ma_value, &value, &text );
#else
/* normalize for equality */
if ( value_validate_normalize( a->a_desc,
rc = value_validate_normalize( a->a_desc,
SLAP_MR_EQUALITY,
&mra->ma_value, &value,
&text ) != LDAP_SUCCESS ) {
continue;
}
&text );
#endif
if( rc != LDAP_SUCCESS ) continue;
}
for ( bv = a->a_vals, j = 0; bv->bv_val != NULL; bv++, j++ ) {
......@@ -388,11 +393,8 @@ test_mra_vrFilter(
int rc;
const char *text;
rc = value_match( &ret, a->a_desc, mra->ma_rule,
SLAP_MR_ASSERTION_SYNTAX_MATCH,
bv, &value,
&text );
rc = value_match( &ret, a->a_desc, mra->ma_rule, 0,
bv, &value, &text );
if( rc != LDAP_SUCCESS ) {
return rc;
}
......
......@@ -609,13 +609,14 @@ int slap_mods_check(
#ifdef SLAP_NVALUES
if( nvals && ad->ad_type->sat_equality &&
ad->ad_type->sat_equality->smr_match &&
ad->ad_type->sat_syntax->ssyn_normalize )
ad->ad_type->sat_equality->smr_normalize )
{
ml->sml_nvalues = ch_malloc( (nvals+1)*sizeof(struct berval) );
for( nvals = 0; ml->sml_values[nvals].bv_val; nvals++ ) {
rc = ad->ad_type->sat_syntax->ssyn_normalize(
rc = ad->ad_type->sat_equality->smr_normalize(
0,
ad->ad_type->sat_syntax,
ad->ad_type->sat_equality,
&ml->sml_values[nvals], &ml->sml_nvalues[nvals] );
if( rc ) {
#ifdef NEW_LOGGING
......
......@@ -30,6 +30,9 @@ modify_check_duplicates(
{
int i, j, numvals = 0, nummods,
rc = LDAP_SUCCESS, matched;
#ifdef SLAP_NVALUES
/* needs major reworking */
#else
BerVarray nvals = NULL, nmods = NULL;
/*
......@@ -121,23 +124,24 @@ modify_check_duplicates(
goto return_results;
}
for ( i = 0; mods[ i ].bv_val != NULL; i++ ) {
for ( i=0; mods[i].bv_val != NULL; i++ ) {
rc = value_normalize( ad, SLAP_MR_EQUALITY,
&mods[ i ], &nmods[ i ], text );
&mods[i], &nmods[i], text );
if ( rc != LDAP_SUCCESS ) {
nmods[ i ].bv_val = NULL;
nmods[i].bv_val = NULL;
goto return_results;
}
if ( numvals > 0 && numvals < nummods ) {
for ( matched = 0, j = 0; nvals[ j ].bv_val; j++ ) {
for ( matched=0, j=0; nvals[j].bv_val; j++ ) {
int match;
rc = (*mr->smr_match)( &match,
SLAP_MR_ATTRIBUTE_SYNTAX_MATCH,
ad->ad_type->sat_syntax,
mr, &nmods[ i ], &nvals[ j ] );
if ( rc != LDAP_SUCCESS ) {
nmods[ i + 1 ].bv_val = NULL;
*text = textbuf;
......@@ -270,6 +274,7 @@ return_results:;
ber_bvarray_free( nmods );
}
#endif
return rc;
}
......@@ -324,8 +329,7 @@ modify_add_values(
/* test asserted values against existing values */
if( a ) {