- if ( update_ctxcsn == SLAP_TOOL_CTXCSN_KEEP ) {
- if ( is_entry_syncProviderSubentry( e )) {
- if ( !LDAP_SLIST_EMPTY( &consumer_subentry )) {
- fprintf( stderr, "%s: consumer and provider subentries "
- "are both present\n", progname );
- rc = EXIT_FAILURE;
- entry_free( e );
- sei = LDAP_SLIST_FIRST( &consumer_subentry );
- while ( sei ) {
- ch_free( sei->cn.bv_val );
- ch_free( sei->ndn.bv_val );
- ch_free( sei->rdn.bv_val );
- ch_free( sei->cookie.bv_val );
- LDAP_SLIST_REMOVE_HEAD( &consumer_subentry, sei_next );
- ch_free( sei );
- sei = LDAP_SLIST_FIRST( &consumer_subentry );
- }
- break;
- }
- if ( provider_subentry ) {
- fprintf( stderr, "%s: multiple provider subentries are "
- "present : add -w flag to refresh\n", progname );
- rc = EXIT_FAILURE;
- entry_free( e );
- break;
- }
- attr = attr_find( e->e_attrs, slap_schema.si_ad_contextCSN );
- if ( attr == NULL ) {
- entry_free( e );
- continue;
- }
- provider_subentry = 1;
- ber_dupbv( &maxcsn, &attr->a_nvals[0] );
- } else if ( is_entry_syncConsumerSubentry( e )) {
- if ( provider_subentry ) {
- fprintf( stderr, "%s: consumer and provider subentries "
- "are both present\n", progname );
- rc = EXIT_FAILURE;
- entry_free( e );
- break;
- }
-
- attr = attr_find( e->e_attrs, slap_schema.si_ad_cn );
-
- if ( attr == NULL ) {
- entry_free( e );
- continue;
- }
-
- if ( !LDAP_SLIST_EMPTY( &consumer_subentry )) {
- LDAP_SLIST_FOREACH( sei, &consumer_subentry, sei_next ) {
- value_match( &match, slap_schema.si_ad_cn,
- slap_schema.si_ad_cn->ad_type->sat_equality,
- SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX,
- &sei->cn, &attr->a_nvals[0], &text );
- }
- if ( !match ) {
- fprintf( stderr, "%s: multiple consumer subentries "
- "have the same id : add -w flag to refresh\n",
- progname );
- rc = EXIT_FAILURE;
- entry_free( e );
- sei = LDAP_SLIST_FIRST( &consumer_subentry );
- while ( sei ) {
- ch_free( sei->cn.bv_val );
- ch_free( sei->ndn.bv_val );
- ch_free( sei->rdn.bv_val );
- ch_free( sei->cookie.bv_val );
- LDAP_SLIST_REMOVE_HEAD( &consumer_subentry, sei_next );
- ch_free( sei );
- sei = LDAP_SLIST_FIRST( &consumer_subentry );
- }
- break;
- }
- }
- sei = ch_calloc( 1, sizeof( struct subentryinfo ));
- ber_dupbv( &sei->cn, &attr->a_nvals[0] );
- ber_dupbv( &sei->ndn, &e->e_nname );
- dnExtractRdn( &sei->ndn, &sei->rdn, NULL );
- attr = attr_find( e->e_attrs, slap_schema.si_ad_syncreplCookie );
- if ( attr == NULL ) {
- ch_free( sei->cn.bv_val );
- ch_free( sei->ndn.bv_val );
- ch_free( sei->rdn.bv_val );
- ch_free( sei->cookie.bv_val );
- ch_free( sei );
- entry_free( e );
- continue;
- }
- ber_dupbv( &sei->cookie, &attr->a_nvals[0] );
- LDAP_SLIST_INSERT_HEAD( &consumer_subentry, sei, sei_next );