X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Fslapi%2Fslapi_ops.c;h=199fc8daf3142d5824d26a017e24edc70d8dc956;hb=35dc15ad6649d47749455d46e2bf186f035da62e;hp=a2461ec9f204582778b1d46f958cd6db23f681a7;hpb=fc4d4e2f952115e083e3073aa065b8f7d7b5c53e;p=openldap diff --git a/servers/slapd/slapi/slapi_ops.c b/servers/slapd/slapi/slapi_ops.c index a2461ec9f2..199fc8daf3 100644 --- a/servers/slapd/slapi/slapi_ops.c +++ b/servers/slapd/slapi/slapi_ops.c @@ -3,21 +3,26 @@ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file */ /* - * (C) Copyright IBM Corp. 1997,2002 - * Redistribution and use in source and binary forms are permitted - * provided that this notice is preserved and that due credit is - * given to IBM Corporation. This software is provided ``as is'' - * without express or implied warranty. + * Portions Copyright IBM Corp. 1997,2002-2003 + * Redistribution and use in source and binary forms, with or without + * modification, are permitted only as authorized by the OpenLDAP + * Public License, version 2.7 or later. */ /* * Portions (C) Copyright PADL Software Pty Ltd. 2003 - * Redistribution and use in source and binary forms are permitted - * provided that this notice is preserved and that due credit is - * given to PADL Software Pty Ltd. This software is provided ``as is'' - * without express or implied warranty. + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that this notice is preserved + * and that due credit is given to PADL Software Pty Ltd. This software + * is provided ``as is'' without express or implied warranty. */ #include "portable.h" + +#include +#include +#include +#include + #include #include #include @@ -27,17 +32,23 @@ * so it can be used in ACLs */ static struct slap_listener slap_unknown_listener = { - BER_BVC("unknown"), /* FIXME: use a URI form? */ + BER_BVC("unknown"), /* FIXME: use a URI form? (e.g. slapi://) */ BER_BVC("UNKNOWN") }; -int bvptr2obj( struct berval **bvptr, struct berval **bvobj ); - static void internal_result_v3( Operation *op, SlapReply *rs ) { +#ifdef notdef + /* XXX needs review after internal API change */ + /* rs->sr_nentries appears to always be 0 */ + if (op->o_tag == LDAP_REQ_SEARCH) + slapi_pblock_set( (Slapi_PBlock *)op->o_pb, + SLAPI_NENTRIES, (void *)rs->sr_nentries ); +#endif + return; } @@ -46,12 +57,12 @@ internal_search_entry( Operation *op, SlapReply *rs ) { - char *ent2str = NULL; int nentries = 0, len = 0, i = 0; Slapi_Entry **head = NULL, **tp; - - ent2str = slapi_entry2str( rs->sr_entry, &len ); - if ( ent2str == NULL ) { + Slapi_Entry *entry; + + entry = slapi_entry_dup( rs->sr_entry ); + if ( entry == NULL ) { return 1; } @@ -64,24 +75,19 @@ internal_search_entry( if ( nentries == 0 ) { tp = (Slapi_Entry **)slapi_ch_malloc( 2 * sizeof(Slapi_Entry *) ); if ( tp == NULL ) { + slapi_entry_free( entry ); return 1; } - tp[ 0 ] = (Slapi_Entry *)str2entry( ent2str ); - if ( tp[ 0 ] == NULL ) { - return 1; - } - + tp[ 0 ] = entry; } else { tp = (Slapi_Entry **)slapi_ch_realloc( (char *)head, sizeof(Slapi_Entry *) * ( i + 1 ) ); if ( tp == NULL ) { + slapi_entry_free( entry ); return 1; } - tp[ i - 1 ] = (Slapi_Entry *)str2entry( ent2str ); - if ( tp[ i - 1 ] == NULL ) { - return 1; - } + tp[ i - 1 ] = entry; } tp[ i ] = NULL; @@ -93,17 +99,6 @@ internal_search_entry( return LDAP_SUCCESS; } -static void -internal_search_result( - Operation *op, - SlapReply *sr ) -{ - slapi_pblock_set( (Slapi_PBlock *)op->o_pb, - SLAPI_NENTRIES, (void *)sr->sr_nentries ); - - return; -} - static void internal_result_ext( Operation *op, @@ -159,7 +154,10 @@ slapiConnectionInit( c->c_pending_ops.stqh_first->o_authmech.bv_len = 0; c->c_pending_ops.stqh_first->o_time = slap_get_time(); c->c_pending_ops.stqh_first->o_do_not_cache = 1; - c->c_pending_ops.stqh_first->o_threadctx = ldap_pvt_thread_pool_context( &connection_pool ); + c->c_pending_ops.stqh_first->o_threadctx = ldap_pvt_thread_pool_context(); + c->c_pending_ops.stqh_first->o_tmpmemctx = NULL; + c->c_pending_ops.stqh_first->o_tmpmfuncs = &ch_mfuncs; + c->c_pending_ops.stqh_first->o_conn = c; /* connection object */ c->c_authmech.bv_val = NULL; @@ -168,7 +166,6 @@ slapiConnectionInit( c->c_dn.bv_len = 0; c->c_ndn.bv_val = NULL; c->c_ndn.bv_len = 0; - c->c_groups = NULL; c->c_listener = &slap_unknown_listener; ber_dupbv( &c->c_peer_domain, (struct berval *)&slap_unknown_bv ); @@ -178,7 +175,8 @@ slapiConnectionInit( c->c_sasl_bind_mech.bv_val = NULL; c->c_sasl_bind_mech.bv_len = 0; - c->c_sasl_context = NULL; + c->c_sasl_authctx = NULL; + c->c_sasl_sockctx = NULL; c->c_sasl_extra = NULL; c->c_sb = ber_sockbuf_alloc( ); @@ -217,7 +215,6 @@ slapiConnectionInit( pConn->c_send_ldap_result = internal_result_v3; pConn->c_send_search_entry = internal_search_entry; - pConn->c_send_search_result = internal_search_result; pConn->c_send_ldap_extended = internal_result_ext; pConn->c_send_search_reference = internal_search_reference; @@ -257,9 +254,9 @@ static void slapiConnectionDestroy( Connection **pConn ) * the strings. */ static int -values2obj( +values2obj_copy( char **ppValue, - BerVarray *bvobj) + BerVarray *bvobj ) { int i; BerVarray tmpberval; @@ -277,8 +274,11 @@ values2obj( return LDAP_NO_MEMORY; } for ( i = 0; ppValue[i] != NULL; i++ ) { - tmpberval[i].bv_val = ppValue[i]; - tmpberval[i].bv_len = strlen( ppValue[i] ); + size_t len = strlen( ppValue[i] ); + + tmpberval[i].bv_val = slapi_ch_malloc( len + 1 ); + AC_MEMCPY( tmpberval[i].bv_val, ppValue[i], len + 1 ); + tmpberval[i].bv_len = len; } tmpberval[i].bv_val = NULL; tmpberval[i].bv_len = 0; @@ -288,25 +288,41 @@ values2obj( return LDAP_SUCCESS; } -static void -freeMods( Modifications *ml ) +static int +bvptr2obj_copy( + struct berval **bvptr, + BerVarray *bvobj ) { - /* - * Free a modification list whose values have been - * set with bvptr2obj() or values2obj() (ie. they - * do not own the pointer to the underlying values) - */ - Modifications *next; + int rc = LDAP_SUCCESS; + int i; + BerVarray tmpberval; - for ( ; ml != NULL; ml = next ) { - next = ml->sml_next; + if ( bvptr == NULL || *bvptr == NULL ) { + return LDAP_OTHER; + } - slapi_ch_free( (void **)&ml->sml_bvalues ); -#ifdef SLAP_NVALUES - slapi_ch_free( (void **)&ml->sml_nvalues ); -#endif - slapi_ch_free( (void **)&ml ); + for ( i = 0; bvptr != NULL && bvptr[i] != NULL; i++ ) { + ; /* EMPTY */ } + + tmpberval = (BerVarray)slapi_ch_malloc( (i + 1)*sizeof(struct berval)); + if ( tmpberval == NULL ) { + return LDAP_NO_MEMORY; + } + + for ( i = 0; bvptr[i] != NULL; i++ ) { + tmpberval[i].bv_val = slapi_ch_malloc( bvptr[i]->bv_len ); + tmpberval[i].bv_len = bvptr[i]->bv_len; + AC_MEMCPY( tmpberval[i].bv_val, bvptr[i]->bv_val, bvptr[i]->bv_len ); + } + tmpberval[i].bv_val = NULL; + tmpberval[i].bv_len = 0; + + if ( rc == LDAP_SUCCESS ) { + *bvobj = tmpberval; + } + + return rc; } /* @@ -326,7 +342,6 @@ LDAPModToEntry( Entry *pEntry=NULL; LDAPMod *pMod; struct berval *bv; - Backend *be; Operation *op; Modifications *modlist = NULL; @@ -340,7 +355,7 @@ LDAPModToEntry( op = (Operation *) slapi_ch_calloc(1, sizeof(Operation)); - if ( pEntry == NULL) { + if ( op == NULL) { rc = LDAP_NO_MEMORY; goto cleanup; } @@ -355,24 +370,30 @@ LDAPModToEntry( dn.bv_val = slapi_ch_strdup(ldn); dn.bv_len = strlen(ldn); - rc = dnPrettyNormal( NULL, &dn, &pEntry->e_name, &pEntry->e_nname ); - if ( rc != LDAP_SUCCESS ) + rc = dnPrettyNormal( NULL, &dn, &pEntry->e_name, &pEntry->e_nname, NULL ); + if ( rc != LDAP_SUCCESS ) { goto cleanup; + } if ( rc == LDAP_SUCCESS ) { - for ( i=0, pMod=mods[0]; rc == LDAP_SUCCESS && pMod != NULL; pMod=mods[++i]) { + for ( i = 0, pMod = mods[0]; rc == LDAP_SUCCESS && pMod != NULL; pMod = mods[++i]) { Modifications *mod; + if ( (pMod->mod_op & LDAP_MOD_BVALUES) != 0 ) { - /* attr values are in berval format */ - /* convert an array of pointers to bervals to an array of bervals */ - rc = bvptr2obj(pMod->mod_bvalues, &bv); - if (rc != LDAP_SUCCESS) goto cleanup; + /* + * Convert an array of pointers to bervals to + * an array of bervals. Note that we need to copy the + * values too, as the slap_mods_check() will free the + * original values after prettying; the modifications + * being passed in may not have been allocated on the + * heap. + */ + rc = bvptr2obj_copy( pMod->mod_bvalues, &bv ); + if ( rc != LDAP_SUCCESS ) goto cleanup; tmp.sml_type.bv_val = pMod->mod_type; tmp.sml_type.bv_len = strlen( pMod->mod_type ); tmp.sml_bvalues = bv; -#ifdef SLAP_NVALUES tmp.sml_nvalues = NULL; -#endif mod = (Modifications *) ch_malloc( sizeof(Modifications) ); @@ -381,9 +402,7 @@ LDAPModToEntry( mod->sml_desc = NULL; mod->sml_type = tmp.sml_type; mod->sml_bvalues = tmp.sml_bvalues; -#ifdef SLAP_NVALUES mod->sml_nvalues = tmp.sml_nvalues; -#endif *modtail = mod; modtail = &mod->sml_next; @@ -394,14 +413,12 @@ LDAPModToEntry( if ( pMod->mod_values == NULL ) { rc = LDAP_OTHER; } else { - rc = values2obj( pMod->mod_values, &bv ); - if (rc != LDAP_SUCCESS) goto cleanup; + rc = values2obj_copy( pMod->mod_values, &bv ); + if ( rc != LDAP_SUCCESS ) goto cleanup; tmp.sml_type.bv_val = pMod->mod_type; tmp.sml_type.bv_len = strlen( pMod->mod_type ); tmp.sml_bvalues = bv; -#ifdef SLAP_NVALUES tmp.sml_nvalues = NULL; -#endif mod = (Modifications *) ch_malloc( sizeof(Modifications) ); @@ -410,9 +427,7 @@ LDAPModToEntry( mod->sml_desc = NULL; mod->sml_type = tmp.sml_type; mod->sml_bvalues = tmp.sml_bvalues; -#ifdef SLAP_NVALUES mod->sml_nvalues = tmp.sml_nvalues; -#endif *modtail = mod; modtail = &mod->sml_next; @@ -421,21 +436,18 @@ LDAPModToEntry( } /* for each LDAPMod */ } - be = select_backend(&pEntry->e_nname, 0, 0); - if ( be == NULL ) { - rc = LDAP_PARTIAL_RESULTS; - goto cleanup; - } - - if ( be ) { - int repl_user = be_isupdate(be, &be->be_rootdn ); - if ( !be->be_update_ndn.bv_len || repl_user ) { - int update = be->be_update_ndn.bv_len; + op->o_bd = select_backend( &pEntry->e_nname, 0, 0 ); + if ( op->o_bd == NULL ) { + rc = LDAP_PARTIAL_RESULTS; + } else { + int repl_user = be_isupdate( op->o_bd, &op->o_bd->be_rootdn ); + if ( !op->o_bd->be_update_ndn.bv_len || repl_user ) { + int update = op->o_bd->be_update_ndn.bv_len; char textbuf[SLAP_TEXT_BUFLEN]; size_t textlen = sizeof textbuf; rc = slap_mods_check( modlist, update, &text, - textbuf, textlen ); + textbuf, textlen, NULL ); if ( rc != LDAP_SUCCESS) { goto cleanup; } @@ -449,12 +461,8 @@ LDAPModToEntry( } } - /* - * FIXME: slap_mods2entry is declared static - * in servers/slapd/add.c - */ rc = slap_mods2entry( modlist, &pEntry, repl_user, - &text, textbuf, textlen ); + 0, &text, textbuf, textlen ); if (rc != LDAP_SUCCESS) { goto cleanup; } @@ -462,8 +470,6 @@ LDAPModToEntry( } else { rc = LDAP_REFERRAL; } - } else { - rc = LDAP_UNWILLING_TO_PERFORM; } cleanup: @@ -473,7 +479,7 @@ cleanup: if ( op ) slapi_ch_free( (void **)&op ); if ( modlist != NULL ) - freeMods( modlist ); + slap_mods_free( modlist ); if ( rc != LDAP_SUCCESS ) { if ( pEntry != NULL ) { slapi_entry_free( pEntry ); @@ -501,7 +507,6 @@ slapi_delete_internal( int log_change ) { #ifdef LDAP_SLAPI - Backend *be; Connection *pConn = NULL; Operation *op = NULL; Slapi_PBlock *pPB = NULL; @@ -529,7 +534,7 @@ slapi_delete_internal( dn.bv_val = slapi_ch_strdup(ldn); dn.bv_len = strlen(ldn); - rs.sr_err = dnPrettyNormal( NULL, &dn, &op->o_req_dn, &op->o_req_ndn ); + rs.sr_err = dnPrettyNormal( NULL, &dn, &op->o_req_dn, &op->o_req_ndn, NULL ); if ( rs.sr_err != LDAP_SUCCESS ) goto cleanup; @@ -538,19 +543,19 @@ slapi_delete_internal( manageDsaIt = 1; } - be = select_backend( &op->o_req_ndn, manageDsaIt, 0 ); - if ( be == NULL ) { + op->o_bd = select_backend( &op->o_req_ndn, manageDsaIt, 0 ); + if ( op->o_bd == NULL ) { rs.sr_err = LDAP_PARTIAL_RESULTS; goto cleanup; } - op->o_dn = pConn->c_dn = be->be_rootdn; - op->o_ndn = pConn->c_ndn = be->be_rootndn; + op->o_dn = pConn->c_dn = op->o_bd->be_rootdn; + op->o_ndn = pConn->c_ndn = op->o_bd->be_rootndn; - if ( be->be_delete ) { - int repl_user = be_isupdate( be, &op->o_ndn ); - if ( !be->be_update_ndn.bv_len || repl_user ) { - if ( (*be->be_delete)( op, &rs ) == 0 ) { + if ( op->o_bd->be_delete ) { + int repl_user = be_isupdate( op->o_bd, &op->o_ndn ); + if ( !op->o_bd->be_update_ndn.bv_len || repl_user ) { + if ( (*op->o_bd->be_delete)( op, &rs ) == 0 ) { if ( log_change ) { replog( op ); } @@ -583,23 +588,22 @@ cleanup: #endif /* LDAP_SLAPI */ } -Slapi_PBlock * -slapi_add_entry_internal( - Slapi_Entry *e, +#ifdef LDAP_SLAPI +static Slapi_PBlock * +slapi_add_entry_internal_locked( + Slapi_Entry **e, LDAPControl **controls, int log_changes ) { -#ifdef LDAP_SLAPI Connection *pConn = NULL; Operation *op = NULL; Slapi_PBlock *pPB = NULL, *pSavePB = NULL; - Backend *be; int manageDsaIt = 0; int isCritical; SlapReply rs = { REP_RESULT }; - if ( e == NULL ) { + if ( *e == NULL ) { rs.sr_err = LDAP_PARAM_ERROR; goto cleanup; } @@ -619,23 +623,25 @@ slapi_add_entry_internal( pPB = (Slapi_PBlock *)op->o_pb; op->o_ctrls = controls; - be = select_backend( &e->e_nname, manageDsaIt, 0 ); - if ( be == NULL ) { + op->o_bd = select_backend( &((*e)->e_nname), manageDsaIt, 0 ); + if ( op->o_bd == NULL ) { rs.sr_err = LDAP_PARTIAL_RESULTS; goto cleanup; } - op->o_dn = pConn->c_dn = be->be_rootdn; - op->o_ndn = pConn->c_ndn = be->be_rootndn; - op->oq_add.rs_e = e; + op->o_dn = pConn->c_dn = op->o_bd->be_rootdn; + op->o_ndn = pConn->c_ndn = op->o_bd->be_rootndn; + op->oq_add.rs_e = *e; - if ( be->be_add ) { - int repl_user = be_isupdate( be, &op->o_ndn ); - if ( !be->be_update_ndn.bv_len || repl_user ){ - if ( (*be->be_add)( op, &rs ) == 0 ) { + if ( op->o_bd->be_add ) { + int repl_user = be_isupdate( op->o_bd, &op->o_ndn ); + if ( !op->o_bd->be_update_ndn.bv_len || repl_user ) { + if ( (*op->o_bd->be_add)( op, &rs ) == 0 ) { if ( log_changes ) { replog( op ); } + be_entry_release_w( op, *e ); + *e = NULL; } } else { rs.sr_err = LDAP_REFERRAL; @@ -657,12 +663,34 @@ cleanup: slapiConnectionDestroy( &pConn ); return( pSavePB ); +} +#endif /* LDAP_SLAPI */ + +Slapi_PBlock * +slapi_add_entry_internal( + Slapi_Entry *e, + LDAPControl **controls, + int log_changes ) +{ +#ifdef LDAP_SLAPI + Slapi_PBlock *pb; + Slapi_Entry *entry; + + /* + * We make a copy to avoid an entry that may be freed later + * by the caller being placed in the cache. + */ + entry = slapi_entry_dup( e ); + pb = slapi_add_entry_internal_locked( &entry, controls, log_changes ); + if ( entry != NULL ) { + slapi_entry_free( entry ); + } + return pb; #else return NULL; -#endif /* LDAP_SLAPI */ +#endif } - Slapi_PBlock * slapi_add_internal( char *dn, @@ -690,7 +718,8 @@ slapi_add_internal( } if ( rc == LDAP_SUCCESS ) { - if((pEntry = LDAPModToEntry( dn, mods )) == NULL) { + pEntry = LDAPModToEntry( dn, mods ); + if ( pEntry == NULL ) { rc = LDAP_OTHER; } } @@ -699,10 +728,10 @@ slapi_add_internal( pb = slapi_pblock_new(); slapi_pblock_set( pb, SLAPI_PLUGIN_INTOP_RESULT, (void *)rc ); } else { - pb = slapi_add_entry_internal( pEntry, controls, log_changes ); + pb = slapi_add_entry_internal_locked( &pEntry, controls, log_changes ); } - if ( pEntry ) { + if ( pEntry != NULL ) { slapi_entry_free(pEntry); } @@ -739,7 +768,6 @@ slapi_modrdn_internal( Operation *op = NULL; Slapi_PBlock *pPB = NULL; Slapi_PBlock *pSavePB = NULL; - Backend *be; int manageDsaIt = 0; int isCritical; SlapReply rs = { REP_RESULT }; @@ -759,19 +787,19 @@ slapi_modrdn_internal( manageDsaIt = 1; } - be = select_backend( &op->o_req_ndn, manageDsaIt, 0 ); - if ( be == NULL ) { + op->o_bd = select_backend( &op->o_req_ndn, manageDsaIt, 0 ); + if ( op->o_bd == NULL ) { rs.sr_err = LDAP_PARTIAL_RESULTS; goto cleanup; } - op->o_dn = pConn->c_dn = be->be_rootdn; - op->o_ndn = pConn->c_ndn = be->be_rootndn; + op->o_dn = pConn->c_dn = op->o_bd->be_rootdn; + op->o_ndn = pConn->c_ndn = op->o_bd->be_rootndn; dn.bv_val = slapi_ch_strdup( olddn ); dn.bv_len = strlen( olddn ); - rs.sr_err = dnPrettyNormal( NULL, &dn, &op->o_req_dn, &op->o_req_ndn ); + rs.sr_err = dnPrettyNormal( NULL, &dn, &op->o_req_dn, &op->o_req_ndn, NULL ); if ( rs.sr_err != LDAP_SUCCESS ) { goto cleanup; } @@ -784,7 +812,7 @@ slapi_modrdn_internal( newrdn.bv_val = slapi_ch_strdup( lnewrdn ); newrdn.bv_len = strlen( lnewrdn ); - rs.sr_err = dnPrettyNormal( NULL, &newrdn, &op->oq_modrdn.rs_newrdn, &op->oq_modrdn.rs_nnewrdn ); + rs.sr_err = dnPrettyNormal( NULL, &newrdn, &op->oq_modrdn.rs_newrdn, &op->oq_modrdn.rs_nnewrdn, NULL ); if ( rs.sr_err != LDAP_SUCCESS ) { goto cleanup; } @@ -797,10 +825,10 @@ slapi_modrdn_internal( op->oq_modrdn.rs_nnewSup = NULL; op->oq_modrdn.rs_deleteoldrdn = deloldrdn; - if ( be->be_modrdn ) { - int repl_user = be_isupdate( be, &op->o_ndn ); - if ( !be->be_update_ndn.bv_len || repl_user ) { - if ( (*be->be_modrdn)( op, &rs ) == 0 ) { + if ( op->o_bd->be_modrdn ) { + int repl_user = be_isupdate( op->o_bd, &op->o_ndn ); + if ( !op->o_bd->be_update_ndn.bv_len || repl_user ) { + if ( (*op->o_bd->be_modrdn)( op, &rs ) == 0 ) { if ( log_change ) { replog( op ); } @@ -870,7 +898,6 @@ slapi_modify_internal( int manageDsaIt = 0; int isCritical; - Backend *be; struct berval *bv; LDAPMod *pMod; @@ -897,7 +924,7 @@ slapi_modify_internal( dn.bv_val = slapi_ch_strdup( ldn ); dn.bv_len = strlen( ldn ); - rs.sr_err = dnPrettyNormal( NULL, &dn, &op->o_req_dn, &op->o_req_ndn ); + rs.sr_err = dnPrettyNormal( NULL, &dn, &op->o_req_dn, &op->o_req_ndn, NULL ); if ( rs.sr_err != LDAP_SUCCESS ) { goto cleanup; } @@ -907,14 +934,14 @@ slapi_modify_internal( manageDsaIt = 1; } - be = select_backend( &op->o_req_ndn, manageDsaIt, 0 ); - if ( be == NULL ) { + op->o_bd = select_backend( &op->o_req_ndn, manageDsaIt, 0 ); + if ( op->o_bd == NULL ) { rs.sr_err = LDAP_PARTIAL_RESULTS; goto cleanup; } - op->o_dn = pConn->c_dn = be->be_rootdn; - op->o_ndn = pConn->c_ndn = be->be_rootndn; + op->o_dn = pConn->c_dn = op->o_bd->be_rootdn; + op->o_ndn = pConn->c_ndn = op->o_bd->be_rootndn; for ( i = 0, pMod = mods[0]; rs.sr_err == LDAP_SUCCESS && pMod != NULL; @@ -928,15 +955,13 @@ slapi_modify_internal( * convert an array of pointers to bervals * to an array of bervals */ - rs.sr_err = bvptr2obj( pMod->mod_bvalues, &bv ); + rs.sr_err = bvptr2obj_copy( pMod->mod_bvalues, &bv ); if ( rs.sr_err != LDAP_SUCCESS ) goto cleanup; tmp.sml_type.bv_val = pMod->mod_type; tmp.sml_type.bv_len = strlen( pMod->mod_type ); tmp.sml_bvalues = bv; -#ifdef SLAP_NVALUES tmp.sml_nvalues = NULL; -#endif mod = (Modifications *)ch_malloc( sizeof(Modifications) ); @@ -945,19 +970,15 @@ slapi_modify_internal( mod->sml_desc = NULL; mod->sml_type = tmp.sml_type; mod->sml_bvalues = tmp.sml_bvalues; -#ifdef SLAP_NVALUES mod->sml_nvalues = tmp.sml_nvalues; -#endif } else { - rs.sr_err = values2obj( pMod->mod_values, &bv ); + rs.sr_err = values2obj_copy( pMod->mod_values, &bv ); if ( rs.sr_err != LDAP_SUCCESS ) goto cleanup; tmp.sml_type.bv_val = pMod->mod_type; tmp.sml_type.bv_len = strlen( pMod->mod_type ); tmp.sml_bvalues = bv; -#ifdef SLAP_NVALUES tmp.sml_nvalues = NULL; -#endif mod = (Modifications *) ch_malloc( sizeof(Modifications) ); @@ -966,9 +987,7 @@ slapi_modify_internal( mod->sml_desc = NULL; mod->sml_type = tmp.sml_type; mod->sml_bvalues = tmp.sml_bvalues; -#ifdef SLAP_NVALUES mod->sml_nvalues = tmp.sml_nvalues; -#endif } *modtail = mod; modtail = &mod->sml_next; @@ -999,16 +1018,16 @@ slapi_modify_internal( op->oq_modify.rs_modlist = modlist; - if ( be->be_modify ) { - int repl_user = be_isupdate( be, &op->o_ndn ); - if ( !be->be_update_ndn.bv_len || repl_user ) { - int update = be->be_update_ndn.bv_len; + if ( op->o_bd->be_modify ) { + int repl_user = be_isupdate( op->o_bd, &op->o_ndn ); + if ( !op->o_bd->be_update_ndn.bv_len || repl_user ) { + int update = op->o_bd->be_update_ndn.bv_len; const char *text = NULL; char textbuf[SLAP_TEXT_BUFLEN]; size_t textlen = sizeof( textbuf ); rs.sr_err = slap_mods_check( modlist, update, - &text, textbuf, textlen ); + &text, textbuf, textlen, NULL ); if ( rs.sr_err != LDAP_SUCCESS ) { goto cleanup; } @@ -1021,7 +1040,7 @@ slapi_modify_internal( goto cleanup; } } - if ( (*be->be_modify)( op, &rs ) == 0 ) { + if ( (*op->o_bd->be_modify)( op, &rs ) == 0 ) { if ( log_change ) { replog( op ); } @@ -1044,7 +1063,7 @@ cleanup: slapi_ch_free( (void **)&dn.bv_val ); if ( modlist != NULL ) - freeMods( modlist ); + slap_mods_free( modlist ); if ( pConn != NULL ) { pSavePB = pPB; @@ -1069,7 +1088,6 @@ slapi_search_internal_bind( int attrsonly ) { #ifdef LDAP_SLAPI - Backend *be; Connection *c; Operation *op = NULL; Slapi_PBlock *ptr = NULL; @@ -1096,10 +1114,12 @@ slapi_search_internal_bind( ptr = (Slapi_PBlock *)op->o_pb; op->o_ctrls = controls; - dn.bv_val = slapi_ch_strdup(ldn); - dn.bv_len = strlen(ldn); + if ( ldn != NULL ) { + dn.bv_val = slapi_ch_strdup(ldn); + dn.bv_len = strlen(ldn); + } - rs.sr_err = dnPrettyNormal( NULL, &dn, &op->o_req_dn, &op->o_req_ndn ); + rs.sr_err = dnPrettyNormal( NULL, &dn, &op->o_req_dn, &op->o_req_ndn, NULL ); if ( rs.sr_err != LDAP_SUCCESS ) { goto cleanup; } @@ -1173,8 +1193,8 @@ slapi_search_internal_bind( } if ( !op->o_req_ndn.bv_len && default_search_nbase.bv_len ) { - slapi_ch_free( (void **)op->o_req_dn.bv_val ); - slapi_ch_free( (void **)op->o_req_ndn.bv_val ); + slapi_ch_free( (void **)&op->o_req_dn.bv_val ); + slapi_ch_free( (void **)&op->o_req_ndn.bv_val ); ber_dupbv( &op->o_req_dn, &default_search_base ); ber_dupbv( &op->o_req_ndn, &default_search_nbase ); @@ -1185,8 +1205,8 @@ slapi_search_internal_bind( manageDsaIt = 1; } - be = select_backend( &op->o_req_ndn, manageDsaIt, 0 ); - if ( be == NULL ) { + op->o_bd = select_backend( &op->o_req_ndn, manageDsaIt, 0 ); + if ( op->o_bd == NULL ) { if ( manageDsaIt == 1 ) { rs.sr_err = LDAP_NO_SUCH_OBJECT; } else { @@ -1195,8 +1215,8 @@ slapi_search_internal_bind( goto cleanup; } - op->o_dn = c->c_dn = be->be_rootdn; - op->o_ndn = c->c_ndn = be->be_rootndn; + op->o_dn = c->c_dn = op->o_bd->be_rootdn; + op->o_ndn = c->c_ndn = op->o_bd->be_rootndn; op->oq_search.rs_scope = scope; op->oq_search.rs_deref = 0; @@ -1207,8 +1227,8 @@ slapi_search_internal_bind( op->oq_search.rs_filter = filter; op->oq_search.rs_filterstr = fstr; - if ( be->be_search ) { - if ( (*be->be_search)( op, &rs ) != 0 ) { + if ( op->o_bd->be_search ) { + if ( (*op->o_bd->be_search)( op, &rs ) != 0 ) { rs.sr_err = LDAP_OTHER; } } else {