X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Fbackover.c;h=07388ec6620b69c869dc0a9426f24a53c8704421;hb=a17df0e810578d593808c6afeb0cdea55a65633c;hp=136fb95ff0344e666014cf4529faa477bfeae7f0;hpb=51ebb4ee99ad1f6ae6365443ceaade834f516c09;p=openldap diff --git a/servers/slapd/backover.c b/servers/slapd/backover.c index 136fb95ff0..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 @@ -252,7 +252,7 @@ over_access_allowed( { slap_overinfo *oi; slap_overinst *on; - BackendInfo *bi = op->o_bd->bd_info; + BackendInfo *bi; BackendDB *be = op->o_bd, db; int rc = SLAP_CB_CONTINUE; @@ -260,7 +260,13 @@ over_access_allowed( * when global overlays are used... */ assert( op->o_bd != NULL ); - oi = op->o_bd->bd_info->bi_private; + bi = op->o_bd->bd_info; + /* Were we invoked on the frontend? */ + if ( !bi->bi_access_allowed ) { + oi = frontendDB->bd_info->bi_private; + } else { + oi = op->o_bd->bd_info->bi_private; + } on = oi->oi_list; for ( ; on; on = on->on_next ) { @@ -710,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; @@ -717,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. */ @@ -748,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; } @@ -805,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... */