- for ( i = 0; replica_id_list[i] > -1 ; i++ ) {
- slap_syncrepl_bv.bv_len = snprintf( slap_syncrepl_bv.bv_val,
- slap_syncrepl_bvc.bv_len+1,
- "syncrepl%d", replica_id_list[i] );
- slap_syncrepl_cn_bv.bv_len = snprintf( slap_syncrepl_cn_bv.bv_val,
- slap_syncrepl_cn_bvc.bv_len+1,
- "cn=syncrepl%d", replica_id_list[i] );
- build_new_dn( &ctxcsn_ndn, &be->be_nsuffix[0],
- (struct berval *)&slap_syncrepl_cn_bv, NULL );
- ctxcsn_id = be->be_dn2id_get( be, &ctxcsn_ndn );
-
- if ( ctxcsn_id == NOID ) {
- ctxcsn_e = slap_create_syncrepl_entry( be, &mc,
- &slap_syncrepl_cn_bv,
- &slap_syncrepl_bv );
-
- /* dryrun moved earlier */
- assert( !dryrun );
-
- if ( !dryrun ) {
- ctxcsn_id = be->be_entry_put( be, ctxcsn_e, &bvtext );
- if( ctxcsn_id == NOID ) {
- fprintf( stderr, "%s: could not add ctxcsn subentry\n",
- progname);
- rc = EXIT_FAILURE;
- }
- if ( verbose ) {
- fprintf( stderr, "added: \"%s\" (%08lx)\n",
- ctxcsn_e->e_dn, (long) ctxcsn_id );
- }
- } else {
- if ( verbose ) {
- fprintf( stderr, "(dry) added: \"%s\"\n",
- ctxcsn_e->e_dn );
- }
- }
- entry_free( ctxcsn_e );
- } else {
- ret = be->be_id2entry_get( be, ctxcsn_id, &ctxcsn_e );
- if ( ret == LDAP_SUCCESS ) {
- attr = attr_find( ctxcsn_e->e_attrs,
- slap_schema.si_ad_syncreplCookie );
- AC_MEMCPY( attr->a_vals[0].bv_val, mc.bv_val, mc.bv_len );
- attr->a_vals[0].bv_val[maxcsn.bv_len] = '\0';
- attr->a_vals[0].bv_len = maxcsn.bv_len;
-
- /* dryrun moved earlier */
- assert( !dryrun );
-
- if ( !dryrun ) {
- ctxcsn_id = be->be_entry_modify( be,
- ctxcsn_e, &bvtext );
- if( ctxcsn_id == NOID ) {
- fprintf( stderr, "%s: could not modify ctxcsn "
- "subentry\n", progname);
- rc = EXIT_FAILURE;
- }
- if ( verbose ) {
- fprintf( stderr, "modified: \"%s\" (%08lx)\n",
- ctxcsn_e->e_dn, (long) ctxcsn_id );
- }
- } else {
- if ( verbose ) {
- fprintf( stderr, "(dry) modified: \"%s\"\n",
- ctxcsn_e->e_dn );