int slapi_delete_internal_pb( Slapi_PBlock *pb ) { if ( pb == NULL ) { return -1; } PBLOCK_ASSERT_INTOP( pb, LDAP_REQ_DELETE ); slapi_int_func_internal_pb( pb, op_delete ); return 0; }
static int slapi_int_func_internal_pb( Slapi_PBlock *pb, slap_operation_t which ) { SlapReply *rs = pb->pb_rs; int rc; PBLOCK_ASSERT_INTOP( pb, 0 ); rc = slapi_int_get_ctrls( pb ); if ( rc != LDAP_SUCCESS ) { rs->sr_err = rc; return rc; } pb->pb_op->o_bd = frontendDB; return (&frontendDB->be_bind)[which]( pb->pb_op, pb->pb_rs ); }
static int slapi_int_search_entry_callback( Slapi_Entry *entry, void *callback_data ) { int nentries = 0, i = 0; Slapi_Entry **head = NULL, **tp; Slapi_PBlock *pb = (Slapi_PBlock *)callback_data; PBLOCK_ASSERT_INTOP( pb, LDAP_REQ_SEARCH ); entry = slapi_entry_dup( entry ); if ( entry == NULL ) { return LDAP_NO_MEMORY; } slapi_pblock_get( pb, SLAPI_NENTRIES, &nentries ); slapi_pblock_get( pb, SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES, &head ); i = nentries + 1; if ( nentries == 0 ) { tp = (Slapi_Entry **)slapi_ch_malloc( 2 * sizeof(Slapi_Entry *) ); if ( tp == NULL ) { slapi_entry_free( entry ); return LDAP_NO_MEMORY; } 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 LDAP_NO_MEMORY; } tp[i - 1] = entry; } tp[i] = NULL; slapi_pblock_set( pb, SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES, (void *)tp ); slapi_pblock_set( pb, SLAPI_NENTRIES, (void *)&i ); return LDAP_SUCCESS; }
int slapi_modrdn_internal_pb( Slapi_PBlock *pb ) { if ( pb == NULL ) { return -1; } PBLOCK_ASSERT_INTOP( pb, LDAP_REQ_MODRDN ); if ( BER_BVISEMPTY( &pb->pb_op->o_req_ndn ) ) { pb->pb_rs->sr_err = LDAP_UNWILLING_TO_PERFORM; goto cleanup; } slapi_int_func_internal_pb( pb, op_modrdn ); cleanup: return 0; }
int slapi_add_internal_pb( Slapi_PBlock *pb ) { SlapReply *rs; Slapi_Entry *entry_orig = NULL; OpExtraDB oex; int rc; if ( pb == NULL ) { return -1; } PBLOCK_ASSERT_INTOP( pb, LDAP_REQ_ADD ); rs = pb->pb_rs; entry_orig = pb->pb_op->ora_e; pb->pb_op->ora_e = NULL; /* * The caller can specify a new entry, or a target DN and set * of modifications, but not both. */ if ( entry_orig != NULL ) { if ( pb->pb_op->ora_modlist != NULL || !BER_BVISNULL( &pb->pb_op->o_req_ndn )) { rs->sr_err = LDAP_PARAM_ERROR; goto cleanup; } assert( BER_BVISNULL( &pb->pb_op->o_req_dn ) ); /* shouldn't get set */ ber_dupbv( &pb->pb_op->o_req_dn, &entry_orig->e_name ); ber_dupbv( &pb->pb_op->o_req_ndn, &entry_orig->e_nname ); } else if ( pb->pb_op->ora_modlist == NULL || BER_BVISNULL( &pb->pb_op->o_req_ndn )) { rs->sr_err = LDAP_PARAM_ERROR; goto cleanup; } pb->pb_op->ora_e = (Entry *)slapi_ch_calloc( 1, sizeof(Entry) ); ber_dupbv( &pb->pb_op->ora_e->e_name, &pb->pb_op->o_req_dn ); ber_dupbv( &pb->pb_op->ora_e->e_nname, &pb->pb_op->o_req_ndn ); if ( entry_orig != NULL ) { assert( pb->pb_op->ora_modlist == NULL ); rs->sr_err = slap_entry2mods( entry_orig, &pb->pb_op->ora_modlist, &rs->sr_text, pb->pb_textbuf, sizeof( pb->pb_textbuf ) ); if ( rs->sr_err != LDAP_SUCCESS ) { goto cleanup; } } else { assert( pb->pb_op->ora_modlist != NULL ); } rs->sr_err = slap_mods_check( pb->pb_op, pb->pb_op->ora_modlist, &rs->sr_text, pb->pb_textbuf, sizeof( pb->pb_textbuf ), NULL ); if ( rs->sr_err != LDAP_SUCCESS ) { goto cleanup; } /* Duplicate the values, because we may call slapi_entry_free() */ rs->sr_err = slap_mods2entry( pb->pb_op->ora_modlist, &pb->pb_op->ora_e, 1, 0, &rs->sr_text, pb->pb_textbuf, sizeof( pb->pb_textbuf ) ); if ( rs->sr_err != LDAP_SUCCESS ) { goto cleanup; } oex.oe.oe_key = (void *)do_add; oex.oe_db = NULL; LDAP_SLIST_INSERT_HEAD(&pb->pb_op->o_extra, &oex.oe, oe_next); rc = slapi_int_func_internal_pb( pb, op_add ); LDAP_SLIST_REMOVE(&pb->pb_op->o_extra, &oex.oe, OpExtra, oe_next); if ( !rc ) { if ( pb->pb_op->ora_e != NULL && oex.oe_db != NULL ) { BackendDB *bd = pb->pb_op->o_bd; pb->pb_op->o_bd = oex.oe_db; be_entry_release_w( pb->pb_op, pb->pb_op->ora_e ); pb->pb_op->ora_e = NULL; pb->pb_op->o_bd = bd; } } cleanup: if ( pb->pb_op->ora_e != NULL ) { slapi_entry_free( pb->pb_op->ora_e ); pb->pb_op->ora_e = NULL; } if ( entry_orig != NULL ) { pb->pb_op->ora_e = entry_orig; slap_mods_free( pb->pb_op->ora_modlist, 1 ); pb->pb_op->ora_modlist = NULL; } return 0; }
void slapi_int_connection_done_pb( Slapi_PBlock *pb ) { Connection *conn; Operation *op; PBLOCK_ASSERT_INTOP( pb, 0 ); conn = pb->pb_conn; op = pb->pb_op; /* free allocated DNs */ if ( !BER_BVISNULL( &op->o_dn ) ) op->o_tmpfree( op->o_dn.bv_val, op->o_tmpmemctx ); if ( !BER_BVISNULL( &op->o_ndn ) ) op->o_tmpfree( op->o_ndn.bv_val, op->o_tmpmemctx ); if ( !BER_BVISNULL( &op->o_req_dn ) ) op->o_tmpfree( op->o_req_dn.bv_val, op->o_tmpmemctx ); if ( !BER_BVISNULL( &op->o_req_ndn ) ) op->o_tmpfree( op->o_req_ndn.bv_val, op->o_tmpmemctx ); switch ( op->o_tag ) { case LDAP_REQ_MODRDN: if ( !BER_BVISNULL( &op->orr_newrdn )) op->o_tmpfree( op->orr_newrdn.bv_val, op->o_tmpmemctx ); if ( !BER_BVISNULL( &op->orr_nnewrdn )) op->o_tmpfree( op->orr_nnewrdn.bv_val, op->o_tmpmemctx ); if ( op->orr_newSup != NULL ) { assert( !BER_BVISNULL( op->orr_newSup ) ); op->o_tmpfree( op->orr_newSup->bv_val, op->o_tmpmemctx ); op->o_tmpfree( op->orr_newSup, op->o_tmpmemctx ); } if ( op->orr_nnewSup != NULL ) { assert( !BER_BVISNULL( op->orr_nnewSup ) ); op->o_tmpfree( op->orr_nnewSup->bv_val, op->o_tmpmemctx ); op->o_tmpfree( op->orr_nnewSup, op->o_tmpmemctx ); } slap_mods_free( op->orr_modlist, 1 ); break; case LDAP_REQ_ADD: slap_mods_free( op->ora_modlist, 0 ); break; case LDAP_REQ_MODIFY: slap_mods_free( op->orm_modlist, 1 ); break; case LDAP_REQ_SEARCH: if ( op->ors_attrs != NULL ) { op->o_tmpfree( op->ors_attrs, op->o_tmpmemctx ); op->ors_attrs = NULL; } break; default: break; } slapi_ch_free_string( &conn->c_authmech.bv_val ); slapi_ch_free_string( &conn->c_dn.bv_val ); slapi_ch_free_string( &conn->c_ndn.bv_val ); slapi_ch_free_string( &conn->c_peer_domain.bv_val ); slapi_ch_free_string( &conn->c_peer_name.bv_val ); if ( conn->c_sb != NULL ) { ber_sockbuf_free( conn->c_sb ); } slapi_int_free_object_extensions( SLAPI_X_EXT_OPERATION, op ); slapi_int_free_object_extensions( SLAPI_X_EXT_CONNECTION, conn ); slapi_ch_free( (void **)&pb->pb_op->o_callback ); slapi_ch_free( (void **)&pb->pb_op ); slapi_ch_free( (void **)&pb->pb_conn ); slapi_ch_free( (void **)&pb->pb_rs ); }