]> git.sur5r.net Git - openldap/commitdiff
allow dynlist to take over dyngroup
authorPierangelo Masarati <ando@openldap.org>
Tue, 29 Nov 2005 10:02:05 +0000 (10:02 +0000)
committerPierangelo Masarati <ando@openldap.org>
Tue, 29 Nov 2005 10:02:05 +0000 (10:02 +0000)
servers/slapd/backover.c
servers/slapd/overlays/dynlist.c

index 1a2aa3e0e5a63ec6e453f08fe6e637bfe14f7977..0aa4a72be93ca3e193060cc214b0a7282ac5d2fa 100644 (file)
@@ -716,6 +716,69 @@ overlay_register(
        slap_overinst *on
 )
 {
+       slap_overinst   *tmp;
+
+       /* FIXME: check for duplicates? */
+       for ( tmp = overlays; tmp != NULL; tmp = tmp->on_next ) {
+               if ( strcmp( on->on_bi.bi_type, tmp->on_bi.bi_type ) == 0 ) {
+                       Debug( LDAP_DEBUG_ANY,
+                               "overlay_register(\"%s\"): "
+                               "name already in use.\n",
+                               on->on_bi.bi_type, 0, 0 );
+                       return -1;
+               }
+
+               if ( on->on_bi.bi_obsolete_names != NULL ) {
+                       int     i;
+
+                       for ( i = 0; on->on_bi.bi_obsolete_names[ i ] != NULL; i++ ) {
+                               if ( strcmp( on->on_bi.bi_obsolete_names[ i ], tmp->on_bi.bi_type ) == 0 ) {
+                                       Debug( LDAP_DEBUG_ANY,
+                                               "overlay_register(\"%s\"): "
+                                               "obsolete name \"%s\" already in use "
+                                               "by overlay \"%s\".\n",
+                                               on->on_bi.bi_type,
+                                               on->on_bi.bi_obsolete_names[ i ],
+                                               tmp->on_bi.bi_type );
+                                       return -1;
+                               }
+                       }
+               }
+
+               if ( tmp->on_bi.bi_obsolete_names != NULL ) {
+                       int     i;
+
+                       for ( i = 0; tmp->on_bi.bi_obsolete_names[ i ] != NULL; i++ ) {
+                               int     j;
+
+                               if ( strcmp( on->on_bi.bi_type, tmp->on_bi.bi_obsolete_names[ i ] ) == 0 ) {
+                                       Debug( LDAP_DEBUG_ANY,
+                                               "overlay_register(\"%s\"): "
+                                               "name already in use "
+                                               "as obsolete by overlay \"%s\".\n",
+                                               on->on_bi.bi_type,
+                                               tmp->on_bi.bi_obsolete_names[ i ], 0 );
+                                       return -1;
+                               }
+
+                               if ( on->on_bi.bi_obsolete_names != NULL ) {
+                                       for ( j = 0; on->on_bi.bi_obsolete_names[ j ] != NULL; j++ ) {
+                                               if ( strcmp( on->on_bi.bi_obsolete_names[ j ], tmp->on_bi.bi_obsolete_names[ i ] ) == 0 ) {
+                                                       Debug( LDAP_DEBUG_ANY,
+                                                               "overlay_register(\"%s\"): "
+                                                               "obsolete name \"%s\" already in use "
+                                                               "as obsolete by overlay \"%s\".\n",
+                                                               on->on_bi.bi_type,
+                                                               on->on_bi.bi_obsolete_names[ j ],
+                                                               tmp->on_bi.bi_type );
+                                                       return -1;
+                                               }
+                                       }
+                               }
+                       }
+               }
+       }
+
        on->on_next = overlays;
        overlays = on;
        return 0;
@@ -723,8 +786,8 @@ overlay_register(
 
 /*
  * iterator on registered overlays; overlay_next( NULL ) returns the first
- * overlay; subsequent calls with the previously returned value allow to 
- * iterate over the entire list; returns NULL when no more overlays are 
+ * overlay; subsequent calls with the previously returned value allow to 
+ * iterate over the entire list; returns NULL when no more overlays are 
  * registered.
  */
 
@@ -771,7 +834,6 @@ overlay_find( const char *over_type )
                                }
                        }
                }
-
        }
 
 foundit:;
index 80c3835446f7543d8f180b998fcd9be3e2b1acd0..7e895381177e18e8300fd80dc561dcc322ff6c3f 100644 (file)
@@ -24,6 +24,8 @@
 
 #if LDAP_VENDOR_VERSION_MINOR != X && LDAP_VENDOR_VERSION_MINOR < 3
 #define OL_2_2_COMPAT
+#elif defined(LDAP_DEVEL) && SLAPD_OVER_DYNGROUP != SLAPD_MOD_STATIC
+#define TAKEOVER_DYNGROUP
 #endif
 
 #include <stdio.h>
@@ -867,6 +869,7 @@ dynlist_db_config(
 enum {
        DL_ATTRSET = 1,
        DL_ATTRPAIR,
+       DL_ATTRPAIR_COMPAT,
        DL_LAST
 };
 
@@ -884,6 +887,11 @@ static ConfigTable dlcfg[] = {
        { "dynlist-attrpair", "member-ad> <URL-ad",
                3, 3, 0, ARG_MAGIC|DL_ATTRPAIR, dl_cfgen,
                        NULL, NULL, NULL },
+#ifdef TAKEOVER_DYNGROUP
+       { "attrpair", "member-ad> <URL-ad",
+               3, 3, 0, ARG_MAGIC|DL_ATTRPAIR_COMPAT, dl_cfgen,
+                       NULL, NULL, NULL },
+#endif
        { NULL, NULL, 0, 0, 0, ARG_IGNORED }
 };
 
@@ -932,6 +940,7 @@ dl_cfgen( ConfigArgs *c )
                        }
                        break;
 
+               case DL_ATTRPAIR_COMPAT:
                case DL_ATTRPAIR:
                        rc = 1;
                        break;
@@ -979,6 +988,7 @@ dl_cfgen( ConfigArgs *c )
                        }
                        break;
 
+               case DL_ATTRPAIR_COMPAT:
                case DL_ATTRPAIR:
                        rc = 1;
                        break;
@@ -1082,6 +1092,13 @@ dl_cfgen( ConfigArgs *c )
 
                } break;
 
+       case DL_ATTRPAIR_COMPAT:
+               snprintf( c->msg, sizeof( c->msg ),
+                       "warning: \"attrpair\" only supported for limited "
+                       "backward compatibility with overlay \"dyngroup\"" );
+               Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->msg, 0 );
+               /* fallthru */
+
        case DL_ATTRPAIR: {
                dynlist_info_t          **dlip;
                ObjectClass             *oc = NULL;
@@ -1231,7 +1248,11 @@ dynlist_db_destroy(
        return 0;
 }
 
-static slap_overinst dynlist = { { NULL } };
+static slap_overinst   dynlist = { { NULL } };
+static char            *obsolete_names[] = {
+       "dyngroup",
+       NULL
+};
 
 #if SLAPD_OVER_DYNLIST == SLAPD_MOD_DYNAMIC
 static
@@ -1244,6 +1265,12 @@ dynlist_initialize(void)
 #endif
 
        dynlist.on_bi.bi_type = "dynlist";
+
+#ifdef TAKEOVER_DYNGROUP
+       /* makes dynlist incompatible with dyngroup */
+       dynlist.on_bi.bi_obsolete_names = obsolete_names;
+#endif
+
 #ifdef OL_2_2_COMPAT
        dynlist.on_bi.bi_db_config = dynlist_db_config;
 #else