X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Fback-bdb%2Fmodify.c;h=66df842a08a2cf8ebd0dbfdfa8fb2c96e8ded43f;hb=2c94c7915a52f8df4323c8193ec424df568f0fc1;hp=452aff29ec43882560ffd730ca16f4b5f92e3737;hpb=ac1332cdb868b6a30f545796aca8e0bbf13fe939;p=openldap diff --git a/servers/slapd/back-bdb/modify.c b/servers/slapd/back-bdb/modify.c index 452aff29ec..66df842a08 100644 --- a/servers/slapd/back-bdb/modify.c +++ b/servers/slapd/back-bdb/modify.c @@ -117,6 +117,11 @@ int bdb_modify_internal( return err; } + /* If objectClass was modified, reset the flags */ + if ( mod->sm_desc == slap_schema.si_ad_objectClass ) { + e->e_ocflags = 0; + } + /* check if modified attribute was indexed */ err = bdb_index_is_indexed( be, mod->sm_desc ); if ( err == LDAP_SUCCESS ) { @@ -212,6 +217,7 @@ retry: /* transaction retry */ text = "internal error"; goto return_results; } + ldap_pvt_thread_yield(); } if( bdb->bi_txn ) { @@ -379,7 +385,7 @@ add_values( char *dn ) { - int i; + int i, j; Attribute *a; /* char *desc = mod->sm_desc->ad_cname.bv_val; */ @@ -388,16 +394,42 @@ add_values( a = attr_find( e->e_attrs, mod->sm_desc ); /* check if the values we're adding already exist */ - if ( a != NULL ) { - if( mr == NULL || !mr->smr_match ) { + if( mr == NULL || !mr->smr_match ) { + if ( a != NULL ) { /* do not allow add of additional attribute if no equality rule exists */ return LDAP_INAPPROPRIATE_MATCHING; } for ( i = 0; mod->sm_bvalues[i].bv_val != NULL; i++ ) { - int rc; - int j; + /* test asserted values against existing values */ + if( a ) { + for( j = 0; a->a_vals[j].bv_val != NULL; j++ ) { + int rc = ber_bvcmp( &mod->sm_bvalues[i], + &a->a_vals[j] ); + + if( rc == 0 ) { + /* value exists already */ + return LDAP_TYPE_OR_VALUE_EXISTS; + } + } + } + + /* test asserted values against themselves */ + for( j = 0; j < i; j++ ) { + int rc = ber_bvcmp( &mod->sm_bvalues[i], + &mod->sm_bvalues[j] ); + + if( rc == 0 ) { + /* value exists already */ + return LDAP_TYPE_OR_VALUE_EXISTS; + } + } + } + + } else { + for ( i = 0; mod->sm_bvalues[i].bv_val != NULL; i++ ) { + int rc, match; const char *text = NULL; struct berval asserted; @@ -409,11 +441,23 @@ add_values( if( rc != LDAP_SUCCESS ) return rc; - for ( j = 0; a->a_vals[j].bv_val != NULL; j++ ) { - int match; + if( a ) { + for ( j = 0; a->a_vals[j].bv_val != NULL; j++ ) { + int rc = value_match( &match, mod->sm_desc, mr, + SLAP_MR_VALUE_SYNTAX_MATCH, + &a->a_vals[j], &asserted, &text ); + + if( rc == LDAP_SUCCESS && match == 0 ) { + free( asserted.bv_val ); + return LDAP_TYPE_OR_VALUE_EXISTS; + } + } + } + + for ( j = 0; j < i; j++ ) { int rc = value_match( &match, mod->sm_desc, mr, SLAP_MR_VALUE_SYNTAX_MATCH, - &a->a_vals[j], &asserted, &text ); + &mod->sm_bvalues[j], &asserted, &text ); if( rc == LDAP_SUCCESS && match == 0 ) { free( asserted.bv_val ); @@ -540,16 +584,10 @@ replace_values( char *dn ) { - int rc = attr_delete( &e->e_attrs, mod->sm_desc ); + (void) attr_delete( &e->e_attrs, mod->sm_desc ); - if( rc != LDAP_SUCCESS && rc != LDAP_NO_SUCH_ATTRIBUTE ) { - return rc; - } - - if ( mod->sm_bvalues != NULL && - attr_merge( e, mod->sm_desc, mod->sm_bvalues ) != 0 ) - { - return LDAP_OTHER; + if ( mod->sm_bvalues ) { + return add_values( e, mod, dn ); } return LDAP_SUCCESS;