mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-12-21 15:19:34 -05:00
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.
This commit is contained in:
parent
5c7a7998a9
commit
2ac7c91cae
14 changed files with 63 additions and 44 deletions
|
|
@ -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 );
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 );
|
||||
|
|
|
|||
|
|
@ -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 ) {
|
||||
|
|
|
|||
|
|
@ -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 );
|
||||
|
|
|
|||
|
|
@ -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 );
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 ) {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 );
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 );
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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 ) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue