]> git.sur5r.net Git - openldap/commitdiff
Preliminary steps to enabling sync replication of config. Needs work.
authorHoward Chu <hyc@openldap.org>
Sun, 21 Jan 2007 13:44:32 +0000 (13:44 +0000)
committerHoward Chu <hyc@openldap.org>
Sun, 21 Jan 2007 13:44:32 +0000 (13:44 +0000)
Allow configuring a consumer on the provider that points to the provider
but is a no-op. This ensures that the consumer will continue to be a
consumer after the replication occurs.

servers/slapd/bconfig.c
servers/slapd/syncrepl.c

index a08e10e954fdeddf0dd3d8ff1e9df549b4f3bd5a..d9862ed9ac59cf4ca3f95bddcc68519538d900fa 100644 (file)
@@ -2959,9 +2959,6 @@ config_shadow( ConfigArgs *c, int flag )
 
        } else if ( SLAP_MONITOR(c->be) ) {
                notallowed = "monitor";
-
-       } else if ( SLAP_CONFIG(c->be) ) {
-               notallowed = "config";
        }
 
        if ( notallowed != NULL ) {
@@ -2996,7 +2993,7 @@ config_updateref(ConfigArgs *c) {
                }
                return 0;
        }
-       if(!SLAP_SHADOW(c->be)) {
+       if(!SLAP_SHADOW(c->be) && !c->be->be_syncinfo) {
                snprintf( c->msg, sizeof( c->msg ), "<%s> must appear after syncrepl or updatedn",
                        c->argv[0] );
                Debug(LDAP_DEBUG_ANY, "%s: %s\n",
@@ -3803,7 +3800,7 @@ check_name_index( CfEntryInfo *parent, ConfigType ce_type, Entry *e,
 {
        CfEntryInfo *ce;
        int index = -1, gotindex = 0, nsibs, rc = 0;
-       int renumber = 0, tailindex = 0;
+       int renumber = 0, tailindex = 0, isfrontend = 0;
        char *ptr1, *ptr2 = NULL;
        struct berval rdn;
 
@@ -3818,6 +3815,9 @@ check_name_index( CfEntryInfo *parent, ConfigType ce_type, Entry *e,
 
        /* See if the rdn has an index already */
        dnRdn( &e->e_name, &rdn );
+       if ( ce_type == Cft_Database && !strncmp( rdn.bv_val + rdn.bv_len -
+               STRLENOF("frontend"), "frontend", STRLENOF("frontend") ))
+               isfrontend = 1;
        ptr1 = ber_bvchr( &e->e_name, '{' );
        if ( ptr1 && ptr1 - e->e_name.bv_val < rdn.bv_len ) {
                char    *next;
@@ -3833,13 +3833,14 @@ check_name_index( CfEntryInfo *parent, ConfigType ce_type, Entry *e,
                }
                if ( index < 0 ) {
                        /* Special case, we allow -1 for the frontendDB */
-                       if ( index != -1 || ce_type != Cft_Database ||
-                               strncmp( ptr2+1, "frontend,", STRLENOF("frontend,") ))
-
+                       if ( index != -1 || !isfrontend )
                                return LDAP_NAMING_VIOLATION;
                }
        }
 
+       if ( !isfrontend && index == -1 )
+               index = 0;
+
        /* count related kids */
        for (nsibs=0, ce=parent->ce_kids; ce; ce=ce->ce_sibs) {
                if ( ce->ce_type == ce_type ) nsibs++;
@@ -4907,6 +4908,13 @@ out:
        return rs->sr_err;
 }
 
+static int
+config_back_delete( Operation *op, SlapReply *rs )
+{
+       send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM, NULL );
+       return rs->sr_err;
+}
+
 static int
 config_back_search( Operation *op, SlapReply *rs )
 {
@@ -5724,7 +5732,7 @@ config_back_initialize( BackendInfo *bi )
        bi->bi_op_modify = config_back_modify;
        bi->bi_op_modrdn = config_back_modrdn;
        bi->bi_op_add = config_back_add;
-       bi->bi_op_delete = 0;
+       bi->bi_op_delete = config_back_delete;
        bi->bi_op_abandon = 0;
 
        bi->bi_extended = 0;
index e26db39b8589c98369e6c33cb1ca9ea55e840b69..89358cc0688e53e24cea989af286aff3aca2af5f 100644 (file)
@@ -3243,11 +3243,36 @@ add_syncrepl(
                }
 
                si->si_be = c->be;
-               init_syncrepl( si );
-               si->si_re = ldap_pvt_runqueue_insert( &slapd_rq, si->si_interval,
-                       do_syncrepl, si, "do_syncrepl", c->be->be_suffix[0].bv_val );
-               if ( !si->si_re )
-                       rc = -1;
+               if ( slapMode & SLAP_SERVER_MODE ) {
+                       Listener **l = slapd_get_listeners();
+                       int isMe = 0;
+
+                       /* check if URL points to current server. If so, ignore
+                        * this configuration. We require an exact match. Just
+                        * in case they really want to do this, they can vary
+                        * the case of the URL to allow it.
+                        */
+                       if ( l ) {
+                               int i;
+                               for ( i=0; l[i]; i++ ) {
+                                       if ( bvmatch( &l[i]->sl_url, &si->si_bindconf.sb_uri )) {
+                                               isMe = 1;
+                                               break;
+                                       }
+                               }
+                       }
+
+                       if ( !isMe ) {
+                               init_syncrepl( si );
+                               si->si_re = ldap_pvt_runqueue_insert( &slapd_rq,
+                                       si->si_interval, do_syncrepl, si, "do_syncrepl",
+                                       c->be->be_suffix[0].bv_val );
+                               if ( si->si_re )
+                                       rc = config_sync_shadow( c ) ? -1 : 0;
+                               else
+                                       rc = -1;
+                       }
+               }
        }
 
 #ifdef HAVE_TLS
@@ -3458,8 +3483,7 @@ syncrepl_config( ConfigArgs *c )
                        "syncrepl: database already shadowed.\n",
                        c->log, 0, 0);
                return(1);
-       } else if ( add_syncrepl( c ) ) {
-               return(1);
+       } else {
+               return add_syncrepl( c );
        }
-       return config_sync_shadow( c );
 }