]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/syncrepl.c
Detect TLS config changes
[openldap] / servers / slapd / syncrepl.c
index ac1042abd18ead5b9b81c4801875252bc221de56..19c31ec6e5058ba6ec4f4464ee66449a1c7e8110 100644 (file)
@@ -433,7 +433,22 @@ do_syncrep1(
        }
 
        op->o_protocol = LDAP_VERSION3;
-       ldap_set_option( si->si_ld, LDAP_OPT_PROTOCOL_VERSION, &op->o_protocol );
+       ldap_set_option( si->si_ld, LDAP_OPT_PROTOCOL_VERSION,
+               (const void *)&op->o_protocol );
+
+#ifdef HAVE_TLS
+       if ( si->si_bindconf.sb_tls_do_init ) {
+               rc = bindconf_tls_set( &si->si_bindconf, si->si_ld );
+       } else if ( si->si_bindconf.sb_tls_ctx ) {
+               rc = ldap_set_option( si->si_ld, LDAP_OPT_X_TLS_CTX,
+                       si->si_bindconf.sb_tls_ctx );
+       }
+       if ( rc ) {
+               Debug( LDAP_DEBUG_ANY,
+                       "do_syncrep1: TLS context initialization failed\n", 0, 0, 0 );
+               return rc;
+       }
+#endif
 
        /* Bind to master */
 
@@ -1672,8 +1687,13 @@ syncrepl_entry(
        f.f_choice = LDAP_FILTER_EQUALITY;
        f.f_ava = &ava;
        ava.aa_desc = slap_schema.si_ad_entryUUID;
-       (void)slap_uuidstr_from_normalized( &syncUUID_strrep, syncUUID, op->o_tmpmemctx );
        ava.aa_value = *syncUUID;
+
+       (void)slap_uuidstr_from_normalized( &syncUUID_strrep, syncUUID, op->o_tmpmemctx );
+       if ( syncuuid_bv ) {
+               Debug( LDAP_DEBUG_SYNC, "syncrepl_entry: inserted UUID %s\n",
+                       syncUUID_strrep.bv_val, 0, 0 );
+       }
        op->ors_filter = &f;
 
        op->ors_filterstr.bv_len = STRLENOF( "(entryUUID=)" ) + syncUUID_strrep.bv_len;
@@ -2478,10 +2498,14 @@ nonpresent_callback(
                if ( !(si->si_refreshDelete & NP_DELETE_ONE )) {
                        a = attr_find( rs->sr_entry->e_attrs, slap_schema.si_ad_entryUUID );
 
-                       if ( a == NULL ) return 0;
+                       if ( a )
+                               present_uuid = avl_find( si->si_presentlist, &a->a_nvals[0],
+                                       syncuuid_cmp );
 
-                       present_uuid = avl_find( si->si_presentlist, &a->a_nvals[0],
-                               syncuuid_cmp );
+                       Debug( LDAP_DEBUG_SYNC, "nonpresent_callback: UUID %s, dn %s, %sfound\n",
+                               a ? a->a_vals[0].bv_val : "<missing>", rs->sr_entry->e_name.bv_val, present_uuid ? "" : "not " );
+
+                       if ( a == NULL ) return 0;
                }
 
                if ( present_uuid == NULL ) {
@@ -2729,10 +2753,11 @@ syncinfo_free( syncinfo_t *sie )
 
 /* mandatory */
 #define GOT_ID                 0x0001
-#define GOT_PROVIDER           0x0002
+#define GOT_PROVIDER   0x0002
+#define        GOT_BASE                0x0004
 
 /* check */
-#define GOT_ALL                        (GOT_ID|GOT_PROVIDER)
+#define GOT_ALL                        (GOT_ID|GOT_PROVIDER|GOT_BASE)
 
 static struct {
        struct berval key;
@@ -2742,6 +2767,7 @@ static struct {
        { BER_BVC("one"), LDAP_SCOPE_ONELEVEL },
        { BER_BVC("onelevel"), LDAP_SCOPE_ONELEVEL },   /* OpenLDAP extension */
        { BER_BVC("children"), LDAP_SCOPE_SUBORDINATE },
+       { BER_BVC("subord"), LDAP_SCOPE_SUBORDINATE },
        { BER_BVC("subordinate"), LDAP_SCOPE_SUBORDINATE },
        { BER_BVC("sub"), LDAP_SCOPE_SUBTREE },
        { BER_BVC("subtree"), LDAP_SCOPE_SUBTREE },     /* OpenLDAP extension */
@@ -2837,6 +2863,7 @@ parse_syncrepl_line(
                                Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->msg, 0 );
                                return -1;
                        }
+                       gots |= GOT_BASE;
                } else if ( !strncasecmp( c->argv[ i ], LOGBASESTR "=",
                                        STRLENOF( LOGBASESTR "=" ) ) )
                {
@@ -2963,8 +2990,11 @@ parse_syncrepl_line(
                        } else if ( strchr( val, ':' ) != NULL ) {
                                char *next, *ptr = val;
                                unsigned dd, hh, mm, ss;
+
+                               /* NOTE: the test for ptr[ 0 ] == '-'
+                                * should go before the call to strtoul() */
                                dd = strtoul( ptr, &next, 10 );
-                               if ( next == ptr || next[0] != ':' ) {
+                               if ( ptr[ 0 ] == '-' || next == ptr || next[0] != ':' ) {
                                        snprintf( c->msg, sizeof( c->msg ),
                                                "Error: parse_syncrepl_line: "
                                                "invalid interval \"%s\", unable to parse days", val );
@@ -2973,7 +3003,7 @@ parse_syncrepl_line(
                                }
                                ptr = next + 1;
                                hh = strtoul( ptr, &next, 10 );
-                               if ( next == ptr || next[0] != ':' || hh > 24 ) {
+                               if ( ptr[ 0 ] == '-' || next == ptr || next[0] != ':' || hh > 24 ) {
                                        snprintf( c->msg, sizeof( c->msg ),
                                                "Error: parse_syncrepl_line: "
                                                "invalid interval \"%s\", unable to parse hours", val );
@@ -2982,7 +3012,7 @@ parse_syncrepl_line(
                                }
                                ptr = next + 1;
                                mm = strtoul( ptr, &next, 10 );
-                               if ( next == ptr || next[0] != ':' || mm > 60 ) {
+                               if ( ptr[ 0 ] == '-' || next == ptr || next[0] != ':' || mm > 60 ) {
                                        snprintf( c->msg, sizeof( c->msg ),
                                                "Error: parse_syncrepl_line: "
                                                "invalid interval \"%s\", unable to parse minutes", val );
@@ -2991,7 +3021,7 @@ parse_syncrepl_line(
                                }
                                ptr = next + 1;
                                ss = strtoul( ptr, &next, 10 );
-                               if ( next == ptr || next[0] != '\0' || ss > 60 ) {
+                               if ( ptr[ 0 ] == '-' || next == ptr || next[0] != '\0' || ss > 60 ) {
                                        snprintf( c->msg, sizeof( c->msg ),
                                                "Error: parse_syncrepl_line: "
                                                "invalid interval \"%s\", unable to parse seconds", val );
@@ -3150,7 +3180,10 @@ parse_syncrepl_line(
 
        if ( gots != GOT_ALL ) {
                snprintf( c->msg, sizeof( c->msg ),
-                       "Error: Malformed \"syncrepl\" line in slapd config file" );
+                       "Error: Malformed \"syncrepl\" line in slapd config file, missing%s%s%s",
+                       gots & GOT_ID ? "" : " "IDSTR,
+                       gots & GOT_PROVIDER ? "" : " "PROVIDERSTR,
+                       gots & GOT_BASE ? "" : " "SEARCHBASESTR );
                Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->msg, 0 );
                return -1;
        }
@@ -3405,8 +3438,6 @@ syncrepl_config( ConfigArgs *c )
                }
                return 1;
        } else if ( c->op == LDAP_MOD_DELETE ) {
-               struct re_s *re;
-
                if ( c->be->be_syncinfo ) {
                        syncinfo_free( c->be->be_syncinfo );
                        c->be->be_syncinfo = NULL;