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 * );
49 static AttributeDescription **add_descs;
50 static AttributeDescription **add_descs_lastmod;
51 static AttributeDescription **del_descs;
52 static AttributeDescription **del_descs_lastmod;
54 struct runqueue_s syncrepl_rq;
59 add_descs = ch_malloc( 2 * sizeof( AttributeDescription * ));
60 add_descs[0] = slap_schema.si_ad_objectClass;
63 add_descs_lastmod = ch_malloc( 7 * sizeof( AttributeDescription * ));
64 add_descs_lastmod[0] = slap_schema.si_ad_objectClass;
65 add_descs_lastmod[1] = slap_schema.si_ad_creatorsName;
66 add_descs_lastmod[2] = slap_schema.si_ad_modifiersName;
67 add_descs_lastmod[3] = slap_schema.si_ad_createTimestamp;
68 add_descs_lastmod[4] = slap_schema.si_ad_modifyTimestamp;
69 add_descs_lastmod[5] = slap_schema.si_ad_entryCSN;
70 add_descs_lastmod[6] = NULL;
72 del_descs = ch_malloc( 9 * sizeof( AttributeDescription * ));
73 del_descs[0] = slap_schema.si_ad_structuralObjectClass;
74 del_descs[1] = slap_schema.si_ad_subschemaSubentry;
75 del_descs[2] = slap_schema.si_ad_hasSubordinates;
76 del_descs[3] = slap_schema.si_ad_creatorsName;
77 del_descs[4] = slap_schema.si_ad_modifiersName;
78 del_descs[5] = slap_schema.si_ad_createTimestamp;
79 del_descs[6] = slap_schema.si_ad_modifyTimestamp;
80 del_descs[7] = slap_schema.si_ad_entryCSN;
83 del_descs_lastmod = ch_malloc( 4 * sizeof( AttributeDescription * ));
84 del_descs_lastmod[0] = slap_schema.si_ad_structuralObjectClass;
85 del_descs_lastmod[1] = slap_schema.si_ad_subschemaSubentry;
86 del_descs_lastmod[2] = slap_schema.si_ad_hasSubordinates;
87 del_descs_lastmod[3] = NULL;
103 BerElement *sync_ber = NULL;
104 struct berval *sync_bvalp = NULL;
108 struct timeval timeout;
110 /* setup LDAP SYNC control */
111 sync_ber = ber_alloc_t( LBER_USE_DER );
112 ber_set_option( sync_ber, LBER_OPT_BER_MEMCTX, NULL );
114 if ( si->syncCookie ) {
115 ber_printf( sync_ber, "{eO}", abs(si->type), si->syncCookie );
117 ber_printf( sync_ber, "{e}", abs(si->type) );
120 if ( ber_flatten( sync_ber, &sync_bvalp ) == LBER_ERROR ) {
121 ber_free( sync_ber, 1 );
124 ber_free( sync_ber, 1 );
126 ctrls = (LDAPControl**) sl_calloc( 3, sizeof(LDAPControl*), NULL );
128 c[0].ldctl_oid = LDAP_CONTROL_SYNC;
129 c[0].ldctl_value = (*sync_bvalp);
130 c[0].ldctl_iscritical = si->type < 0;
134 c[1].ldctl_oid = LDAP_CONTROL_PROXY_AUTHZ;
135 c[1].ldctl_value.bv_val = si->authzId;
136 c[1].ldctl_value.bv_len = strlen( si->authzId );
137 c[1].ldctl_iscritical = 1;
145 err = ldap_set_option( ld, LDAP_OPT_SERVER_CONTROLS, ctrls );
147 ber_bvfree( sync_bvalp );
150 if ( err != LDAP_OPT_SUCCESS )
151 fprintf( stderr, "Could not set controls : %d\n", err );
153 timeout.tv_sec = si->tlimit > 0 ? si->tlimit : 1;
155 rc = ldap_search_ext( ld, si->base, si->scope, si->filterstr,
156 si->attrs, si->attrsonly, sctrls, cctrls,
157 si->tlimit < 0 ? NULL : &timeout,
158 si->slimit, msgidp );
168 struct re_s* rtask = arg;
169 syncinfo_t *si = ( syncinfo_t * ) rtask->arg;
170 Backend *be = si->be;
172 SlapReply rs = {REP_RESULT};
175 LDAPControl **sctrls = NULL;
176 LDAPControl **rctrls = NULL;
177 LDAPControl *rctrlp = NULL;
178 BerElement *sync_ber = NULL;
179 struct berval *sync_bvalp = NULL;
181 BerElement *ctrl_ber = NULL;
182 BerElement *res_ber = NULL;
185 LDAPMessage *res = NULL;
186 LDAPMessage *msg = NULL;
190 int nresponses, nreferences, nextended, npartial;
191 int nresponses_psearch;
193 int cancel_msgid = -1;
195 struct berval *retdata = NULL;
197 int sync_info_arrived = 0;
201 struct berval syncUUID = { 0, NULL };
202 struct berval syncCookie = { 0, NULL };
207 int syncinfo_arrived = 0;
208 int cancel_response = 0;
211 AttributeDescription** descs = NULL;
223 struct berval base_bv = { 0, NULL };
224 struct berval pbase = { 0, NULL };
225 struct berval nbase = { 0, NULL };
226 struct berval sub_bv = { 0, NULL };
227 struct berval psubrdn = { 0, NULL };
228 struct berval nsubrdn = { 0, NULL };
229 struct berval psub = { 0, NULL };
230 struct berval nsub = { 0, NULL };
232 Modifications *modlist = NULL;
233 Modifications *ml, *mlnext;
234 char *def_filter_str = NULL;
237 LDAP_LOG ( OPERATION, DETAIL1, "do_syncrepl\n", 0, 0, 0 );
239 Debug( LDAP_DEBUG_TRACE, "=>do_syncrepl\n", 0, 0, 0 );
245 if ( abs(si->type) != LDAP_SYNC_REFRESH_ONLY &&
246 abs(si->type) != LDAP_SYNC_REFRESH_AND_PERSIST ) {
250 si->sync_mode = LDAP_SYNC_STATE_MODE;
252 /* Init connection to master */
254 rc = ldap_initialize( &ld, si->provideruri );
255 if ( rc != LDAP_SUCCESS ) {
257 LDAP_LOG( OPERATION, ERR, "do_syncrepl: "
258 "ldap_initialize failed (%s)\n",
259 si->provideruri, 0, 0 );
261 Debug( LDAP_DEBUG_ANY, "do_syncrepl: "
262 "ldap_initialize failed (%s)\n",
263 si->provideruri, 0, 0 );
267 op.o_protocol = LDAP_VERSION3;
268 ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &op.o_protocol );
273 rc = ldap_start_tls_s( ld, NULL, NULL );
274 if( rc != LDAP_SUCCESS ) {
276 LDAP_LOG ( OPERATION, ERR, "do_syncrepl: "
277 "%s: ldap_start_tls failed (%d)\n",
278 si->tls == TLS_CRITICAL ? "Error" : "Warning",
281 Debug( LDAP_DEBUG_ANY,
282 "%s: ldap_start_tls failed (%d)\n",
283 si->tls == TLS_CRITICAL ? "Error" : "Warning",
286 if( si->tls == TLS_CRITICAL )
291 if ( si->bindmethod == LDAP_AUTH_SASL ) {
292 #ifdef HAVE_CYRUS_SASL
295 if ( si->secprops != NULL ) {
296 int err = ldap_set_option( ld,
297 LDAP_OPT_X_SASL_SECPROPS, si->secprops);
299 if( err != LDAP_OPT_SUCCESS ) {
301 LDAP_LOG ( OPERATION, ERR, "do_bind: Error: "
302 "ldap_set_option(%s,SECPROPS,\"%s\") failed!\n",
303 si->provideruri, si->secprops, 0 );
305 Debug( LDAP_DEBUG_ANY, "Error: ldap_set_option "
306 "(%s,SECPROPS,\"%s\") failed!\n",
307 si->provideruri, si->secprops, NULL );
313 defaults = lutil_sasl_defaults( ld,
320 rc = ldap_sasl_interactive_bind_s( ld,
328 if ( rc != LDAP_SUCCESS ) {
330 LDAP_LOG ( OPERATION, ERR, "do_syncrepl: "
331 "ldap_sasl_interactive_bind_s failed (%d)\n",
334 Debug( LDAP_DEBUG_ANY, "do_syncrepl: "
335 "ldap_sasl_interactive_bind_s failed (%d)\n",
340 #else /* HAVE_CYRUS_SASL */
341 fprintf( stderr, "not compiled with SASL support\n" );
345 rc = ldap_bind_s( ld, si->binddn, si->passwd, si->bindmethod );
346 if ( rc != LDAP_SUCCESS ) {
348 LDAP_LOG ( OPERATION, ERR, "do_syncrepl: "
349 "ldap_bind_s failed (%d)\n", rc, 0, 0 );
351 Debug( LDAP_DEBUG_ANY, "do_syncrepl: "
352 "ldap_bind_s failed (%d)\n", rc, 0, 0 );
358 /* set thread context in syncinfo */
361 /* set memory context */
362 #define SLAB_SIZE 1048576
364 memctx = sl_mem_create( memsiz, ctx );
365 op.o_tmpmemctx = memctx;
366 op.o_tmpmfuncs = &sl_mfuncs;
369 op.o_tag = LDAP_REQ_SEARCH;
370 op.o_dn = si->updatedn;
371 op.o_ndn = si->updatedn;
373 op.o_time = slap_get_time();
374 op.o_managedsait = 1;
375 op.o_threadctx = si->ctx;
378 op.o_connid = op.o_conn->c_connid;
379 op.ors_scope = LDAP_SCOPE_BASE;
380 op.ors_deref = LDAP_DEREF_NEVER;
383 op.ors_attrsonly = 0;
385 op.ors_filter = str2filter( def_filter_str = "(objectClass=*)" );
386 ber_str2bv( def_filter_str, strlen( def_filter_str ), 1,
390 conn.c_send_ldap_result = slap_send_ldap_result;
391 conn.c_send_search_entry = slap_send_search_entry;
392 conn.c_send_search_reference = slap_send_search_reference;
394 /* get syncrepl cookie of shadow replica from subentry */
395 ber_str2bv( si->base, strlen(si->base), 1, &base_bv );
396 dnPrettyNormal( 0, &base_bv, &pbase, &nbase, op.o_tmpmemctx );
398 sprintf( substr, "cn=syncrepl%d", si->id );
399 ber_str2bv( substr, strlen(substr), 1, &sub_bv );
400 dnPrettyNormal( 0, &sub_bv, &psubrdn, &nsubrdn, op.o_tmpmemctx );
402 build_new_dn( &op.o_req_dn, &pbase, &psubrdn );
403 build_new_dn( &op.o_req_ndn, &nbase, &nsubrdn );
405 ch_free( base_bv.bv_val );
406 ch_free( pbase.bv_val );
407 ch_free( nbase.bv_val );
408 ch_free( sub_bv.bv_val );
409 ch_free( psubrdn.bv_val );
410 ch_free( nsubrdn.bv_val );
412 /* set callback function */
413 cb.sc_response = cookie_callback;
416 /* search subentry to retrieve cookie */
417 si->syncCookie = NULL;
418 be->be_search( &op, &rs );
420 ch_free( op.o_req_dn.bv_val );
421 ch_free( op.o_req_ndn.bv_val );
422 filter_free( op.ors_filter );
423 ch_free( op.ors_filterstr.bv_val );
425 psub = be->be_nsuffix[0];
427 /* Delete Attributes */
428 if ( si->lastmod == LASTMOD_REQ ) {
429 descs = del_descs_lastmod;
434 for ( i = 0; descs[i] != NULL; i++ ) {
435 for ( j = 0; si->attrs[j] != NULL; j++ ) {
436 if ( !strcmp( si->attrs[j], descs[i]->ad_cname.bv_val )) {
437 ch_free( si->attrs[j] );
438 for ( k = j; si->attrs[k] != NULL; k++ ) {
439 si->attrs[k] = si->attrs[k+1];
447 for ( n = 0; si->attrs[ n ] != NULL; n++ ) ;
449 if ( si->lastmod == LASTMOD_REQ ) {
450 descs = add_descs_lastmod;
455 for ( i = 0; descs[i] != NULL; i++ ) {
456 tmp = ( char ** ) ch_realloc( si->attrs,
457 ( n + 2 ) * sizeof( char * ));
460 LDAP_LOG( OPERATION, ERR, "out of memory\n", 0,0,0 );
462 Debug( LDAP_DEBUG_ANY, "out of memory\n", 0,0,0 );
466 si->attrs[ n++ ] = ch_strdup ( descs[i]->ad_cname.bv_val );
467 si->attrs[ n ] = NULL;
470 rc = ldap_sync_search( si, ld, NULL, NULL, &msgid );
471 if( rc != LDAP_SUCCESS ) {
472 fprintf( stderr, "syncrepl: ldap_search_ext: %s (%d)\n",
473 ldap_err2string( rc ), rc );
477 while (( rc = ldap_result( ld, LDAP_RES_ANY, LDAP_MSG_ONE, NULL, &res )) > 0 ) {
479 for ( msg = ldap_first_message( ld, res );
481 msg = ldap_next_message( ld, msg ) )
483 switch( ldap_msgtype( msg ) ) {
484 case LDAP_RES_SEARCH_ENTRY:
485 entry = syncrepl_message_to_entry( si, ld, &op, msg,
486 &modlist, &syncstate, &syncUUID, &syncCookie );
487 rc_efree = syncrepl_entry( si, ld, &op, entry, modlist,
488 syncstate, &syncUUID, &syncCookie, !syncinfo_arrived );
489 if ( syncCookie.bv_len ) {
490 syncrepl_updateCookie( si, ld, &op, &psub, &syncCookie );
494 for ( ml = modlist; ml != NULL; ml = mlnext ) {
495 mlnext = ml->sml_next;
500 case LDAP_RES_SEARCH_REFERENCE:
502 LDAP_LOG( OPERATION, ERR,
503 "do_syncrepl : reference received\n", 0, 0, 0 );
505 Debug( LDAP_DEBUG_ANY,
506 "do_syncrepl : reference received\n", 0, 0, 0 );
510 case LDAP_RES_SEARCH_RESULT:
511 ldap_parse_result( ld, msg, &err, NULL, NULL, NULL, &rctrls, 0 );
514 ctrl_ber = ber_alloc_t( LBER_USE_DER );
515 ber_set_option( ctrl_ber, LBER_OPT_BER_MEMCTX, &op.o_tmpmemctx );
516 ber_write( ctrl_ber, rctrlp->ldctl_value.bv_val, rctrlp->ldctl_value.bv_len, 0 );
517 ber_reset( ctrl_ber, 1 );
519 ber_scanf( ctrl_ber, "{" /*"}"*/);
520 if ( ber_peek_tag( ctrl_ber, &len )
521 == LDAP_SYNC_TAG_COOKIE ) {
522 ber_scanf( ctrl_ber, "o", &syncCookie );
525 if (si->type == LDAP_SYNC_REFRESH_AND_PERSIST) {
526 if ( cancel_response ) {
527 if ( syncCookie.bv_len ) {
528 syncrepl_updateCookie( si, ld, &op, &psub, &syncCookie );
531 ber_free( ctrl_ber, 1 );
536 ber_free( ctrl_ber, 1 );
540 if ( syncCookie.bv_len ) {
541 syncrepl_updateCookie( si, ld, &op, &psub, &syncCookie);
543 if ( si->sync_mode == LDAP_SYNC_STATE_MODE )
544 syncrepl_del_nonpresent( ld, &op );
546 ber_free( ctrl_ber, 1 );
551 case LDAP_RES_INTERMEDIATE:
552 rc = ldap_parse_intermediate( ld, msg,
553 &retoid, &retdata, NULL, 0 );
554 if ( !rc && !strcmp( retoid, LDAP_SYNC_INFO ) ) {
555 sync_info_arrived = 1;
556 res_ber = ber_init( retdata );
557 ber_scanf( res_ber, "{e" /*"}"*/, &syncstate );
559 if ( syncstate == LDAP_SYNC_STATE_MODE_DONE ) {
560 syncrepl_del_nonpresent( ld, &op );
561 si->sync_mode = LDAP_SYNC_LOG_MODE;
562 } else if ( syncstate == LDAP_SYNC_LOG_MODE_DONE ) {
563 si->sync_mode = LDAP_SYNC_PERSIST_MODE;
564 } else if ( syncstate == LDAP_SYNC_REFRESH_DONE ) {
565 si->sync_mode = LDAP_SYNC_PERSIST_MODE;
566 } else if ( syncstate != LDAP_SYNC_NEW_COOKIE ||
567 syncstate != LDAP_SYNC_LOG_MODE_DONE ) {
569 LDAP_LOG( OPERATION, ERR,
570 "do_syncrepl : unknown sync info\n", 0, 0, 0 );
572 Debug( LDAP_DEBUG_ANY,
573 "do_syncrepl : unknown sync info\n", 0, 0, 0 );
577 if ( ber_peek_tag( res_ber, &len )
578 == LDAP_SYNC_TAG_COOKIE ) {
579 ber_scanf( res_ber, /*"{"*/ "o}", &syncCookie );
580 if ( syncCookie.bv_len ) {
581 syncrepl_updateCookie( si, ld, &op, &psub, &syncCookie);
584 if ( syncstate == LDAP_SYNC_NEW_COOKIE ) {
586 LDAP_LOG( OPERATION, ERR,
587 "do_syncrepl : cookie required\n", 0, 0, 0 );
589 Debug( LDAP_DEBUG_ANY,
590 "do_syncrepl : cookie required\n", 0, 0, 0 );
595 ldap_memfree( retoid );
596 ber_bvfree( retdata );
597 ber_free( res_ber, 1 );
601 LDAP_LOG( OPERATION, ERR,"do_syncrepl :"
602 " unknown intermediate "
603 "response\n", 0, 0, 0 );
605 Debug( LDAP_DEBUG_ANY, "do_syncrepl : "
606 "unknown intermediate response (%d)\n",
609 ldap_memfree( retoid );
610 ber_bvfree( retdata );
616 LDAP_LOG( OPERATION, ERR, "do_syncrepl : "
617 "unknown message\n", 0, 0, 0 );
619 Debug( LDAP_DEBUG_ANY, "do_syncrepl : "
620 "unknown message\n", 0, 0, 0 );
631 LDAP_LOG( OPERATION, ERR,
632 "do_syncrepl : unknown result\n", 0, 0, 0 );
634 Debug( LDAP_DEBUG_ANY,
635 "do_syncrepl : unknown result\n", 0, 0, 0 );
640 if ( syncCookie.bv_val )
641 ch_free( syncCookie.bv_val );
642 if ( syncUUID.bv_val )
643 ch_free( syncUUID.bv_val );
649 ldap_pvt_thread_mutex_lock( &syncrepl_rq.rq_mutex );
650 ldap_pvt_runqueue_stoptask( &syncrepl_rq, rtask );
651 if ( si->type == LDAP_SYNC_REFRESH_ONLY ) {
652 ldap_pvt_runqueue_resched( &syncrepl_rq, rtask );
654 ldap_pvt_runqueue_remove( &syncrepl_rq, rtask );
656 ldap_pvt_thread_mutex_unlock( &syncrepl_rq.rq_mutex );
662 syncrepl_message_to_entry(
667 Modifications **modlist,
669 struct berval *syncUUID,
670 struct berval *syncCookie
674 BerElement *ber = NULL;
676 struct berval bv = {0, NULL};
679 Modifications **modtail = modlist;
680 Backend *be = op->o_bd;
683 char txtbuf[SLAP_TEXT_BUFLEN];
684 size_t textlen = sizeof txtbuf;
686 struct berval **bvals = NULL;
688 struct berval bdn = {0, NULL};
690 struct berval empty_bv = { 0, NULL };
696 LDAPControl** rctrls = NULL;
697 BerElement* ctrl_ber;
701 Modifications *prevml = NULL;
702 Modifications *nextml = NULL;
703 Modifications *ml = NULL;
704 AttributeDescription** descs;
709 if ( ldap_msgtype( msg ) != LDAP_RES_SEARCH_ENTRY ) {
711 LDAP_LOG( OPERATION, ERR,
712 "Message type should be entry (%d)", ldap_msgtype( msg ), 0, 0 );
714 Debug( LDAP_DEBUG_ANY,
715 "Message type should be entry (%d)", ldap_msgtype( msg ), 0, 0 );
720 op->o_tag = LDAP_REQ_ADD;
722 rc = ldap_get_dn_ber( ld, msg, &ber, &bdn );
724 if ( rc != LDAP_SUCCESS ) {
726 LDAP_LOG( OPERATION, ERR,
727 "syncrepl_message_to_entry : dn get failed (%d)", rc, 0, 0 );
729 Debug( LDAP_DEBUG_ANY,
730 "syncrepl_message_to_entry : dn get failed (%d)", rc, 0, 0 );
735 e = ( Entry * ) ch_calloc( 1, sizeof( Entry ));
736 dnPrettyNormal( NULL, &bdn, &e->e_name, &e->e_nname, NULL );
740 while ( ber_remaining( ber ) ) {
741 tag = ber_scanf( ber, "{mW}", &tmp.sml_type, &tmp.sml_values );
743 if ( tag == LBER_ERROR ) break;
744 if ( tmp.sml_type.bv_val == NULL ) break;
746 mod = (Modifications *) ch_malloc( sizeof( Modifications ));
748 mod->sml_op = LDAP_MOD_REPLACE;
749 mod->sml_next = NULL;
750 mod->sml_desc = NULL;
751 mod->sml_type = tmp.sml_type;
752 mod->sml_bvalues = tmp.sml_bvalues;
753 mod->sml_nvalues = tmp.sml_bvalues;
756 modtail = &mod->sml_next;
759 if ( ber_scanf( ber, "}") == LBER_ERROR ) {
761 LDAP_LOG( OPERATION, ERR,
762 "syncrepl_message_to_entry: ber_scanf failed\n", 0, 0, 0 );
764 Debug( LDAP_DEBUG_ANY, "syncrepl_message_to_entry: ber_scanf failed\n",
771 tmpber = ldap_get_message_ber( msg );
772 ber = ber_dup( tmpber );
774 ber_scanf( ber, "{xx" );
776 rc = ldap_int_get_controls( ber, &rctrls );
778 if ( rc != LDAP_SUCCESS ) {
780 LDAP_LOG( OPERATION, ERR,
781 "syncrepl_message_to_entry : control get failed (%d)", rc, 0, 0 );
783 Debug( LDAP_DEBUG_ANY,
784 "syncrepl_message_to_entry : control get failed (%d)", rc, 0, 0 );
791 ctrl_ber = ber_alloc_t( LBER_USE_DER );
792 ber_set_option( ctrl_ber, LBER_OPT_BER_MEMCTX, &op->o_tmpmemctx );
793 ber_write( ctrl_ber, rctrlp->ldctl_value.bv_val, rctrlp->ldctl_value.bv_len, 0 );
794 ber_reset( ctrl_ber, 1 );
795 ber_scanf( ctrl_ber, "{eo", syncstate, syncUUID );
796 if ( ber_peek_tag( ctrl_ber, &len ) == LDAP_SYNC_TAG_COOKIE ) {
797 ber_scanf( ctrl_ber, "o}", syncCookie );
799 ber_free( ctrl_ber, 1 );
802 LDAP_LOG( OPERATION, ERR,"syncrepl_message_to_entry : "
803 " rctrls absent\n", 0, 0, 0 );
805 Debug( LDAP_DEBUG_ANY, "syncrepl_message_to_entry :"
806 " rctrls absent\n", 0, 0, 0 );
810 if ( *syncstate == LDAP_SYNC_PRESENT ) {
813 } else if ( *syncstate == LDAP_SYNC_DELETE ) {
817 if ( *modlist == NULL ) {
819 LDAP_LOG( OPERATION, ERR,
820 "syncrepl_message_to_entry: no attributes\n", 0, 0, 0 );
822 Debug( LDAP_DEBUG_ANY, "syncrepl_message_to_entry: no attributes\n",
828 while ( ml != NULL ) {
829 AttributeDescription *ad = NULL;
830 rc = slap_bv2ad( &ml->sml_type, &ml->sml_desc, &text );
832 if( rc != LDAP_SUCCESS ) {
840 if ( si->lastmod == LASTMOD_REQ ) {
841 descs = del_descs_lastmod;
846 for ( i = 0; descs[i] != NULL; i++ ) {
847 if ( ad == descs[i] ) {
848 if ( prevml == NULL ) {
849 modlist = &ml->sml_next;
852 prevml->sml_next = ml->sml_next;
854 slap_mod_free( &ml->sml_mod, 0 );
855 nextml = ml->sml_next;
865 rc = slap_mods_check( *modlist, 1, &text, txtbuf, textlen, NULL );
867 if ( rc != LDAP_SUCCESS ) {
869 LDAP_LOG( OPERATION, ERR,
870 "syncrepl_message_to_entry: mods check (%s)\n", text, 0, 0 );
872 Debug( LDAP_DEBUG_ANY, "syncrepl_message_to_entry: mods check (%s)\n",
878 rc = slap_mods_opattrs( op, *modlist, modtail,
879 &text,txtbuf, textlen );
881 if( rc != LDAP_SUCCESS ) {
883 LDAP_LOG( OPERATION, ERR,
884 "syncrepl_message_to_entry: mods opattrs (%s)\n", text, 0, 0 );
886 Debug( LDAP_DEBUG_ANY, "syncrepl_message_to_entry: mods opattrs (%s)\n",
892 rc = slap_mods2entry( *modlist, &e, 1, 1, &text, txtbuf, textlen);
893 if( rc != LDAP_SUCCESS ) {
895 LDAP_LOG( OPERATION, ERR,
896 "syncrepl_message_to_entry: mods2entry (%s)\n", text, 0, 0 );
898 Debug( LDAP_DEBUG_ANY, "syncrepl_message_to_entry: mods2entry (%s)\n",
911 syncuuid_cmp( const void* v_uuid1, const void* v_uuid2 )
913 const struct berval *uuid1 = v_uuid1;
914 const struct berval *uuid2 = v_uuid2;
915 int rc = uuid1->bv_len - uuid2->bv_len;
917 return ( strcmp( uuid1->bv_val, uuid2->bv_val ) );
926 Modifications* modlist,
928 struct berval* syncUUID,
929 struct berval* syncCookie,
933 Backend *be = op->o_bd;
935 struct berval csn_bv = {0, NULL};
936 struct berval *syncuuid_bv = NULL;
937 char csnbuf[ LDAP_LUTIL_CSNSTR_BUFSIZE ];
939 SlapReply rs = {REP_RESULT};
940 int rc = LDAP_SUCCESS;
942 struct berval base_bv = {0, NULL};
950 ( syncstate == LDAP_SYNC_PRESENT || syncstate == LDAP_SYNC_ADD )) {
951 syncuuid_bv = ber_dupbv( NULL, syncUUID );
952 avl_insert( &si->presentlist, (caddr_t) syncuuid_bv,
953 syncuuid_cmp, avl_dup_error );
956 if ( syncstate == LDAP_SYNC_PRESENT ) {
963 filterstr = (char *) sl_malloc( strlen("entryUUID=") + syncUUID->bv_len + 1,
965 strcpy( filterstr, "entryUUID=" );
966 strcat( filterstr, syncUUID->bv_val );
969 si->syncUUID = syncUUID;
970 si->syncUUID_ndn = NULL;
972 filter = str2filter( filterstr );
973 ber_str2bv( filterstr, strlen(filterstr), 1, &op->ors_filterstr );
974 ch_free( filterstr );
975 op->ors_filter = filter;
976 op->ors_scope = LDAP_SCOPE_SUBTREE;
978 /* get syncrepl cookie of shadow replica from subentry */
979 ber_str2bv( si->base, strlen(si->base), 1, &base_bv );
980 dnPrettyNormal( 0, &base_bv, &op->o_req_dn, &op->o_req_ndn, op->o_tmpmemctx );
981 ch_free( base_bv.bv_val );
983 /* set callback function */
984 op->o_callback = &cb;
985 cb.sc_response = dn_callback;
988 rc = be->be_search( op, &rs );
990 ch_free( op->o_req_dn.bv_val );
991 ch_free( op->o_req_ndn.bv_val );
992 filter_free( op->ors_filter );
993 ch_free( op->ors_filterstr.bv_val );
995 cb.sc_response = null_callback;
998 if ( rc == LDAP_SUCCESS && si->syncUUID_ndn && si->sync_mode != LDAP_SYNC_LOG_MODE ) {
999 op->o_req_dn = *si->syncUUID_ndn;
1000 op->o_req_ndn = *si->syncUUID_ndn;
1001 op->o_tag = LDAP_REQ_DELETE;
1002 rc = be->be_delete( op, &rs );
1005 if ( si->syncUUID_ndn ) {
1006 ber_bvfree( si->syncUUID_ndn );
1009 switch ( syncstate ) {
1010 case LDAP_SYNC_ADD :
1011 case LDAP_SYNC_MODIFY :
1013 if ( rc == LDAP_SUCCESS ||
1014 rc == LDAP_REFERRAL ||
1015 rc == LDAP_NO_SUCH_OBJECT ) {
1017 if ( !attr_find( e->e_attrs, slap_schema.si_ad_entryUUID )) {
1018 attr_merge_one( e, slap_schema.si_ad_entryUUID, syncUUID, syncUUID );
1021 op->o_tag = LDAP_REQ_ADD;
1023 op->o_req_dn = e->e_name;
1024 op->o_req_ndn = e->e_nname;
1025 rc = be->be_add( op, &rs );
1027 if ( rc != LDAP_SUCCESS ) {
1028 if ( rc == LDAP_ALREADY_EXISTS ) {
1029 op->o_tag = LDAP_REQ_MODIFY;
1030 op->orm_modlist = modlist;
1031 op->o_req_dn = e->e_name;
1032 op->o_req_ndn = e->e_nname;
1033 rc = be->be_modify( op, &rs );
1036 } else if ( rc == LDAP_REFERRAL ||
1037 rc == LDAP_NO_SUCH_OBJECT ) {
1038 syncrepl_add_glue( si, ld, op, e,
1040 syncUUID, syncCookie);
1045 LDAP_LOG( OPERATION, ERR,
1046 "be_modify failed (%d)\n",
1049 Debug( LDAP_DEBUG_ANY,
1050 "be_modify failed (%d)\n",
1058 be_entry_release_w( op, e );
1063 LDAP_LOG( OPERATION, ERR,
1064 "be_modify/be_delete failed (%d)\n", rc, 0, 0 );
1066 Debug( LDAP_DEBUG_ANY,
1067 "be_modify/be_delete failed (%d)\n", rc, 0, 0 );
1073 case LDAP_SYNC_DELETE :
1074 if ( si->sync_mode == LDAP_SYNC_LOG_MODE ) {
1075 op->o_req_dn = *si->syncUUID_ndn;
1076 op->o_req_ndn = *si->syncUUID_ndn;
1077 op->o_tag = LDAP_REQ_DELETE;
1078 rc = be->be_delete( op, &rs );
1080 /* Already deleted otherwise */
1085 LDAP_LOG( OPERATION, ERR,
1086 "unknown syncstate\n", 0, 0, 0 );
1088 Debug( LDAP_DEBUG_ANY,
1089 "unknown syncstate\n", 0, 0, 0 );
1096 syncrepl_del_nonpresent(
1101 Backend* be = op->o_bd;
1102 syncinfo_t *si = op->o_si;
1104 struct berval base_bv = {0, NULL};
1106 SlapReply rs = {REP_RESULT};
1107 struct berval filterstr_bv = {0, NULL};
1108 struct nonpresent_entry *np_list, *np_prev;
1110 ber_str2bv( si->base, strlen(si->base), 1, &base_bv );
1111 dnPrettyNormal(0, &base_bv, &op->o_req_dn, &op->o_req_ndn, op->o_tmpmemctx );
1112 ch_free( base_bv.bv_val );
1114 filter = str2filter( si->filterstr );
1116 cb.sc_response = nonpresent_callback;
1119 op->o_callback = &cb;
1120 op->o_tag = LDAP_REQ_SEARCH;
1121 op->ors_scope = si->scope;
1122 op->ors_deref = LDAP_DEREF_NEVER;
1125 op->ors_attrsonly = 0;
1126 op->ors_attrs = NULL;
1127 op->ors_filter = filter;
1128 ber_str2bv( si->filterstr, strlen( si->filterstr ), 1, &op->ors_filterstr );
1130 be->be_search( op, &rs );
1132 if ( !LDAP_LIST_EMPTY( &si->nonpresentlist ) ) {
1133 np_list = LDAP_LIST_FIRST( &si->nonpresentlist );
1134 while ( np_list != NULL ) {
1135 LDAP_LIST_REMOVE( np_list, np_link );
1137 np_list = LDAP_LIST_NEXT( np_list, np_link );
1138 op->o_tag = LDAP_REQ_DELETE;
1139 op->o_callback = &cb;
1140 cb.sc_response = null_callback;
1142 op->o_req_dn = *np_prev->dn;
1143 op->o_req_ndn = *np_prev->ndn;
1144 op->o_bd->be_delete( op, &rs );
1145 ber_bvfree( np_prev->dn );
1146 ber_bvfree( np_prev->ndn );
1147 op->o_req_dn.bv_val = NULL;
1148 op->o_req_ndn.bv_val = NULL;
1153 if ( op->o_req_dn.bv_val )
1154 ch_free( op->o_req_dn.bv_val );
1155 if ( op->o_req_ndn.bv_val )
1156 ch_free( op->o_req_ndn.bv_val );
1157 filter_free( op->ors_filter );
1158 ch_free( op->ors_filterstr.bv_val );
1170 Modifications* modlist,
1172 struct berval* syncUUID,
1173 struct berval* syncCookie
1176 Backend *be = op->o_bd;
1177 struct berval uuid_bv = {0, NULL};
1181 char uuidbuf[ LDAP_LUTIL_UUIDSTR_BUFSIZE ];
1184 struct berval dn = {0, NULL};
1185 struct berval pdn = {0, NULL};
1186 struct berval ndn = {0, NULL};
1187 struct berval rdn = {0, NULL};
1189 SlapReply rs = {REP_RESULT};
1190 Connection *conn = op->o_conn;
1193 op->o_tag = LDAP_REQ_ADD;
1194 op->o_callback = &cb;
1195 cb.sc_response = null_callback;
1198 ber_dupbv( &dn, &e->e_nname );
1199 ber_dupbv( &pdn, &e->e_nname );
1202 while ( !be_issuffix ( be, &pdn )) {
1203 dnParent( &dn, &pdn );
1204 dn.bv_val = pdn.bv_val;
1205 dn.bv_len = pdn.bv_len;
1210 for ( i = 0; i <= levels; i++ ) {
1211 glue = (Entry*) ch_calloc( 1, sizeof(Entry) );
1212 ber_dupbv( &dn, &e->e_nname );
1216 for ( k = 0; k < j; k++ ) {
1217 dnParent( &dn, &pdn );
1218 dn.bv_val = pdn.bv_val;
1219 dn.bv_len = pdn.bv_len;
1222 dnPrettyNormal( 0, &dn, &pdn, &ndn, op->o_tmpmemctx );
1223 ber_dupbv( &glue->e_name, &pdn );
1224 ber_dupbv( &glue->e_nname, &ndn );
1226 ch_free( pdn.bv_val );
1227 ch_free( ndn.bv_val );
1229 a = ch_calloc( 1, sizeof( Attribute ));
1230 a->a_desc = slap_schema.si_ad_objectClass;
1232 a->a_vals = ch_calloc( 3, sizeof( struct berval ));
1233 ber_str2bv( "top", strlen("top"), 1, &a->a_vals[0] );
1234 ber_str2bv( "glue", strlen("glue"), 1, &a->a_vals[1] );
1235 a->a_vals[2].bv_len = 0;
1236 a->a_vals[2].bv_val = NULL;
1238 a->a_nvals = ch_calloc( 3, sizeof( struct berval ));
1239 ber_str2bv( "top", strlen("top"), 1, &a->a_nvals[0] );
1240 ber_str2bv( "glue", strlen("glue"), 1, &a->a_nvals[1] );
1241 a->a_nvals[2].bv_len = 0;
1242 a->a_nvals[2].bv_val = NULL;
1244 a->a_next = glue->e_attrs;
1247 a = ch_calloc( 1, sizeof( Attribute ));
1248 a->a_desc = slap_schema.si_ad_structuralObjectClass;
1250 a->a_vals = ch_calloc( 2, sizeof( struct berval ));
1251 ber_str2bv( "glue", strlen("glue"), 1, &a->a_vals[0] );
1252 a->a_vals[1].bv_len = 0;
1253 a->a_vals[1].bv_val = NULL;
1255 a->a_nvals = ch_calloc( 2, sizeof( struct berval ));
1256 ber_str2bv( "glue", strlen("glue"), 1, &a->a_nvals[0] );
1257 a->a_nvals[1].bv_len = 0;
1258 a->a_nvals[1].bv_val = NULL;
1260 a->a_next = glue->e_attrs;
1263 if ( !strcmp( e->e_nname.bv_val, glue->e_nname.bv_val )) {
1264 op->o_req_dn = e->e_name;
1265 op->o_req_ndn = e->e_nname;
1267 rc = be->be_add ( op, &rs );
1268 if ( rc == LDAP_SUCCESS )
1269 be_entry_release_w( op, e );
1274 op->o_req_dn = glue->e_name;
1275 op->o_req_ndn = glue->e_nname;
1277 rc = be->be_add ( op, &rs );
1278 if ( rc == LDAP_SUCCESS ) {
1279 be_entry_release_w( op, glue );
1281 /* incl. ALREADY EXIST */
1291 syncrepl_updateCookie(
1296 struct berval *syncCookie
1299 Backend *be = op->o_bd;
1301 Modifications *mlnext;
1303 Modifications *modlist;
1304 Modifications **modtail = &modlist;
1306 struct berval* ocbva = NULL;
1307 struct berval* cnbva = NULL;
1308 struct berval* ssbva = NULL;
1309 struct berval* scbva = NULL;
1314 char txtbuf[SLAP_TEXT_BUFLEN];
1315 size_t textlen = sizeof txtbuf;
1320 struct berval sub_bv = { 0, NULL };
1321 struct berval psubrdn = { 0, NULL };
1324 SlapReply rs = {REP_RESULT};
1326 ocbva = ( struct berval * ) ch_calloc( 4, sizeof( struct berval ));
1327 cnbva = ( struct berval * ) ch_calloc( 2, sizeof( struct berval ));
1328 ssbva = ( struct berval * ) ch_calloc( 2, sizeof( struct berval ));
1329 scbva = ( struct berval * ) ch_calloc( 2, sizeof( struct berval ));
1331 /* update in memory cookie */
1332 if ( si->syncCookie != NULL ) {
1333 ber_bvfree( si->syncCookie );
1335 si->syncCookie = ber_dupbv( NULL, syncCookie );
1336 ber_str2bv( "top", strlen("top"), 1, &ocbva[0] );
1337 ber_str2bv( "subentry", strlen("subentry"), 1, &ocbva[1] );
1338 ber_str2bv( "syncConsumerSubentry",
1339 strlen("syncConsumerSubentry"), 1, &ocbva[2] );
1340 ocbva[3].bv_len = 0;
1341 ocbva[3].bv_val = NULL;
1343 mod = (Modifications *) ch_malloc( sizeof( Modifications ));
1344 mod->sml_op = LDAP_MOD_REPLACE;
1345 mod->sml_next = NULL;
1346 mod->sml_desc = NULL;
1347 ber_str2bv( "objectClass", strlen("objectClass"), 1, &mod->sml_type );
1348 mod->sml_bvalues = ocbva;
1349 mod->sml_nvalues = ocbva;
1351 modtail = &mod->sml_next;
1353 sprintf( substr, "syncrepl%d", si->id );
1354 sprintf( rdnstr, "cn=%s", substr );
1355 ber_str2bv( substr, strlen( substr ), 1, &cnbva[0] );
1356 ber_str2bv( rdnstr, strlen( rdnstr ), 1, &psubrdn );
1357 cnbva[1].bv_len = 0;
1358 cnbva[1].bv_val = NULL;
1359 mod = (Modifications *) ch_malloc( sizeof( Modifications ));
1360 mod->sml_op = LDAP_MOD_REPLACE;
1361 mod->sml_next = NULL;
1362 mod->sml_desc = NULL;
1363 ber_str2bv( "cn", strlen("cn"), 1, &mod->sml_type );
1364 mod->sml_bvalues = cnbva;
1365 mod->sml_nvalues = cnbva;
1367 modtail = &mod->sml_next;
1369 ber_dupbv( &scbva[0], si->syncCookie );
1370 scbva[1].bv_len = 0;
1371 scbva[1].bv_val = NULL;
1372 mod = (Modifications *) ch_malloc( sizeof( Modifications ));
1373 mod->sml_op = LDAP_MOD_REPLACE;
1374 mod->sml_next = NULL;
1375 mod->sml_desc = NULL;
1376 ber_str2bv( "syncreplCookie", strlen("syncreplCookie"),
1377 1, &mod->sml_type );
1378 mod->sml_bvalues = scbva;
1379 mod->sml_nvalues = scbva;
1381 modtail = &mod->sml_next;
1383 ber_str2bv( "{}", strlen("{}"), 1, &ssbva[0] );
1384 ssbva[1].bv_len = 0;
1385 ssbva[1].bv_val = NULL;
1386 mod = (Modifications *) ch_malloc( sizeof( Modifications ));
1387 mod->sml_op = LDAP_MOD_REPLACE;
1388 mod->sml_next = NULL;
1389 mod->sml_desc = NULL;
1390 ber_str2bv( "subtreeSpecification",
1391 strlen("subtreeSpecification"), 1, &mod->sml_type );
1392 mod->sml_bvalues = ssbva;
1393 mod->sml_nvalues = ssbva;
1395 modtail = &mod->sml_next;
1397 rc = slap_mods_check( modlist, 1, &text, txtbuf, textlen, NULL );
1399 if ( rc != LDAP_SUCCESS ) {
1401 LDAP_LOG( OPERATION, ERR,
1402 "syncrepl_updateCookie: mods check (%s)\n", text, 0, 0 );
1404 Debug( LDAP_DEBUG_ANY, "syncrepl_updateCookie: mods check (%s)\n",
1409 op->o_tag = LDAP_REQ_ADD;
1410 rc = slap_mods_opattrs( op, modlist, modtail,
1411 &text,txtbuf, textlen );
1413 for ( ml = modlist; ml != NULL; ml = mlnext ) {
1414 mlnext = ml->sml_next;
1415 if ( ml->sml_desc == slap_schema.si_ad_structuralObjectClass )
1416 ml->sml_op = LDAP_MOD_REPLACE;
1419 if( rc != LDAP_SUCCESS ) {
1421 LDAP_LOG( OPERATION, ERR,
1422 "syncrepl_updateCookie: mods opattrs (%s)\n", text, 0, 0 );
1424 Debug( LDAP_DEBUG_ANY, "syncrepl_updateCookie: mods opattrs (%s)\n",
1429 e = ( Entry * ) ch_calloc( 1, sizeof( Entry ));
1431 build_new_dn( &sub_bv, pdn, &psubrdn );
1432 dnPrettyNormal( NULL, &sub_bv, &e->e_name, &e->e_nname, NULL );
1433 ch_free( sub_bv.bv_val );
1434 ch_free( psubrdn.bv_val );
1438 rc = slap_mods2entry( modlist, &e, 1, 1, &text, txtbuf, textlen );
1440 if( rc != LDAP_SUCCESS ) {
1442 LDAP_LOG( OPERATION, ERR,
1443 "syncrepl_updateCookie: mods2entry (%s)\n", text, 0, 0 );
1445 Debug( LDAP_DEBUG_ANY, "syncrepl_updateCookie: mods2entry (%s)\n",
1450 cb.sc_response = null_callback;
1453 op->o_callback = &cb;
1454 op->o_req_dn = e->e_name;
1455 op->o_req_ndn = e->e_nname;
1457 /* update persistent cookie */
1458 update_cookie_retry:
1459 op->o_tag = LDAP_REQ_MODIFY;
1460 op->orm_modlist = modlist;
1461 rc = be->be_modify( op, &rs );
1462 if ( rc != LDAP_SUCCESS ) {
1463 if ( rc == LDAP_REFERRAL ||
1464 rc == LDAP_NO_SUCH_OBJECT ) {
1465 op->o_tag = LDAP_REQ_ADD;
1467 rc = be->be_add( op, &rs );
1468 if ( rc != LDAP_SUCCESS ) {
1469 if ( rc == LDAP_ALREADY_EXISTS ) {
1470 goto update_cookie_retry;
1471 } else if ( rc == LDAP_REFERRAL ||
1472 rc == LDAP_NO_SUCH_OBJECT ) {
1474 LDAP_LOG( OPERATION, ERR,
1475 "cookie will be non-persistent\n",
1478 Debug( LDAP_DEBUG_ANY,
1479 "cookie will be non-persistent\n",
1484 LDAP_LOG( OPERATION, ERR,
1485 "be_add failed (%d)\n",
1488 Debug( LDAP_DEBUG_ANY,
1489 "be_add failed (%d)\n",
1494 be_entry_release_w( op, e );
1499 LDAP_LOG( OPERATION, ERR,
1500 "be_modify failed (%d)\n", rc, 0, 0 );
1502 Debug( LDAP_DEBUG_ANY,
1503 "be_modify failed (%d)\n", rc, 0, 0 );
1513 for ( ml = modlist; ml != NULL; ml = mlnext ) {
1514 mlnext = ml->sml_next;
1522 avl_ber_bvfree( void *bv )
1527 if ( ((struct berval *)bv)->bv_val != NULL ) {
1528 ber_memfree ( ((struct berval *)bv)->bv_val );
1530 ber_memfree ( (char *) bv );
1539 syncinfo_t *si = op->o_callback->sc_private;
1542 if ( rs->sr_type != REP_SEARCH ) return LDAP_SUCCESS;
1544 a = attr_find( rs->sr_entry->e_attrs, slap_schema.si_ad_syncreplCookie );
1547 si->syncCookie = NULL;
1549 si->syncCookie = ber_dupbv( NULL, &a->a_vals[0] );
1551 return LDAP_SUCCESS;
1560 syncinfo_t *si = op->o_callback->sc_private;
1562 if ( rs->sr_type == REP_SEARCH ) {
1563 si->syncUUID_ndn = ber_dupbv( NULL, &rs->sr_entry->e_nname );
1566 return LDAP_SUCCESS;
1570 nonpresent_callback(
1575 syncinfo_t *si = op->o_callback->sc_private;
1578 struct berval* present_uuid = NULL;
1580 SlapReply rs_cb = {REP_RESULT};
1581 struct nonpresent_entry *np_entry;
1583 if ( rs->sr_type == REP_RESULT ) {
1584 count = avl_free( si->presentlist, avl_ber_bvfree );
1585 si->presentlist = NULL;
1586 return LDAP_SUCCESS;
1587 } else if ( rs->sr_type == REP_SEARCH ) {
1588 a = attr_find( rs->sr_entry->e_attrs, slap_schema.si_ad_entryUUID );
1593 present_uuid = avl_find( si->presentlist, &a->a_vals[0], syncuuid_cmp );
1595 if ( present_uuid == NULL ) {
1596 np_entry = (struct nonpresent_entry *)
1597 ch_calloc( 1, sizeof( struct nonpresent_entry ));
1598 np_entry->dn = ber_dupbv( NULL, &rs->sr_entry->e_name );
1599 np_entry->ndn = ber_dupbv( NULL, &rs->sr_entry->e_nname );
1600 LDAP_LIST_INSERT_HEAD( &si->nonpresentlist, np_entry, np_link );
1602 avl_delete( &si->presentlist,
1603 &a->a_vals[0], syncuuid_cmp );
1605 return LDAP_SUCCESS;
1607 return LDAP_SUCCESS;
1618 syncinfo_t *si = op->o_callback->sc_private;
1620 if ( rs->sr_err != LDAP_SUCCESS &&
1621 rs->sr_err != LDAP_REFERRAL &&
1622 rs->sr_err != LDAP_ALREADY_EXISTS &&
1623 rs->sr_err != LDAP_NO_SUCH_OBJECT ) {
1625 LDAP_LOG( OPERATION, ERR,
1626 "null_callback : error code 0x%x\n",
1629 Debug( LDAP_DEBUG_ANY,
1630 "null_callback : error code 0x%x\n",
1634 return LDAP_SUCCESS;
1639 str2clist( char ***out, char *in, const char *brkstr )
1648 /* find last element in list */
1649 for (i = 0; *out && *out[i]; i++);
1651 /* protect the input string from strtok */
1652 str = ch_strdup( in );
1654 /* Count words in string */
1656 for ( s = str; *s; s++ ) {
1657 if ( strchr( brkstr, *s ) != NULL ) {
1662 *out = ch_realloc( *out, ( i + j + 1 ) * sizeof( char * ) );
1664 for ( s = ldap_pvt_strtok( str, brkstr, &lasts );
1666 s = ldap_pvt_strtok( NULL, brkstr, &lasts ) )
1668 *new = ch_strdup( s );