X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Fbackover.c;h=07388ec6620b69c869dc0a9426f24a53c8704421;hb=543c588772b22a029b60e72e45e68032935ecd54;hp=b87500ebc2fbb20c085409c11a6cdcc9bb3573e8;hpb=b831ebba7de43cc6f7f03c81c13bb30ffc63bfb6;p=openldap diff --git a/servers/slapd/backover.c b/servers/slapd/backover.c index b87500ebc2..07388ec662 100644 --- a/servers/slapd/backover.c +++ b/servers/slapd/backover.c @@ -2,7 +2,7 @@ /* $OpenLDAP$ */ /* This work is part of OpenLDAP Software . * - * Copyright 2003-2005 The OpenLDAP Foundation. + * Copyright 2003-2006 The OpenLDAP Foundation. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -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. */ @@ -754,10 +817,26 @@ overlay_find( const char *over_type ) for ( ; on; on = on->on_next ) { if ( strcmp( on->on_bi.bi_type, over_type ) == 0 ) { - break; + goto foundit; + } + + 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 ], over_type ) == 0 ) { + Debug( LDAP_DEBUG_ANY, + "overlay_find(\"%s\"): " + "obsolete name for \"%s\".\n", + on->on_bi.bi_obsolete_names[ i ], + on->on_bi.bi_type, 0 ); + goto foundit; + } + } } } +foundit:; return on; } @@ -811,7 +890,7 @@ overlay_register_control( BackendDB *be, const char *oid ) return -1; } - if ( SLAP_DBFLAGS( be ) & SLAP_DBFLAG_GLOBAL_OVERLAY ) { + if ( SLAP_ISGLOBALOVERLAY( be ) ) { BackendDB *bd; /* add to all backends... */