]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/syncrepl.c
Cleanup
[openldap] / servers / slapd / syncrepl.c
index ac0379c8eaf363e725387d307fe42f100d3b53b7..4933933935cc9cea4fd97f3c51fdcdf6307be4d8 100644 (file)
@@ -165,13 +165,6 @@ init_syncrepl(syncinfo_t *si)
                sync_descs[3] = NULL;
        }
 
-       if ( SLAP_SYNC_SUBENTRY( si->si_be )) {
-               build_new_dn( &si->si_contextdn, &si->si_be->be_nsuffix[0],
-                       (struct berval *)&slap_ldapsync_cn_bv, NULL );
-       } else {
-               si->si_contextdn = si->si_be->be_nsuffix[0];
-       }
-
        if ( si->si_allattrs && si->si_allopattrs )
                attrs = NULL;
        else
@@ -586,8 +579,9 @@ do_syncrep1(
        {
                ber_len_t ssf; /* ITS#5403, 3864 LDAP_OPT_X_SASL_SSF probably ought
                                                  to use sasl_ssf_t but currently uses ber_len_t */
-               ldap_get_option( si->si_ld, LDAP_OPT_X_SASL_SSF, &ssf );
-               op->o_sasl_ssf = ssf;
+               if ( ldap_get_option( si->si_ld, LDAP_OPT_X_SASL_SSF, &ssf )
+                       == LDAP_SUCCESS )
+                       op->o_sasl_ssf = ssf;
        }
        op->o_ssf = ( op->o_sasl_ssf > op->o_tls_ssf )
                ?  op->o_sasl_ssf : op->o_tls_ssf;
@@ -1329,12 +1323,18 @@ do_syncrepl(
                if ( SLAP_GLUE_SUBORDINATE( be ) && !overlay_is_inst( be, "syncprov" )) {
                        BackendDB * top_be = select_backend( &be->be_nsuffix[0], 1 );
                        if ( overlay_is_inst( top_be, "syncprov" ))
-                               si->si_wbe = select_backend( &be->be_nsuffix[0], 1 );
+                               si->si_wbe = top_be;
                        else
                                si->si_wbe = be;
                } else {
                        si->si_wbe = be;
                }
+               if ( SLAP_SYNC_SUBENTRY( si->si_wbe )) {
+                       build_new_dn( &si->si_contextdn, &si->si_wbe->be_nsuffix[0],
+                               (struct berval *)&slap_ldapsync_cn_bv, NULL );
+               } else {
+                       si->si_contextdn = si->si_wbe->be_nsuffix[0];
+               }
        }
        if ( !si->si_schemachecking )
                op->o_no_schema_check = 1;
@@ -3062,8 +3062,8 @@ syncrepl_updateCookie(
        op->orm_no_opattrs = 1;
        rc = op->o_bd->be_modify( op, &rs_modify );
 
-       /* Should only happen when SYNC_USE_SUBENTRY */
-       if ( rs_modify.sr_err == LDAP_NO_SUCH_OBJECT ) {
+       if ( rs_modify.sr_err == LDAP_NO_SUCH_OBJECT &&
+               SLAP_SYNC_SUBENTRY( op->o_bd )) {
                const char      *text;
                char txtbuf[SLAP_TEXT_BUFLEN];
                size_t textlen = sizeof txtbuf;