3 * Replication Engine which uses the LDAP Sync protocol
5 /* Copyright (c) 2003 by International Business Machines, Inc.
7 * International Business Machines, Inc. (hereinafter called IBM) grants
8 * permission under its copyrights to use, copy, modify, and distribute this
9 * Software with or without fee, provided that the above copyright notice and
10 * all paragraphs of this notice appear in all copies, and that the name of IBM
11 * not be used in connection with the marketing of any product incorporating
12 * the Software or modifications thereof, without specific, written prior
15 * THE SOFTWARE IS PROVIDED "AS IS", AND IBM DISCLAIMS ALL WARRANTIES,
16 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
17 * PARTICULAR PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL,
18 * DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER ARISING
19 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE, EVEN
20 * IF IBM IS APPRISED OF THE POSSIBILITY OF SUCH DAMAGES.
27 #include <ac/string.h>
28 #include <ac/socket.h>
34 #include "lutil_ldap.h"
41 syncrepl_del_nonpresent( LDAP *, Operation * );
43 /* callback functions */
44 static int cookie_callback( struct slap_op *, struct slap_rep * );
45 static int dn_callback( struct slap_op *, struct slap_rep * );
46 static int nonpresent_callback( struct slap_op *, struct slap_rep * );
47 static int null_callback( struct slap_op *, struct slap_rep * );
48 static int contextcsn_callback( Operation*, SlapReply* );
50 static AttributeDescription **add_descs;
51 static AttributeDescription **add_descs_lastmod;
52 static AttributeDescription **del_descs;
53 static AttributeDescription **del_descs_lastmod;
55 struct runqueue_s syncrepl_rq;
60 add_descs = ch_malloc( 2 * sizeof( AttributeDescription * ));
61 add_descs[0] = slap_schema.si_ad_objectClass;
64 add_descs_lastmod = ch_malloc( 7 * sizeof( AttributeDescription * ));
65 add_descs_lastmod[0] = slap_schema.si_ad_objectClass;
66 add_descs_lastmod[1] = slap_schema.si_ad_creatorsName;
67 add_descs_lastmod[2] = slap_schema.si_ad_modifiersName;
68 add_descs_lastmod[3] = slap_schema.si_ad_createTimestamp;
69 add_descs_lastmod[4] = slap_schema.si_ad_modifyTimestamp;
70 add_descs_lastmod[5] = slap_schema.si_ad_entryCSN;
71 add_descs_lastmod[6] = NULL;
73 del_descs = ch_malloc( 9 * sizeof( AttributeDescription * ));
74 del_descs[0] = slap_schema.si_ad_structuralObjectClass;
75 del_descs[1] = slap_schema.si_ad_subschemaSubentry;
76 del_descs[2] = slap_schema.si_ad_hasSubordinates;
77 del_descs[3] = slap_schema.si_ad_creatorsName;
78 del_descs[4] = slap_schema.si_ad_modifiersName;
79 del_descs[5] = slap_schema.si_ad_createTimestamp;
80 del_descs[6] = slap_schema.si_ad_modifyTimestamp;
81 del_descs[7] = slap_schema.si_ad_entryCSN;
84 del_descs_lastmod = ch_malloc( 4 * sizeof( AttributeDescription * ));
85 del_descs_lastmod[0] = slap_schema.si_ad_structuralObjectClass;
86 del_descs_lastmod[1] = slap_schema.si_ad_subschemaSubentry;
87 del_descs_lastmod[2] = slap_schema.si_ad_hasSubordinates;
88 del_descs_lastmod[3] = NULL;
104 BerElement *sync_ber = NULL;
105 struct berval *sync_bvalp = NULL;
109 struct timeval timeout;
111 /* setup LDAP SYNC control */
112 sync_ber = ber_alloc_t( LBER_USE_DER );
113 ber_set_option( sync_ber, LBER_OPT_BER_MEMCTX, NULL );
115 if ( si->syncCookie ) {
116 ber_printf( sync_ber, "{eO}", abs(si->type), si->syncCookie );
118 ber_printf( sync_ber, "{e}", abs(si->type) );
121 if ( ber_flatten( sync_ber, &sync_bvalp ) == LBER_ERROR ) {
122 ber_free( sync_ber, 1 );
125 ber_free( sync_ber, 1 );
127 ctrls = (LDAPControl**) sl_calloc( 3, sizeof(LDAPControl*), NULL );
129 c[0].ldctl_oid = LDAP_CONTROL_SYNC;
130 c[0].ldctl_value = (*sync_bvalp);
131 c[0].ldctl_iscritical = si->type < 0;
135 c[1].ldctl_oid = LDAP_CONTROL_PROXY_AUTHZ;
136 c[1].ldctl_value.bv_val = si->authzId;
137 c[1].ldctl_value.bv_len = strlen( si->authzId );
138 c[1].ldctl_iscritical = 1;
146 err = ldap_set_option( ld, LDAP_OPT_SERVER_CONTROLS, ctrls );
148 ber_bvfree( sync_bvalp );
151 if ( err != LDAP_OPT_SUCCESS )
152 fprintf( stderr, "Could not set controls : %d\n", err );
154 timeout.tv_sec = si->tlimit > 0 ? si->tlimit : 1;
156 rc = ldap_search_ext( ld, si->base, si->scope, si->filterstr,
157 si->attrs, si->attrsonly, sctrls, cctrls,
158 si->tlimit < 0 ? NULL : &timeout,
159 si->slimit, msgidp );
169 struct re_s* rtask = arg;
170 syncinfo_t *si = ( syncinfo_t * ) rtask->arg;
171 Backend *be = si->be;
173 SlapReply rs = {REP_RESULT};
176 LDAPControl **sctrls = NULL;
177 LDAPControl **rctrls = NULL;
178 LDAPControl *rctrlp = NULL;
179 BerElement *sync_ber = NULL;
180 struct berval *sync_bvalp = NULL;
182 BerElement *ctrl_ber = NULL;
183 BerElement *res_ber = NULL;
186 LDAPMessage *res = NULL;
187 LDAPMessage *msg = NULL;
191 int nresponses, nreferences, nextended, npartial;
192 int nresponses_psearch;
194 int cancel_msgid = -1;
196 struct berval *retdata = NULL;
198 int sync_info_arrived = 0;
202 struct berval syncUUID = { 0, NULL };
203 struct berval syncCookie = { 0, NULL };
208 int syncinfo_arrived = 0;
209 int cancel_response = 0;
212 AttributeDescription** descs = NULL;
224 struct berval base_bv = { 0, NULL };
225 struct berval pbase = { 0, NULL };
226 struct berval nbase = { 0, NULL };
227 struct berval sub_bv = { 0, NULL };
228 struct berval psubrdn = { 0, NULL };
229 struct berval nsubrdn = { 0, NULL };
230 struct berval psub = { 0, NULL };
231 struct berval nsub = { 0, NULL };
233 Modifications *modlist = NULL;
234 Modifications *ml, *mlnext;
235 char *def_filter_str = NULL;
238 LDAP_LOG ( OPERATION, DETAIL1, "do_syncrepl\n", 0, 0, 0 );
240 Debug( LDAP_DEBUG_TRACE, "=>do_syncrepl\n", 0, 0, 0 );
246 if ( abs(si->type) != LDAP_SYNC_REFRESH_ONLY &&
247 abs(si->type) != LDAP_SYNC_REFRESH_AND_PERSIST ) {
251 si->sync_mode = LDAP_SYNC_STATE_MODE;
253 /* Init connection to master */
255 rc = ldap_initialize( &ld, si->provideruri );
256 if ( rc != LDAP_SUCCESS ) {
258 LDAP_LOG( OPERATION, ERR, "do_syncrepl: "
259 "ldap_initialize failed (%s)\n",
260 si->provideruri, 0, 0 );
262 Debug( LDAP_DEBUG_ANY, "do_syncrepl: "
263 "ldap_initialize failed (%s)\n",
264 si->provideruri, 0, 0 );
268 op.o_protocol = LDAP_VERSION3;
269 ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &op.o_protocol );
274 rc = ldap_start_tls_s( ld, NULL, NULL );
275 if( rc != LDAP_SUCCESS ) {
277 LDAP_LOG ( OPERATION, ERR, "do_syncrepl: "
278 "%s: ldap_start_tls failed (%d)\n",
279 si->tls == TLS_CRITICAL ? "Error" : "Warning",
282 Debug( LDAP_DEBUG_ANY,
283 "%s: ldap_start_tls failed (%d)\n",
284 si->tls == TLS_CRITICAL ? "Error" : "Warning",
287 if( si->tls == TLS_CRITICAL )
292 if ( si->bindmethod == LDAP_AUTH_SASL ) {
293 #ifdef HAVE_CYRUS_SASL
296 if ( si->secprops != NULL ) {
297 int err = ldap_set_option( ld,
298 LDAP_OPT_X_SASL_SECPROPS, si->secprops);
300 if( err != LDAP_OPT_SUCCESS ) {
302 LDAP_LOG ( OPERATION, ERR, "do_bind: Error: "
303 "ldap_set_option(%s,SECPROPS,\"%s\") failed!\n",
304 si->provideruri, si->secprops, 0 );
306 Debug( LDAP_DEBUG_ANY, "Error: ldap_set_option "
307 "(%s,SECPROPS,\"%s\") failed!\n",
308 si->provideruri, si->secprops, NULL );
314 defaults = lutil_sasl_defaults( ld,
321 rc = ldap_sasl_interactive_bind_s( ld,
329 if ( rc != LDAP_SUCCESS ) {
331 LDAP_LOG ( OPERATION, ERR, "do_syncrepl: "
332 "ldap_sasl_interactive_bind_s failed (%d)\n",
335 Debug( LDAP_DEBUG_ANY, "do_syncrepl: "
336 "ldap_sasl_interactive_bind_s failed (%d)\n",
341 #else /* HAVE_CYRUS_SASL */
342 fprintf( stderr, "not compiled with SASL support\n" );
346 rc = ldap_bind_s( ld, si->binddn, si->passwd, si->bindmethod );
347 if ( rc != LDAP_SUCCESS ) {
349 LDAP_LOG ( OPERATION, ERR, "do_syncrepl: "
350 "ldap_bind_s failed (%d)\n", rc, 0, 0 );
352 Debug( LDAP_DEBUG_ANY, "do_syncrepl: "
353 "ldap_bind_s failed (%d)\n", rc, 0, 0 );
359 /* set thread context in syncinfo */
362 /* set memory context */
363 #define SLAB_SIZE 1048576
365 memctx = sl_mem_create( memsiz, ctx );
366 op.o_tmpmemctx = memctx;
367 op.o_tmpmfuncs = &sl_mfuncs;
370 op.o_tag = LDAP_REQ_SEARCH;
371 op.o_dn = si->updatedn;
372 op.o_ndn = si->updatedn;
374 op.o_time = slap_get_time();
375 op.o_managedsait = 1;
376 op.o_threadctx = si->ctx;
379 op.o_connid = op.o_conn->c_connid;
380 op.ors_scope = LDAP_SCOPE_BASE;
381 op.ors_deref = LDAP_DEREF_NEVER;
384 op.ors_attrsonly = 0;
386 op.ors_filter = str2filter( def_filter_str = "(objectClass=*)" );
387 ber_str2bv( def_filter_str, strlen( def_filter_str ), 1,
391 conn.c_send_ldap_result = slap_send_ldap_result;
392 conn.c_send_search_entry = slap_send_search_entry;
393 conn.c_send_search_reference = slap_send_search_reference;
395 /* get syncrepl cookie of shadow replica from subentry */
396 ber_str2bv( si->base, strlen(si->base), 1, &base_bv );
397 dnPrettyNormal( 0, &base_bv, &pbase, &nbase, op.o_tmpmemctx );
399 sprintf( substr, "cn=syncrepl%d", si->id );
400 ber_str2bv( substr, strlen(substr), 1, &sub_bv );
401 dnPrettyNormal( 0, &sub_bv, &psubrdn, &nsubrdn, op.o_tmpmemctx );
403 build_new_dn( &op.o_req_dn, &pbase, &psubrdn );
404 build_new_dn( &op.o_req_ndn, &nbase, &nsubrdn );
406 ch_free( base_bv.bv_val );
407 ch_free( pbase.bv_val );
408 ch_free( nbase.bv_val );
409 ch_free( sub_bv.bv_val );
410 ch_free( psubrdn.bv_val );
411 ch_free( nsubrdn.bv_val );
413 /* set callback function */
414 cb.sc_response = cookie_callback;
417 /* search subentry to retrieve cookie */
418 si->syncCookie = NULL;
419 be->be_search( &op, &rs );
421 ch_free( op.o_req_dn.bv_val );
422 ch_free( op.o_req_ndn.bv_val );
423 filter_free( op.ors_filter );
424 ch_free( op.ors_filterstr.bv_val );
426 psub = be->be_nsuffix[0];
428 /* Delete Attributes */
429 if ( si->lastmod == LASTMOD_REQ ) {
430 descs = del_descs_lastmod;
435 for ( i = 0; descs[i] != NULL; i++ ) {
436 for ( j = 0; si->attrs[j] != NULL; j++ ) {
437 if ( !strcmp( si->attrs[j], descs[i]->ad_cname.bv_val )) {
438 ch_free( si->attrs[j] );
439 for ( k = j; si->attrs[k] != NULL; k++ ) {
440 si->attrs[k] = si->attrs[k+1];
448 for ( n = 0; si->attrs[ n ] != NULL; n++ ) ;
450 if ( si->lastmod == LASTMOD_REQ ) {
451 descs = add_descs_lastmod;
456 for ( i = 0; descs[i] != NULL; i++ ) {
457 tmp = ( char ** ) ch_realloc( si->attrs,
458 ( n + 2 ) * sizeof( char * ));
461 LDAP_LOG( OPERATION, ERR, "out of memory\n", 0,0,0 );
463 Debug( LDAP_DEBUG_ANY, "out of memory\n", 0,0,0 );
467 si->attrs[ n++ ] = ch_strdup ( descs[i]->ad_cname.bv_val );
468 si->attrs[ n ] = NULL;
471 rc = ldap_sync_search( si, ld, NULL, NULL, &msgid );
472 if( rc != LDAP_SUCCESS ) {
473 fprintf( stderr, "syncrepl: ldap_search_ext: %s (%d)\n",
474 ldap_err2string( rc ), rc );
478 while (( rc = ldap_result( ld, LDAP_RES_ANY, LDAP_MSG_ONE, NULL, &res )) > 0 ) {
480 for ( msg = ldap_first_message( ld, res );
482 msg = ldap_next_message( ld, msg ) )
484 switch( ldap_msgtype( msg ) ) {
485 case LDAP_RES_SEARCH_ENTRY:
486 entry = syncrepl_message_to_entry( si, ld, &op, msg,
487 &modlist, &syncstate, &syncUUID, &syncCookie );
488 rc_efree = syncrepl_entry( si, ld, &op, entry, modlist,
489 syncstate, &syncUUID, &syncCookie, !syncinfo_arrived );
490 if ( syncCookie.bv_len ) {
491 syncrepl_updateCookie( si, ld, &op, &psub, &syncCookie );
495 for ( ml = modlist; ml != NULL; ml = mlnext ) {
496 mlnext = ml->sml_next;
501 case LDAP_RES_SEARCH_REFERENCE:
503 LDAP_LOG( OPERATION, ERR,
504 "do_syncrepl : reference received\n", 0, 0, 0 );
506 Debug( LDAP_DEBUG_ANY,
507 "do_syncrepl : reference received\n", 0, 0, 0 );
511 case LDAP_RES_SEARCH_RESULT:
512 ldap_parse_result( ld, msg, &err, NULL, NULL, NULL, &rctrls, 0 );
515 ctrl_ber = ber_alloc_t( LBER_USE_DER );
516 ber_set_option( ctrl_ber, LBER_OPT_BER_MEMCTX, &op.o_tmpmemctx );
517 ber_write( ctrl_ber, rctrlp->ldctl_value.bv_val, rctrlp->ldctl_value.bv_len, 0 );
518 ber_reset( ctrl_ber, 1 );
520 ber_scanf( ctrl_ber, "{" /*"}"*/);
521 if ( ber_peek_tag( ctrl_ber, &len )
522 == LDAP_SYNC_TAG_COOKIE ) {
523 ber_scanf( ctrl_ber, "o", &syncCookie );
526 if (si->type == LDAP_SYNC_REFRESH_AND_PERSIST) {
527 if ( cancel_response ) {
528 if ( syncCookie.bv_len ) {
529 syncrepl_updateCookie( si, ld, &op, &psub, &syncCookie );
532 ber_free( ctrl_ber, 1 );
537 ber_free( ctrl_ber, 1 );
541 if ( syncCookie.bv_len ) {
542 syncrepl_updateCookie( si, ld, &op, &psub, &syncCookie);
544 if ( si->sync_mode == LDAP_SYNC_STATE_MODE )
545 syncrepl_del_nonpresent( ld, &op );
547 ber_free( ctrl_ber, 1 );
552 case LDAP_RES_INTERMEDIATE:
553 rc = ldap_parse_intermediate( ld, msg,
554 &retoid, &retdata, NULL, 0 );
555 if ( !rc && !strcmp( retoid, LDAP_SYNC_INFO ) ) {
556 sync_info_arrived = 1;
557 res_ber = ber_init( retdata );
558 ber_scanf( res_ber, "{e" /*"}"*/, &syncstate );
560 if ( syncstate == LDAP_SYNC_STATE_MODE_DONE ) {
561 syncrepl_del_nonpresent( ld, &op );
562 si->sync_mode = LDAP_SYNC_LOG_MODE;
563 } else if ( syncstate == LDAP_SYNC_LOG_MODE_DONE ) {
564 si->sync_mode = LDAP_SYNC_PERSIST_MODE;
565 } else if ( syncstate == LDAP_SYNC_REFRESH_DONE ) {
566 si->sync_mode = LDAP_SYNC_PERSIST_MODE;
567 } else if ( syncstate != LDAP_SYNC_NEW_COOKIE ||
568 syncstate != LDAP_SYNC_LOG_MODE_DONE ) {
570 LDAP_LOG( OPERATION, ERR,
571 "do_syncrepl : unknown sync info\n", 0, 0, 0 );
573 Debug( LDAP_DEBUG_ANY,
574 "do_syncrepl : unknown sync info\n", 0, 0, 0 );
578 if ( ber_peek_tag( res_ber, &len )
579 == LDAP_SYNC_TAG_COOKIE ) {
580 ber_scanf( res_ber, /*"{"*/ "o}", &syncCookie );
581 if ( syncCookie.bv_len ) {
582 syncrepl_updateCookie( si, ld, &op, &psub, &syncCookie);
585 if ( syncstate == LDAP_SYNC_NEW_COOKIE ) {
587 LDAP_LOG( OPERATION, ERR,
588 "do_syncrepl : cookie required\n", 0, 0, 0 );
590 Debug( LDAP_DEBUG_ANY,
591 "do_syncrepl : cookie required\n", 0, 0, 0 );
596 ldap_memfree( retoid );
597 ber_bvfree( retdata );
598 ber_free( res_ber, 1 );
602 LDAP_LOG( OPERATION, ERR,"do_syncrepl :"
603 " unknown intermediate "
604 "response\n", 0, 0, 0 );
606 Debug( LDAP_DEBUG_ANY, "do_syncrepl : "
607 "unknown intermediate response (%d)\n",
610 ldap_memfree( retoid );
611 ber_bvfree( retdata );
617 LDAP_LOG( OPERATION, ERR, "do_syncrepl : "
618 "unknown message\n", 0, 0, 0 );
620 Debug( LDAP_DEBUG_ANY, "do_syncrepl : "
621 "unknown message\n", 0, 0, 0 );
632 LDAP_LOG( OPERATION, ERR,
633 "do_syncrepl : unknown result\n", 0, 0, 0 );
635 Debug( LDAP_DEBUG_ANY,
636 "do_syncrepl : unknown result\n", 0, 0, 0 );
641 if ( syncCookie.bv_val )
642 ch_free( syncCookie.bv_val );
643 if ( syncUUID.bv_val )
644 ch_free( syncUUID.bv_val );
650 ldap_pvt_thread_mutex_lock( &syncrepl_rq.rq_mutex );
651 ldap_pvt_runqueue_stoptask( &syncrepl_rq, rtask );
652 if ( si->type == LDAP_SYNC_REFRESH_ONLY ) {
653 ldap_pvt_runqueue_resched( &syncrepl_rq, rtask );
655 ldap_pvt_runqueue_remove( &syncrepl_rq, rtask );
657 ldap_pvt_thread_mutex_unlock( &syncrepl_rq.rq_mutex );
663 syncrepl_message_to_entry(
668 Modifications **modlist,
670 struct berval *syncUUID,
671 struct berval *syncCookie
675 BerElement *ber = NULL;
677 struct berval bv = {0, NULL};
680 Modifications **modtail = modlist;
681 Backend *be = op->o_bd;
684 char txtbuf[SLAP_TEXT_BUFLEN];
685 size_t textlen = sizeof txtbuf;
687 struct berval **bvals = NULL;
689 struct berval bdn = {0, NULL};
691 struct berval empty_bv = { 0, NULL };
697 LDAPControl** rctrls = NULL;
698 BerElement* ctrl_ber;
702 Modifications *prevml = NULL;
703 Modifications *nextml = NULL;
704 Modifications *ml = NULL;
705 AttributeDescription** descs;
710 if ( ldap_msgtype( msg ) != LDAP_RES_SEARCH_ENTRY ) {
712 LDAP_LOG( OPERATION, ERR,
713 "Message type should be entry (%d)", ldap_msgtype( msg ), 0, 0 );
715 Debug( LDAP_DEBUG_ANY,
716 "Message type should be entry (%d)", ldap_msgtype( msg ), 0, 0 );
721 op->o_tag = LDAP_REQ_ADD;
723 rc = ldap_get_dn_ber( ld, msg, &ber, &bdn );
725 if ( rc != LDAP_SUCCESS ) {
727 LDAP_LOG( OPERATION, ERR,
728 "syncrepl_message_to_entry : dn get failed (%d)", rc, 0, 0 );
730 Debug( LDAP_DEBUG_ANY,
731 "syncrepl_message_to_entry : dn get failed (%d)", rc, 0, 0 );
736 e = ( Entry * ) ch_calloc( 1, sizeof( Entry ));
737 dnPrettyNormal( NULL, &bdn, &e->e_name, &e->e_nname, NULL );
741 while ( ber_remaining( ber ) ) {
742 tag = ber_scanf( ber, "{mW}", &tmp.sml_type, &tmp.sml_values );
744 if ( tag == LBER_ERROR ) break;
745 if ( tmp.sml_type.bv_val == NULL ) break;
747 mod = (Modifications *) ch_malloc( sizeof( Modifications ));
749 mod->sml_op = LDAP_MOD_REPLACE;
750 mod->sml_next = NULL;
751 mod->sml_desc = NULL;
752 mod->sml_type = tmp.sml_type;
753 mod->sml_bvalues = tmp.sml_bvalues;
754 mod->sml_nvalues = tmp.sml_bvalues;
757 modtail = &mod->sml_next;
760 if ( ber_scanf( ber, "}") == LBER_ERROR ) {
762 LDAP_LOG( OPERATION, ERR,
763 "syncrepl_message_to_entry: ber_scanf failed\n", 0, 0, 0 );
765 Debug( LDAP_DEBUG_ANY, "syncrepl_message_to_entry: ber_scanf failed\n",
772 tmpber = ldap_get_message_ber( msg );
773 ber = ber_dup( tmpber );
775 ber_scanf( ber, "{xx" );
777 rc = ldap_int_get_controls( ber, &rctrls );
779 if ( rc != LDAP_SUCCESS ) {
781 LDAP_LOG( OPERATION, ERR,
782 "syncrepl_message_to_entry : control get failed (%d)", rc, 0, 0 );
784 Debug( LDAP_DEBUG_ANY,
785 "syncrepl_message_to_entry : control get failed (%d)", rc, 0, 0 );
792 ctrl_ber = ber_alloc_t( LBER_USE_DER );
793 ber_set_option( ctrl_ber, LBER_OPT_BER_MEMCTX, &op->o_tmpmemctx );
794 ber_write( ctrl_ber, rctrlp->ldctl_value.bv_val, rctrlp->ldctl_value.bv_len, 0 );
795 ber_reset( ctrl_ber, 1 );
796 ber_scanf( ctrl_ber, "{eo", syncstate, syncUUID );
797 if ( ber_peek_tag( ctrl_ber, &len ) == LDAP_SYNC_TAG_COOKIE ) {
798 ber_scanf( ctrl_ber, "o}", syncCookie );
800 ber_free( ctrl_ber, 1 );
803 LDAP_LOG( OPERATION, ERR,"syncrepl_message_to_entry : "
804 " rctrls absent\n", 0, 0, 0 );
806 Debug( LDAP_DEBUG_ANY, "syncrepl_message_to_entry :"
807 " rctrls absent\n", 0, 0, 0 );
811 if ( *syncstate == LDAP_SYNC_PRESENT ) {
814 } else if ( *syncstate == LDAP_SYNC_DELETE ) {
818 if ( *modlist == NULL ) {
820 LDAP_LOG( OPERATION, ERR,
821 "syncrepl_message_to_entry: no attributes\n", 0, 0, 0 );
823 Debug( LDAP_DEBUG_ANY, "syncrepl_message_to_entry: no attributes\n",
829 while ( ml != NULL ) {
830 AttributeDescription *ad = NULL;
831 rc = slap_bv2ad( &ml->sml_type, &ml->sml_desc, &text );
833 if( rc != LDAP_SUCCESS ) {
841 if ( si->lastmod == LASTMOD_REQ ) {
842 descs = del_descs_lastmod;
847 for ( i = 0; descs[i] != NULL; i++ ) {
848 if ( ad == descs[i] ) {
849 if ( prevml == NULL ) {
850 modlist = &ml->sml_next;
853 prevml->sml_next = ml->sml_next;
855 slap_mod_free( &ml->sml_mod, 0 );
856 nextml = ml->sml_next;
866 rc = slap_mods_check( *modlist, 1, &text, txtbuf, textlen, NULL );
868 if ( rc != LDAP_SUCCESS ) {
870 LDAP_LOG( OPERATION, ERR,
871 "syncrepl_message_to_entry: mods check (%s)\n", text, 0, 0 );
873 Debug( LDAP_DEBUG_ANY, "syncrepl_message_to_entry: mods check (%s)\n",
879 rc = slap_mods_opattrs( op, *modlist, modtail,
880 &text,txtbuf, textlen );
882 if( rc != LDAP_SUCCESS ) {
884 LDAP_LOG( OPERATION, ERR,
885 "syncrepl_message_to_entry: mods opattrs (%s)\n", text, 0, 0 );
887 Debug( LDAP_DEBUG_ANY, "syncrepl_message_to_entry: mods opattrs (%s)\n",
893 rc = slap_mods2entry( *modlist, &e, 1, 1, &text, txtbuf, textlen);
894 if( rc != LDAP_SUCCESS ) {
896 LDAP_LOG( OPERATION, ERR,
897 "syncrepl_message_to_entry: mods2entry (%s)\n", text, 0, 0 );
899 Debug( LDAP_DEBUG_ANY, "syncrepl_message_to_entry: mods2entry (%s)\n",
912 syncuuid_cmp( const void* v_uuid1, const void* v_uuid2 )
914 const struct berval *uuid1 = v_uuid1;
915 const struct berval *uuid2 = v_uuid2;
916 int rc = uuid1->bv_len - uuid2->bv_len;
918 return ( strcmp( uuid1->bv_val, uuid2->bv_val ) );
927 Modifications* modlist,
929 struct berval* syncUUID,
930 struct berval* syncCookie,
934 Backend *be = op->o_bd;
936 struct berval csn_bv = {0, NULL};
937 struct berval *syncuuid_bv = NULL;
938 char csnbuf[ LDAP_LUTIL_CSNSTR_BUFSIZE ];
940 SlapReply rs = {REP_RESULT};
941 int rc = LDAP_SUCCESS;
943 struct berval base_bv = {0, NULL};
951 ( syncstate == LDAP_SYNC_PRESENT || syncstate == LDAP_SYNC_ADD )) {
952 syncuuid_bv = ber_dupbv( NULL, syncUUID );
953 avl_insert( &si->presentlist, (caddr_t) syncuuid_bv,
954 syncuuid_cmp, avl_dup_error );
957 if ( syncstate == LDAP_SYNC_PRESENT ) {
964 filterstr = (char *) sl_malloc( strlen("entryUUID=") + syncUUID->bv_len + 1,
966 strcpy( filterstr, "entryUUID=" );
967 strcat( filterstr, syncUUID->bv_val );
970 si->syncUUID = syncUUID;
971 si->syncUUID_ndn = NULL;
973 filter = str2filter( filterstr );
974 ber_str2bv( filterstr, strlen(filterstr), 1, &op->ors_filterstr );
975 ch_free( filterstr );
976 op->ors_filter = filter;
977 op->ors_scope = LDAP_SCOPE_SUBTREE;
979 /* get syncrepl cookie of shadow replica from subentry */
980 ber_str2bv( si->base, strlen(si->base), 1, &base_bv );
981 dnPrettyNormal( 0, &base_bv, &op->o_req_dn, &op->o_req_ndn, op->o_tmpmemctx );
982 ch_free( base_bv.bv_val );
984 /* set callback function */
985 op->o_callback = &cb;
986 cb.sc_response = dn_callback;
989 rc = be->be_search( op, &rs );
991 ch_free( op->o_req_dn.bv_val );
992 ch_free( op->o_req_ndn.bv_val );
993 filter_free( op->ors_filter );
994 ch_free( op->ors_filterstr.bv_val );
996 cb.sc_response = null_callback;
999 if ( rc == LDAP_SUCCESS && si->syncUUID_ndn && si->sync_mode != LDAP_SYNC_LOG_MODE ) {
1000 op->o_req_dn = *si->syncUUID_ndn;
1001 op->o_req_ndn = *si->syncUUID_ndn;
1002 op->o_tag = LDAP_REQ_DELETE;
1003 rc = be->be_delete( op, &rs );
1006 if ( si->syncUUID_ndn ) {
1007 ber_bvfree( si->syncUUID_ndn );
1010 switch ( syncstate ) {
1011 case LDAP_SYNC_ADD :
1012 case LDAP_SYNC_MODIFY :
1014 if ( rc == LDAP_SUCCESS ||
1015 rc == LDAP_REFERRAL ||
1016 rc == LDAP_NO_SUCH_OBJECT ) {
1018 if ( !attr_find( e->e_attrs, slap_schema.si_ad_entryUUID )) {
1019 attr_merge_normalize_one( e, slap_schema.si_ad_entryUUID, syncUUID, op->o_tmpmemctx );
1022 op->o_tag = LDAP_REQ_ADD;
1024 op->o_req_dn = e->e_name;
1025 op->o_req_ndn = e->e_nname;
1026 rc = be->be_add( op, &rs );
1028 if ( rc != LDAP_SUCCESS ) {
1029 if ( rc == LDAP_ALREADY_EXISTS ) {
1030 op->o_tag = LDAP_REQ_MODIFY;
1031 op->orm_modlist = modlist;
1032 op->o_req_dn = e->e_name;
1033 op->o_req_ndn = e->e_nname;
1034 rc = be->be_modify( op, &rs );
1037 } else if ( rc == LDAP_REFERRAL ||
1038 rc == LDAP_NO_SUCH_OBJECT ) {
1039 syncrepl_add_glue( si, ld, op, e,
1041 syncUUID, syncCookie);
1046 LDAP_LOG( OPERATION, ERR,
1047 "be_modify failed (%d)\n",
1050 Debug( LDAP_DEBUG_ANY,
1051 "be_modify failed (%d)\n",
1059 be_entry_release_w( op, e );
1064 LDAP_LOG( OPERATION, ERR,
1065 "be_modify/be_delete failed (%d)\n", rc, 0, 0 );
1067 Debug( LDAP_DEBUG_ANY,
1068 "be_modify/be_delete failed (%d)\n", rc, 0, 0 );
1074 case LDAP_SYNC_DELETE :
1075 if ( si->sync_mode == LDAP_SYNC_LOG_MODE ) {
1076 op->o_req_dn = *si->syncUUID_ndn;
1077 op->o_req_ndn = *si->syncUUID_ndn;
1078 op->o_tag = LDAP_REQ_DELETE;
1079 rc = be->be_delete( op, &rs );
1081 /* Already deleted otherwise */
1086 LDAP_LOG( OPERATION, ERR,
1087 "unknown syncstate\n", 0, 0, 0 );
1089 Debug( LDAP_DEBUG_ANY,
1090 "unknown syncstate\n", 0, 0, 0 );
1097 syncrepl_del_nonpresent(
1102 Backend* be = op->o_bd;
1103 syncinfo_t *si = op->o_si;
1105 struct berval base_bv = {0, NULL};
1107 SlapReply rs = {REP_RESULT};
1108 struct berval filterstr_bv = {0, NULL};
1109 struct nonpresent_entry *np_list, *np_prev;
1111 ber_str2bv( si->base, strlen(si->base), 1, &base_bv );
1112 dnPrettyNormal(0, &base_bv, &op->o_req_dn, &op->o_req_ndn, op->o_tmpmemctx );
1113 ch_free( base_bv.bv_val );
1115 filter = str2filter( si->filterstr );
1117 cb.sc_response = nonpresent_callback;
1120 op->o_callback = &cb;
1121 op->o_tag = LDAP_REQ_SEARCH;
1122 op->ors_scope = si->scope;
1123 op->ors_deref = LDAP_DEREF_NEVER;
1126 op->ors_attrsonly = 0;
1127 op->ors_attrs = NULL;
1128 op->ors_filter = filter;
1129 ber_str2bv( si->filterstr, strlen( si->filterstr ), 1, &op->ors_filterstr );
1131 be->be_search( op, &rs );
1133 if ( !LDAP_LIST_EMPTY( &si->nonpresentlist ) ) {
1134 np_list = LDAP_LIST_FIRST( &si->nonpresentlist );
1135 while ( np_list != NULL ) {
1136 LDAP_LIST_REMOVE( np_list, np_link );
1138 np_list = LDAP_LIST_NEXT( np_list, np_link );
1139 op->o_tag = LDAP_REQ_DELETE;
1140 op->o_callback = &cb;
1141 cb.sc_response = null_callback;
1143 op->o_req_dn = *np_prev->dn;
1144 op->o_req_ndn = *np_prev->ndn;
1145 op->o_bd->be_delete( op, &rs );
1146 ber_bvfree( np_prev->dn );
1147 ber_bvfree( np_prev->ndn );
1148 op->o_req_dn.bv_val = NULL;
1149 op->o_req_ndn.bv_val = NULL;
1154 if ( op->o_req_dn.bv_val )
1155 ch_free( op->o_req_dn.bv_val );
1156 if ( op->o_req_ndn.bv_val )
1157 ch_free( op->o_req_ndn.bv_val );
1158 filter_free( op->ors_filter );
1159 ch_free( op->ors_filterstr.bv_val );
1171 Modifications* modlist,
1173 struct berval* syncUUID,
1174 struct berval* syncCookie
1177 Backend *be = op->o_bd;
1178 struct berval uuid_bv = {0, NULL};
1182 char uuidbuf[ LDAP_LUTIL_UUIDSTR_BUFSIZE ];
1185 struct berval dn = {0, NULL};
1186 struct berval pdn = {0, NULL};
1187 struct berval ndn = {0, NULL};
1188 struct berval rdn = {0, NULL};
1190 SlapReply rs = {REP_RESULT};
1191 Connection *conn = op->o_conn;
1194 op->o_tag = LDAP_REQ_ADD;
1195 op->o_callback = &cb;
1196 cb.sc_response = null_callback;
1199 ber_dupbv( &dn, &e->e_nname );
1200 ber_dupbv( &pdn, &e->e_nname );
1203 while ( !be_issuffix ( be, &pdn )) {
1204 dnParent( &dn, &pdn );
1205 dn.bv_val = pdn.bv_val;
1206 dn.bv_len = pdn.bv_len;
1211 for ( i = 0; i <= levels; i++ ) {
1212 glue = (Entry*) ch_calloc( 1, sizeof(Entry) );
1213 ber_dupbv( &dn, &e->e_nname );
1217 for ( k = 0; k < j; k++ ) {
1218 dnParent( &dn, &pdn );
1219 dn.bv_val = pdn.bv_val;
1220 dn.bv_len = pdn.bv_len;
1223 dnPrettyNormal( 0, &dn, &pdn, &ndn, op->o_tmpmemctx );
1224 ber_dupbv( &glue->e_name, &pdn );
1225 ber_dupbv( &glue->e_nname, &ndn );
1227 ch_free( pdn.bv_val );
1228 ch_free( ndn.bv_val );
1230 a = ch_calloc( 1, sizeof( Attribute ));
1231 a->a_desc = slap_schema.si_ad_objectClass;
1233 a->a_vals = ch_calloc( 3, sizeof( struct berval ));
1234 ber_str2bv( "top", strlen("top"), 1, &a->a_vals[0] );
1235 ber_str2bv( "glue", strlen("glue"), 1, &a->a_vals[1] );
1236 a->a_vals[2].bv_len = 0;
1237 a->a_vals[2].bv_val = NULL;
1239 a->a_nvals = ch_calloc( 3, sizeof( struct berval ));
1240 ber_str2bv( "top", strlen("top"), 1, &a->a_nvals[0] );
1241 ber_str2bv( "glue", strlen("glue"), 1, &a->a_nvals[1] );
1242 a->a_nvals[2].bv_len = 0;
1243 a->a_nvals[2].bv_val = NULL;
1245 a->a_next = glue->e_attrs;
1248 a = ch_calloc( 1, sizeof( Attribute ));
1249 a->a_desc = slap_schema.si_ad_structuralObjectClass;
1251 a->a_vals = ch_calloc( 2, sizeof( struct berval ));
1252 ber_str2bv( "glue", strlen("glue"), 1, &a->a_vals[0] );
1253 a->a_vals[1].bv_len = 0;
1254 a->a_vals[1].bv_val = NULL;
1256 a->a_nvals = ch_calloc( 2, sizeof( struct berval ));
1257 ber_str2bv( "glue", strlen("glue"), 1, &a->a_nvals[0] );
1258 a->a_nvals[1].bv_len = 0;
1259 a->a_nvals[1].bv_val = NULL;
1261 a->a_next = glue->e_attrs;
1264 if ( !strcmp( e->e_nname.bv_val, glue->e_nname.bv_val )) {
1265 op->o_req_dn = e->e_name;
1266 op->o_req_ndn = e->e_nname;
1268 rc = be->be_add ( op, &rs );
1269 if ( rc == LDAP_SUCCESS )
1270 be_entry_release_w( op, e );
1275 op->o_req_dn = glue->e_name;
1276 op->o_req_ndn = glue->e_nname;
1278 rc = be->be_add ( op, &rs );
1279 if ( rc == LDAP_SUCCESS ) {
1280 be_entry_release_w( op, glue );
1282 /* incl. ALREADY EXIST */
1292 syncrepl_updateCookie(
1297 struct berval *syncCookie
1300 Backend *be = op->o_bd;
1302 Modifications *mlnext;
1304 Modifications *modlist;
1305 Modifications **modtail = &modlist;
1307 struct berval* ocbva = NULL;
1308 struct berval* cnbva = NULL;
1309 struct berval* ssbva = NULL;
1310 struct berval* scbva = NULL;
1315 char txtbuf[SLAP_TEXT_BUFLEN];
1316 size_t textlen = sizeof txtbuf;
1321 struct berval sub_bv = { 0, NULL };
1322 struct berval psubrdn = { 0, NULL };
1325 SlapReply rs = {REP_RESULT};
1327 ocbva = ( struct berval * ) ch_calloc( 4, sizeof( struct berval ));
1328 cnbva = ( struct berval * ) ch_calloc( 2, sizeof( struct berval ));
1329 ssbva = ( struct berval * ) ch_calloc( 2, sizeof( struct berval ));
1330 scbva = ( struct berval * ) ch_calloc( 2, sizeof( struct berval ));
1332 /* update in memory cookie */
1333 if ( si->syncCookie != NULL ) {
1334 ber_bvfree( si->syncCookie );
1336 si->syncCookie = ber_dupbv( NULL, syncCookie );
1337 ber_str2bv( "top", strlen("top"), 1, &ocbva[0] );
1338 ber_str2bv( "subentry", strlen("subentry"), 1, &ocbva[1] );
1339 ber_str2bv( "syncConsumerSubentry",
1340 strlen("syncConsumerSubentry"), 1, &ocbva[2] );
1341 ocbva[3].bv_len = 0;
1342 ocbva[3].bv_val = NULL;
1344 mod = (Modifications *) ch_malloc( sizeof( Modifications ));
1345 mod->sml_op = LDAP_MOD_REPLACE;
1346 mod->sml_next = NULL;
1347 mod->sml_desc = NULL;
1348 ber_str2bv( "objectClass", strlen("objectClass"), 1, &mod->sml_type );
1349 mod->sml_bvalues = ocbva;
1350 mod->sml_nvalues = ocbva;
1352 modtail = &mod->sml_next;
1354 sprintf( substr, "syncrepl%d", si->id );
1355 sprintf( rdnstr, "cn=%s", substr );
1356 ber_str2bv( substr, strlen( substr ), 1, &cnbva[0] );
1357 ber_str2bv( rdnstr, strlen( rdnstr ), 1, &psubrdn );
1358 cnbva[1].bv_len = 0;
1359 cnbva[1].bv_val = NULL;
1360 mod = (Modifications *) ch_malloc( sizeof( Modifications ));
1361 mod->sml_op = LDAP_MOD_REPLACE;
1362 mod->sml_next = NULL;
1363 mod->sml_desc = NULL;
1364 ber_str2bv( "cn", strlen("cn"), 1, &mod->sml_type );
1365 mod->sml_bvalues = cnbva;
1366 mod->sml_nvalues = cnbva;
1368 modtail = &mod->sml_next;
1370 ber_dupbv( &scbva[0], si->syncCookie );
1371 scbva[1].bv_len = 0;
1372 scbva[1].bv_val = NULL;
1373 mod = (Modifications *) ch_malloc( sizeof( Modifications ));
1374 mod->sml_op = LDAP_MOD_REPLACE;
1375 mod->sml_next = NULL;
1376 mod->sml_desc = NULL;
1377 ber_str2bv( "syncreplCookie", strlen("syncreplCookie"),
1378 1, &mod->sml_type );
1379 mod->sml_bvalues = scbva;
1380 mod->sml_nvalues = scbva;
1382 modtail = &mod->sml_next;
1384 ber_str2bv( "{}", strlen("{}"), 1, &ssbva[0] );
1385 ssbva[1].bv_len = 0;
1386 ssbva[1].bv_val = NULL;
1387 mod = (Modifications *) ch_malloc( sizeof( Modifications ));
1388 mod->sml_op = LDAP_MOD_REPLACE;
1389 mod->sml_next = NULL;
1390 mod->sml_desc = NULL;
1391 ber_str2bv( "subtreeSpecification",
1392 strlen("subtreeSpecification"), 1, &mod->sml_type );
1393 mod->sml_bvalues = ssbva;
1394 mod->sml_nvalues = ssbva;
1396 modtail = &mod->sml_next;
1398 rc = slap_mods_check( modlist, 1, &text, txtbuf, textlen, NULL );
1400 if ( rc != LDAP_SUCCESS ) {
1402 LDAP_LOG( OPERATION, ERR,
1403 "syncrepl_updateCookie: mods check (%s)\n", text, 0, 0 );
1405 Debug( LDAP_DEBUG_ANY, "syncrepl_updateCookie: mods check (%s)\n",
1410 op->o_tag = LDAP_REQ_ADD;
1411 rc = slap_mods_opattrs( op, modlist, modtail,
1412 &text,txtbuf, textlen );
1414 for ( ml = modlist; ml != NULL; ml = mlnext ) {
1415 mlnext = ml->sml_next;
1416 if ( ml->sml_desc == slap_schema.si_ad_structuralObjectClass )
1417 ml->sml_op = LDAP_MOD_REPLACE;
1420 if( rc != LDAP_SUCCESS ) {
1422 LDAP_LOG( OPERATION, ERR,
1423 "syncrepl_updateCookie: mods opattrs (%s)\n", text, 0, 0 );
1425 Debug( LDAP_DEBUG_ANY, "syncrepl_updateCookie: mods opattrs (%s)\n",
1430 e = ( Entry * ) ch_calloc( 1, sizeof( Entry ));
1432 build_new_dn( &sub_bv, pdn, &psubrdn );
1433 dnPrettyNormal( NULL, &sub_bv, &e->e_name, &e->e_nname, NULL );
1434 ch_free( sub_bv.bv_val );
1435 ch_free( psubrdn.bv_val );
1439 rc = slap_mods2entry( modlist, &e, 1, 1, &text, txtbuf, textlen );
1441 if( rc != LDAP_SUCCESS ) {
1443 LDAP_LOG( OPERATION, ERR,
1444 "syncrepl_updateCookie: mods2entry (%s)\n", text, 0, 0 );
1446 Debug( LDAP_DEBUG_ANY, "syncrepl_updateCookie: mods2entry (%s)\n",
1451 cb.sc_response = null_callback;
1454 op->o_callback = &cb;
1455 op->o_req_dn = e->e_name;
1456 op->o_req_ndn = e->e_nname;
1458 /* update persistent cookie */
1459 update_cookie_retry:
1460 op->o_tag = LDAP_REQ_MODIFY;
1461 op->orm_modlist = modlist;
1462 rc = be->be_modify( op, &rs );
1463 if ( rc != LDAP_SUCCESS ) {
1464 if ( rc == LDAP_REFERRAL ||
1465 rc == LDAP_NO_SUCH_OBJECT ) {
1466 op->o_tag = LDAP_REQ_ADD;
1468 rc = be->be_add( op, &rs );
1469 if ( rc != LDAP_SUCCESS ) {
1470 if ( rc == LDAP_ALREADY_EXISTS ) {
1471 goto update_cookie_retry;
1472 } else if ( rc == LDAP_REFERRAL ||
1473 rc == LDAP_NO_SUCH_OBJECT ) {
1475 LDAP_LOG( OPERATION, ERR,
1476 "cookie will be non-persistent\n",
1479 Debug( LDAP_DEBUG_ANY,
1480 "cookie will be non-persistent\n",
1485 LDAP_LOG( OPERATION, ERR,
1486 "be_add failed (%d)\n",
1489 Debug( LDAP_DEBUG_ANY,
1490 "be_add failed (%d)\n",
1495 be_entry_release_w( op, e );
1500 LDAP_LOG( OPERATION, ERR,
1501 "be_modify failed (%d)\n", rc, 0, 0 );
1503 Debug( LDAP_DEBUG_ANY,
1504 "be_modify failed (%d)\n", rc, 0, 0 );
1514 for ( ml = modlist; ml != NULL; ml = mlnext ) {
1515 mlnext = ml->sml_next;
1523 avl_ber_bvfree( void *bv )
1528 if ( ((struct berval *)bv)->bv_val != NULL ) {
1529 ber_memfree ( ((struct berval *)bv)->bv_val );
1531 ber_memfree ( (char *) bv );
1540 syncinfo_t *si = op->o_callback->sc_private;
1543 if ( rs->sr_type != REP_SEARCH ) return LDAP_SUCCESS;
1545 a = attr_find( rs->sr_entry->e_attrs, slap_schema.si_ad_syncreplCookie );
1548 si->syncCookie = NULL;
1550 si->syncCookie = ber_dupbv( NULL, &a->a_vals[0] );
1552 return LDAP_SUCCESS;
1561 syncinfo_t *si = op->o_callback->sc_private;
1563 if ( rs->sr_type == REP_SEARCH ) {
1564 si->syncUUID_ndn = ber_dupbv( NULL, &rs->sr_entry->e_nname );
1567 return LDAP_SUCCESS;
1571 nonpresent_callback(
1576 syncinfo_t *si = op->o_callback->sc_private;
1579 struct berval* present_uuid = NULL;
1581 SlapReply rs_cb = {REP_RESULT};
1582 struct nonpresent_entry *np_entry;
1584 if ( rs->sr_type == REP_RESULT ) {
1585 count = avl_free( si->presentlist, avl_ber_bvfree );
1586 si->presentlist = NULL;
1587 return LDAP_SUCCESS;
1588 } else if ( rs->sr_type == REP_SEARCH ) {
1589 a = attr_find( rs->sr_entry->e_attrs, slap_schema.si_ad_entryUUID );
1594 present_uuid = avl_find( si->presentlist, &a->a_vals[0], syncuuid_cmp );
1596 if ( present_uuid == NULL ) {
1597 np_entry = (struct nonpresent_entry *)
1598 ch_calloc( 1, sizeof( struct nonpresent_entry ));
1599 np_entry->dn = ber_dupbv( NULL, &rs->sr_entry->e_name );
1600 np_entry->ndn = ber_dupbv( NULL, &rs->sr_entry->e_nname );
1601 LDAP_LIST_INSERT_HEAD( &si->nonpresentlist, np_entry, np_link );
1603 avl_delete( &si->presentlist,
1604 &a->a_vals[0], syncuuid_cmp );
1606 return LDAP_SUCCESS;
1608 return LDAP_SUCCESS;
1619 syncinfo_t *si = op->o_callback->sc_private;
1621 if ( rs->sr_err != LDAP_SUCCESS &&
1622 rs->sr_err != LDAP_REFERRAL &&
1623 rs->sr_err != LDAP_ALREADY_EXISTS &&
1624 rs->sr_err != LDAP_NO_SUCH_OBJECT ) {
1626 LDAP_LOG( OPERATION, ERR,
1627 "null_callback : error code 0x%x\n",
1630 Debug( LDAP_DEBUG_ANY,
1631 "null_callback : error code 0x%x\n",
1635 return LDAP_SUCCESS;
1640 str2clist( char ***out, char *in, const char *brkstr )
1649 /* find last element in list */
1650 for (i = 0; *out && *out[i]; i++);
1652 /* protect the input string from strtok */
1653 str = ch_strdup( in );
1655 /* Count words in string */
1657 for ( s = str; *s; s++ ) {
1658 if ( strchr( brkstr, *s ) != NULL ) {
1663 *out = ch_realloc( *out, ( i + j + 1 ) * sizeof( char * ) );
1665 for ( s = ldap_pvt_strtok( str, brkstr, &lasts );
1667 s = ldap_pvt_strtok( NULL, brkstr, &lasts ) )
1669 *new = ch_strdup( s );