/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
- * Copyright 2002-2005 The OpenLDAP Foundation.
+ * Copyright 2002-2007 The OpenLDAP Foundation.
* Portions Copyright 1997,2002-2003 IBM Corporation.
* All rights reserved.
*
Slapi_Entry *
slapi_entry_alloc( void )
{
- return (Slapi_Entry *)slapi_ch_calloc( 1, sizeof(Slapi_Entry) );
+ return (Slapi_Entry *)entry_alloc();
}
void
struct berval *
slapi_ch_bvdup(const struct berval *v)
{
- struct berval *bv;
-
- bv = (struct berval *) slapi_ch_malloc( sizeof(struct berval) );
- bv->bv_len = v->bv_len;
- bv->bv_val = slapi_ch_malloc( bv->bv_len );
- AC_MEMCPY( bv->bv_val, v->bv_val, bv->bv_len );
-
- return bv;
+ return ber_dupbv(NULL, (struct berval *)v);
}
struct berval **
} else {
if ( pb->pb_op->o_tag == LDAP_REQ_SEARCH )
rs->sr_nentries = nentries;
+ if ( urls != NULL )
+ bvptr2obj( urls, &rs->sr_ref );
send_ldap_result( pb->pb_op, rs );
+
+ if ( urls != NULL )
+ slapi_ch_free( (void **)&rs->sr_ref );
}
}
int attrsonly )
{
SlapReply rs = { REP_SEARCH };
- int i = 0;
+ int i = 0, j = 0;
AttributeName *an = NULL;
const char *text;
int rc;
}
if ( i ) {
- an = (AttributeName *) slapi_ch_malloc( (i+1) * sizeof(AttributeName) );
+ an = (AttributeName *) slapi_ch_calloc( i + 1, sizeof(AttributeName) );
for ( i = 0; attrs[i] != NULL; i++ ) {
- an[i].an_name.bv_val = attrs[i];
- an[i].an_name.bv_len = strlen( attrs[i] );
- an[i].an_desc = NULL;
- rs.sr_err = slap_bv2ad( &an[i].an_name, &an[i].an_desc, &text );
- if ( rs.sr_err != LDAP_SUCCESS) {
- slapi_ch_free( (void **)&an );
- return -1;
+ an[j].an_name.bv_val = attrs[i];
+ an[j].an_name.bv_len = strlen( attrs[i] );
+ an[j].an_desc = NULL;
+ if ( slap_bv2ad( &an[j].an_name, &an[j].an_desc, &text ) == LDAP_SUCCESS) {
+ j++;
}
}
- an[i].an_name.bv_len = 0;
- an[i].an_name.bv_val = NULL;
+ an[j].an_name.bv_len = 0;
+ an[j].an_name.bv_val = NULL;
}
rs.sr_err = LDAP_SUCCESS;
Slapi_Filter *
slapi_filter_dup( Slapi_Filter *filter )
{
- Filter *f;
-
- f = (Filter *) slapi_ch_malloc( sizeof(Filter) );
- f->f_next = NULL;
- f->f_choice = filter->f_choice;
-
- switch ( f->f_choice ) {
- case LDAP_FILTER_AND:
- case LDAP_FILTER_NOT:
- case LDAP_FILTER_OR: {
- Filter *pFilter, **ppF;
-
- for ( pFilter = filter->f_list, ppF = &f->f_list;
- pFilter != NULL;
- pFilter = pFilter->f_next, ppF = &f->f_next )
- {
- *ppF = slapi_filter_dup( pFilter );
- if ( *ppF == NULL )
- break;
- }
- break;
- }
- case LDAP_FILTER_PRESENT:
- f->f_desc = filter->f_desc;
- break;
- case LDAP_FILTER_EQUALITY:
- case LDAP_FILTER_GE:
- case LDAP_FILTER_LE:
- case LDAP_FILTER_APPROX:
- f->f_ava = (AttributeAssertion *)slapi_ch_malloc( sizeof(AttributeAssertion) );
- f->f_ava->aa_desc = filter->f_ava->aa_desc;
- ber_dupbv( &f->f_ava->aa_value, &filter->f_ava->aa_value );
- break;
- case LDAP_FILTER_EXT:
- f->f_mra = (MatchingRuleAssertion *)slapi_ch_malloc( sizeof(MatchingRuleAssertion) );
- f->f_mra->ma_rule = filter->f_mra->ma_rule;
- f->f_mra->ma_rule_text = filter->f_mra->ma_rule_text; /* struct copy */
- f->f_mra->ma_desc = filter->f_mra->ma_desc;
- f->f_mra->ma_dnattrs = filter->f_mra->ma_dnattrs;
- ber_dupbv( &f->f_mra->ma_value, &filter->f_mra->ma_value );
- break;
- case LDAP_FILTER_SUBSTRINGS: {
- int i;
-
- f->f_sub = (SubstringsAssertion *)slapi_ch_malloc( sizeof(SubstringsAssertion) );
- f->f_sub->sa_desc = filter->f_sub->sa_desc;
- ber_dupbv( &f->f_sub_initial, &filter->f_sub_initial );
- if ( filter->f_sub_any != NULL ) {
- for ( i = 0; filter->f_sub_any[i].bv_val != NULL; i++ )
- ;
- f->f_sub_any = (BerVarray)slapi_ch_malloc( (i + 1) * (sizeof(struct berval)) );
- for ( i = 0; filter->f_sub_any[i].bv_val != NULL; i++ ) {
- ber_dupbv( &f->f_sub_any[i], &filter->f_sub_any[i] );
- }
- f->f_sub_any[i].bv_val = NULL;
- } else {
- f->f_sub_any = NULL;
- }
- ber_dupbv( &f->f_sub_final, &filter->f_sub_final );
- break;
- }
- case SLAPD_FILTER_COMPUTED:
- f->f_result = filter->f_result;
- break;
- default:
- slapi_ch_free( (void **)&f );
- f = NULL;
- break;
- }
-
- return f;
+ return filter_dup( filter, NULL );
}
int
BerVarray vp = *vs;
ber_bvarray_free( vp );
- slapi_ch_free( (void **)&vp );
+ vp = NULL;
- *vs = NULL;
+ slapi_ch_free( (void **)&vp );
}
}
vp = *vs;
+ if ( vp == NULL )
+ return 0;
+
for ( i = 0; vp[i].bv_val != NULL; i++ )
;
if ( pb == NULL || pb->pb_op == NULL )
return LDAP_PARAM_ERROR;
- ml = slapi_int_ldapmods2modifications( mods );
+ ml = slapi_int_ldapmods2modifications( pb->pb_op, mods );
if ( ml == NULL ) {
return LDAP_OTHER;
}
modp->mod_type = slapi_ch_strdup( ml->sml_desc->ad_cname.bv_val );
} else {
modp->mod_type = slapi_ch_strdup( ml->sml_type.bv_val );
- BER_BVZERO( &ml->sml_type );
}
if ( ml->sml_values != NULL ) {
* before prettying (and we can't easily get out of calling
* slap_mods_check() because we need normalized values).
*/
-Modifications *slapi_int_ldapmods2modifications ( LDAPMod **mods )
+Modifications *slapi_int_ldapmods2modifications ( Operation *op, LDAPMod **mods )
{
Modifications *modlist = NULL, **modtail;
LDAPMod **modp;
modtail = &mod->sml_next;
}
- if ( slap_mods_check( modlist, &text, textbuf, sizeof( textbuf ), NULL ) != LDAP_SUCCESS ) {
+ if ( slap_mods_check( op, modlist, &text, textbuf, sizeof( textbuf ), NULL ) != LDAP_SUCCESS ) {
slap_mods_free( modlist, 1 );
modlist = NULL;
}
break;
}
- rc = slapi_int_get_plugins( op->o_bd, SLAPI_PLUGIN_ACL_ALLOW_ACCESS, (SLAPI_FUNC **)&tmpPlugin );
+ rc = slapi_int_get_plugins( frontendDB, SLAPI_PLUGIN_ACL_ALLOW_ACCESS, (SLAPI_FUNC **)&tmpPlugin );
if ( rc != LDAP_SUCCESS || tmpPlugin == NULL ) {
/* nothing to do; allowed access */
return 1;
pb->pb_op->o_bd = select_backend( &e->e_nname, 0, 0 );
if ( pb->pb_op->o_bd != NULL ) {
- rc = entry_schema_check( pb->pb_op, e, NULL, 0,
+ rc = entry_schema_check( pb->pb_op, e, NULL, 0, 0,
&text, textbuf, textlen );
}
pb->pb_op->o_bd = be_orig;