From: Kurt Zeilenga Date: Tue, 27 Nov 2001 21:59:56 +0000 (+0000) Subject: Replace existing SLAP_MR_ matching flags with: X-Git-Tag: LDBM_PRE_GIANT_RWLOCK~828 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=2ac7c91cae12b29ba4201ed00dca41d889e7816b;p=openldap Replace existing SLAP_MR_ matching flags with: SLAP_MR_ASSERTION_SYNTAX_MATCH SLAP_MR_VALUE_SYNTAX_MATCH SLAP_MR_VALUE_SYNTAX_CONVERTED_MATCH, add supporting evaluation macros, and update code as needed. Misc other code cleanup included. --- diff --git a/servers/slapd/back-bdb/add.c b/servers/slapd/back-bdb/add.c index d562196879..fff5f65345 100644 --- a/servers/slapd/back-bdb/add.c +++ b/servers/slapd/back-bdb/add.c @@ -56,7 +56,7 @@ bdb_add( goto return_results; } - if (0) { + if( 0 ) { /* transaction retry */ retry: rc = txn_abort( ltid ); ltid = NULL; @@ -207,7 +207,8 @@ retry: rc = txn_abort( ltid ); p = NULL; if ( ! rc ) { - Debug( LDAP_DEBUG_TRACE, "bdb_add: no write access to parent\n", + Debug( LDAP_DEBUG_TRACE, + "bdb_add: no write access to parent\n", 0, 0, 0 ); rc = LDAP_INSUFFICIENT_ACCESS; text = "no write access to parent"; @@ -287,6 +288,7 @@ retry: rc = txn_abort( ltid ); db_strerror(rc), rc, 0 ); rc = LDAP_OTHER; text = "commit failed"; + } else { Debug( LDAP_DEBUG_TRACE, "bdb_add: added id=%08lx dn=\"%s\"\n", @@ -299,7 +301,7 @@ return_results: send_ldap_result( conn, op, rc, NULL, text, NULL, NULL ); - if(rc == LDAP_SUCCESS && bdb->bi_txn_cp ) { + if( rc == LDAP_SUCCESS && bdb->bi_txn_cp ) { ldap_pvt_thread_yield(); txn_checkpoint( bdb->bi_dbenv, bdb->bi_txn_cp_kbyte, bdb->bi_txn_cp_min, 0 ); diff --git a/servers/slapd/back-bdb/compare.c b/servers/slapd/back-bdb/compare.c index ef32a591c9..35e1508304 100644 --- a/servers/slapd/back-bdb/compare.c +++ b/servers/slapd/back-bdb/compare.c @@ -101,10 +101,7 @@ bdb_compare( { rc = LDAP_COMPARE_FALSE; - if ( value_find_ex( ava->aa_desc, - SLAP_MR_VALUE_IS_IN_MR_SYNTAX, - a->a_vals, ava->aa_value ) == 0 ) - { + if ( value_find( ava->aa_desc, a->a_vals, ava->aa_value ) == 0 ) { rc = LDAP_COMPARE_TRUE; break; } diff --git a/servers/slapd/back-bdb/delete.c b/servers/slapd/back-bdb/delete.c index 7cd603ef35..22e67f6f67 100644 --- a/servers/slapd/back-bdb/delete.c +++ b/servers/slapd/back-bdb/delete.c @@ -35,7 +35,7 @@ bdb_delete( Debug( LDAP_DEBUG_ARGS, "==> bdb_delete: %s\n", dn, 0, 0 ); - if (0) { + if( 0 ) { retry: /* transaction retry */ Debug( LDAP_DEBUG_TRACE, "==> bdb_delete: retrying...\n", 0, 0, 0 ); rc = txn_abort( ltid ); diff --git a/servers/slapd/back-bdb/modify.c b/servers/slapd/back-bdb/modify.c index d1612cd6a7..42869b59a7 100644 --- a/servers/slapd/back-bdb/modify.c +++ b/servers/slapd/back-bdb/modify.c @@ -173,7 +173,7 @@ bdb_modify( Debug( LDAP_DEBUG_ARGS, "bdb_modify: %s\n", dn, 0, 0 ); - if (0) { + if( 0 ) { retry: /* transaction retry */ Debug(LDAP_DEBUG_TRACE, "bdb_modify: retrying...\n", 0, 0, 0); @@ -314,6 +314,7 @@ retry: /* transaction retry */ db_strerror(rc), rc, 0 ); rc = LDAP_OTHER; text = "commit failed"; + } else { Debug( LDAP_DEBUG_TRACE, "bdb_modify: updated id=%08lx dn=\"%s\"\n", @@ -384,7 +385,7 @@ add_values( for ( j = 0; a->a_vals[j] != NULL; j++ ) { int match; int rc = value_match( &match, mod->sm_desc, mr, - SLAP_MR_MODIFY_MATCHING, + SLAP_MR_VALUE_SYNTAX_MATCH, a->a_vals[j], asserted, &text ); if( rc == LDAP_SUCCESS && match == 0 ) { @@ -460,7 +461,7 @@ delete_values( for ( j = 0; a->a_vals[j] != NULL; j++ ) { int match; int rc = value_match( &match, mod->sm_desc, mr, - SLAP_MR_MODIFY_MATCHING, + SLAP_MR_VALUE_SYNTAX_MATCH, a->a_vals[j], asserted, &text ); if( rc == LDAP_SUCCESS && match != 0 ) { diff --git a/servers/slapd/back-bdb/modrdn.c b/servers/slapd/back-bdb/modrdn.c index 260b917d99..6742f71b46 100644 --- a/servers/slapd/back-bdb/modrdn.c +++ b/servers/slapd/back-bdb/modrdn.c @@ -68,7 +68,7 @@ bdb_modrdn( } #endif - if (0) { + if( 0 ) { retry: /* transaction retry */ Debug( LDAP_DEBUG_TRACE, "==>bdb_modrdn: retrying...\n", 0, 0, 0 ); rc = txn_abort( ltid ); @@ -81,7 +81,6 @@ retry: /* transaction retry */ } } - if( bdb->bi_txn ) { /* begin transaction */ rc = txn_begin( bdb->bi_dbenv, NULL, <id, 0 ); diff --git a/servers/slapd/back-bdb/passwd.c b/servers/slapd/back-bdb/passwd.c index 48be3bbf4e..96ea8dc6e3 100644 --- a/servers/slapd/back-bdb/passwd.c +++ b/servers/slapd/back-bdb/passwd.c @@ -84,7 +84,7 @@ bdb_exop_passwd( goto done; } - if (0) { + if( 0 ) { retry: /* transaction retry */ Debug( LDAP_DEBUG_TRACE, "bdb_exop_passwd: retrying...\n", 0, 0, 0 ); rc = txn_abort( ltid ); diff --git a/servers/slapd/back-ldbm/compare.c b/servers/slapd/back-ldbm/compare.c index 4134bb115f..3a7245ec7e 100644 --- a/servers/slapd/back-ldbm/compare.c +++ b/servers/slapd/back-ldbm/compare.c @@ -99,10 +99,7 @@ ldbm_back_compare( { rc = LDAP_COMPARE_FALSE; - if ( value_find_ex( ava->aa_desc, - SLAP_MR_VALUE_IS_IN_MR_SYNTAX, - a->a_vals, ava->aa_value ) == 0 ) - { + if ( value_find( ava->aa_desc, a->a_vals, ava->aa_value ) == 0 ) { rc = LDAP_COMPARE_TRUE; break; } diff --git a/servers/slapd/back-ldbm/modify.c b/servers/slapd/back-ldbm/modify.c index 37fb844dd9..5f771dbc81 100644 --- a/servers/slapd/back-ldbm/modify.c +++ b/servers/slapd/back-ldbm/modify.c @@ -387,7 +387,7 @@ add_values( for ( j = 0; a->a_vals[j] != NULL; j++ ) { int match; int rc = value_match( &match, mod->sm_desc, mr, - SLAP_MR_MODIFY_MATCHING, + SLAP_MR_VALUE_SYNTAX_MATCH, a->a_vals[j], asserted, &text ); if( rc == LDAP_SUCCESS && match == 0 ) { @@ -474,7 +474,7 @@ delete_values( for ( j = 0; a->a_vals[j] != NULL; j++ ) { int match; int rc = value_match( &match, mod->sm_desc, mr, - SLAP_MR_MODIFY_MATCHING, + SLAP_MR_VALUE_SYNTAX_MATCH, a->a_vals[j], asserted, &text ); if( rc == LDAP_SUCCESS && match != 0 ) { diff --git a/servers/slapd/compare.c b/servers/slapd/compare.c index 693eba8e09..6c24393c00 100644 --- a/servers/slapd/compare.c +++ b/servers/slapd/compare.c @@ -302,10 +302,7 @@ static int compare_entry( { rc = LDAP_COMPARE_FALSE; - if ( value_find_ex( ava->aa_desc, - SLAP_MR_VALUE_IS_IN_MR_SYNTAX, - a->a_vals, ava->aa_value ) == 0 ) - { + if ( value_find( ava->aa_desc, a->a_vals, ava->aa_value ) == 0 ) { rc = LDAP_COMPARE_TRUE; break; } diff --git a/servers/slapd/filterentry.c b/servers/slapd/filterentry.c index 3f5ec48ab9..43fd3e84c9 100644 --- a/servers/slapd/filterentry.c +++ b/servers/slapd/filterentry.c @@ -255,7 +255,7 @@ static int test_mra_filter( const char *text; rc = value_match( &ret, a->a_desc, mra->ma_rule, - SLAP_MR_VALUE_IS_IN_MR_SYNTAX, + SLAP_MR_ASSERTION_SYNTAX_MATCH, a->a_vals[i], mra->ma_value, &text ); @@ -327,7 +327,7 @@ test_ava_filter( const char *text; rc = value_match( &ret, a->a_desc, mr, - SLAP_MR_VALUE_IS_IN_MR_SYNTAX, + SLAP_MR_ASSERTION_SYNTAX_MATCH, a->a_vals[i], ava->aa_value, &text ); @@ -514,7 +514,7 @@ test_substrings_filter( const char *text; rc = value_match( &ret, a->a_desc, mr, - SLAP_MR_VALUE_IS_IN_MR_SYNTAX, + SLAP_MR_ASSERTION_SYNTAX_MATCH, a->a_vals[i], f->f_sub, &text ); diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index ab0999850e..3a836707ed 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -783,13 +783,15 @@ LDAP_SLAPD_F (int) value_match LDAP_P(( struct berval *v1, void *v2, const char ** text )); +#define value_find(ad,values,value) (value_find_ex((ad),0,(values),(value))) LDAP_SLAPD_F (int) value_find_ex LDAP_P(( AttributeDescription *ad, unsigned flags, struct berval **values, struct berval *value )); -#define value_find(ad, values, value) ( value_find_ex(ad,0,values,value ) ) -LDAP_SLAPD_F (int) value_add LDAP_P(( struct berval ***vals, struct berval **addvals )); +LDAP_SLAPD_F (int) value_add LDAP_P(( + struct berval ***vals, + struct berval **addvals )); /* * user.c diff --git a/servers/slapd/schema_prep.c b/servers/slapd/schema_prep.c index 9ae8843b22..e34914c15b 100644 --- a/servers/slapd/schema_prep.c +++ b/servers/slapd/schema_prep.c @@ -53,7 +53,7 @@ objectClassMatch( return SLAPD_COMPARE_UNDEFINED; } - if( flags & SLAP_MR_MODIFY_MATCHING ) { + if( SLAP_IS_MR_VALUE_SYNTAX_MATCH( flags ) ) { *matchp = ( asserted != oc ); } else { *matchp = !is_object_subclass( asserted, oc ); diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index 84649445e2..29b3c0ced3 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -343,10 +343,28 @@ typedef struct slap_matching_rule { #define SLAP_MR_SUBSTR_ANY ( SLAP_MR_SUBSTR | 0x0020U ) #define SLAP_MR_SUBSTR_FINAL ( SLAP_MR_SUBSTR | 0x0040U ) -/* this is used to kludge objectClass testing */ -#define SLAP_MR_MODIFY_MATCHING 0x0001U -/* are we matching from a mr asserted value or a real value */ -#define SLAP_MR_VALUE_IS_IN_MR_SYNTAX 0x0002U +/* + * normally the provided value is expected to conform to + * assertion syntax specified in the matching rule, however + * at times (such as during individual value modification), + * the provided value is expected to conform to the + * attribute's value syntax. + */ +#define SLAP_MR_ASSERTION_SYNTAX_MATCH 0x0000U +#define SLAP_MR_VALUE_SYNTAX_MATCH 0x0001U +#define SLAP_MR_VALUE_SYNTAX_CONVERTED_MATCH 0x0003U + +#define SLAP_IS_MR_ASSERTION_SYNTAX_MATCH( usage ) \ + (!((usage) & SLAP_MR_VALUE_SYNTAX_MATCH)) +#define SLAP_IS_MR_VALUE_SYNTAX_MATCH( usage ) \ + ((usage) & SLAP_MR_VALUE_SYNTAX_MATCH) + +#define SLAP_IS_MR_VALUE_SYNTAX_CONVERTED_MATCH( usage ) \ + (((usage) & SLAP_MR_VALUE_SYNTAX_CONVERTED_MATCH) \ + == SLAP_MR_VALUE_SYNTAX_CONVERTED_MATCH) +#define SLAP_IS_MR_VALUE_SYNTAX_NONCONVERTED_MATCH( usage ) \ + (((usage) & SLAP_MR_VALUE_SYNTAX_CONVERTED_MATCH) \ + == SLAP_MR_VALUE_SYNTAX_MATCH) Syntax *smr_syntax; slap_mr_convert_func *smr_convert; diff --git a/servers/slapd/value.c b/servers/slapd/value.c index c73807cebf..88768204bd 100644 --- a/servers/slapd/value.c +++ b/servers/slapd/value.c @@ -148,12 +148,16 @@ value_match( } } - if ( !(flags & SLAP_MR_VALUE_IS_IN_MR_SYNTAX) && - mr->smr_convert ) { - rc = (mr->smr_convert)(v2,&nv2); + if ( SLAP_IS_MR_VALUE_SYNTAX_NONCONVERTED_MATCH( flags ) && + mr->smr_convert ) + { + rc = (mr->smr_convert)( v2, &nv2 ); if ( rc != LDAP_SUCCESS ) { - return LDAP_INVALID_SYNTAX; + return LDAP_INVALID_SYNTAX; } + + /* let smr_match know we've converted the value */ + flags |= SLAP_MR_VALUE_SYNTAX_CONVERTED_MATCH; } rc = (mr->smr_match)( match, flags, @@ -185,12 +189,16 @@ int value_find_ex( } /* Take care of this here or ssyn_normalize later will hurt */ - if ( !(flags & SLAP_MR_VALUE_IS_IN_MR_SYNTAX) && - mr->smr_convert ) { - rc = (mr->smr_convert)(val,&nval); + if ( SLAP_IS_MR_VALUE_SYNTAX_NONCONVERTED_MATCH( flags ) + && mr->smr_convert ) + { + rc = (mr->smr_convert)( val, &nval ); if ( rc != LDAP_SUCCESS ) { return LDAP_INVALID_SYNTAX; } + + /* let value_match know we've done the version */ + flags |= SLAP_MR_VALUE_SYNTAX_CONVERTED_MATCH; } if( mr->smr_syntax->ssyn_normalize ) { @@ -209,9 +217,7 @@ int value_find_ex( int match; const char *text; - /* We did convert, so keep value_match from trying */ - rc = value_match( &match, ad, mr, - flags & !SLAP_MR_VALUE_IS_IN_MR_SYNTAX, + rc = value_match( &match, ad, mr, flags, vals[i], nval == NULL ? val : nval, &text ); if( rc == LDAP_SUCCESS && match == 0 ) {