/* modify.c - ldbm backend modify routine */
/* $OpenLDAP$ */
/*
- * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
+ * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
*/
ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex );
/* check that the entry still obeys the schema */
- rc = entry_schema_check( e, save_attrs, text, textbuf, textlen );
+ rc = entry_schema_check( be, e, save_attrs, text, textbuf, textlen );
if ( rc != LDAP_SUCCESS ) {
attrs_free( e->e_attrs );
e->e_attrs = save_attrs;
/* acquire and lock entry */
- if ( (e = dn2entry_w( be, ndn->bv_val, &matched )) == NULL ) {
+ if ( (e = dn2entry_w( be, ndn, &matched )) == NULL ) {
char* matched_dn = NULL;
- struct berval **refs;
+ BVarray refs;
if ( matched != NULL ) {
matched_dn = ch_strdup( matched->e_dn );
refs = is_entry_referral( matched )
- ? get_entry_referrals( be, conn, op, matched,
- dn->bv_val, LDAP_SCOPE_DEFAULT )
+ ? get_entry_referrals( be, conn, op, matched )
: NULL;
cache_return_entry_r( &li->li_cache, matched );
} else {
refs = referral_rewrite( default_referral,
- NULL, dn->bv_val, LDAP_SCOPE_DEFAULT );
+ NULL, dn, LDAP_SCOPE_DEFAULT );
}
send_ldap_result( conn, op, LDAP_REFERRAL,
matched_dn, NULL, refs, NULL );
- ber_bvecfree( refs );
+ if ( refs ) bvarray_free( refs );
free( matched_dn );
return( -1 );
if ( !manageDSAit && is_entry_referral( e ) ) {
/* parent is a referral, don't allow add */
/* parent is an alias, don't allow add */
- struct berval **refs = get_entry_referrals( be,
- conn, op, e, dn->bv_val, LDAP_SCOPE_DEFAULT );
+ BVarray refs = get_entry_referrals( be,
+ conn, op, e );
#ifdef NEW_LOGGING
LDAP_LOG(( "backend", LDAP_LEVEL_INFO,
send_ldap_result( conn, op, LDAP_REFERRAL,
e->e_dn, NULL, refs, NULL );
- ber_bvecfree( refs );
+ if ( refs ) bvarray_free( refs );
goto error_return;
}
return LDAP_INAPPROPRIATE_MATCHING;
}
- for ( i = 0; mod->sm_bvalues[i] != NULL; i++ ) {
+ for ( i = 0; mod->sm_bvalues[i].bv_val != NULL; i++ ) {
int rc;
int j;
const char *text = NULL;
- struct berval *asserted = NULL;
+ struct berval asserted;
rc = value_normalize( mod->sm_desc,
SLAP_MR_EQUALITY,
- mod->sm_bvalues[i],
+ &mod->sm_bvalues[i],
&asserted,
&text );
if( rc != LDAP_SUCCESS ) return rc;
- for ( j = 0; a->a_vals[j] != NULL; j++ ) {
+ for ( j = 0; a->a_vals[j].bv_val != NULL; j++ ) {
int match;
int rc = value_match( &match, mod->sm_desc, mr,
SLAP_MR_VALUE_SYNTAX_MATCH,
- a->a_vals[j], asserted, &text );
+ &a->a_vals[j], &asserted, &text );
if( rc == LDAP_SUCCESS && match == 0 ) {
- ber_bvfree( asserted );
+ free( asserted.bv_val );
return LDAP_TYPE_OR_VALUE_EXISTS;
}
}
- ber_bvfree( asserted );
+ free( asserted.bv_val );
}
}
}
/* find each value to delete */
- for ( i = 0; mod->sm_bvalues[i] != NULL; i++ ) {
+ for ( i = 0; mod->sm_bvalues[i].bv_val != NULL; i++ ) {
int rc;
const char *text = NULL;
- struct berval *asserted = NULL;
+ struct berval asserted;
rc = value_normalize( mod->sm_desc,
SLAP_MR_EQUALITY,
- mod->sm_bvalues[i],
+ &mod->sm_bvalues[i],
&asserted,
&text );
if( rc != LDAP_SUCCESS ) return rc;
found = 0;
- for ( j = 0; a->a_vals[j] != NULL; j++ ) {
+ for ( j = 0; a->a_vals[j].bv_val != NULL; j++ ) {
int match;
int rc = value_match( &match, mod->sm_desc, mr,
SLAP_MR_VALUE_SYNTAX_MATCH,
- a->a_vals[j], asserted, &text );
+ &a->a_vals[j], &asserted, &text );
if( rc == LDAP_SUCCESS && match != 0 ) {
continue;
found = 1;
/* delete it */
- ber_bvfree( a->a_vals[j] );
- for ( k = j + 1; a->a_vals[k] != NULL; k++ ) {
+ free( a->a_vals[j].bv_val );
+ for ( k = j + 1; a->a_vals[k].bv_val != NULL; k++ ) {
a->a_vals[k - 1] = a->a_vals[k];
}
- a->a_vals[k - 1] = NULL;
+ a->a_vals[k - 1].bv_val = NULL;
break;
}
- ber_bvfree( asserted );
+ free( asserted.bv_val );
/* looked through them all w/o finding it */
if ( ! found ) {
}
/* if no values remain, delete the entire attribute */
- if ( a->a_vals[0] == NULL ) {
+ if ( a->a_vals[0].bv_val == NULL ) {
#ifdef NEW_LOGGING
LDAP_LOG(( "backend", LDAP_LEVEL_ENTRY,
"delete_values: removing entire attribute %s\n", desc ));