From e2fe9e394ac9f15b8d8f1bef79c68fed8dc4fdd3 Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Wed, 26 Jan 2005 08:04:19 +0000 Subject: [PATCH] fix controls run-time registered by global overlays (kludge non longer required?) --- servers/slapd/back-ldap/chain.c | 8 +++++--- servers/slapd/backover.c | 32 +++++++++----------------------- servers/slapd/slap.h | 3 ++- 3 files changed, 16 insertions(+), 27 deletions(-) diff --git a/servers/slapd/back-ldap/chain.c b/servers/slapd/back-ldap/chain.c index b56715467c..6322cf3750 100644 --- a/servers/slapd/back-ldap/chain.c +++ b/servers/slapd/back-ldap/chain.c @@ -314,6 +314,8 @@ ldap_chain_response( Operation *op, SlapReply *rs ) char textbuf[ SLAP_TEXT_BUFLEN ]; size_t textlen = sizeof( textbuf ); + assert( SLAP_DBFLAGS( op->o_bd ) & SLAP_DBFLAG_GLOBAL_OVERLAY ); + /* global overlay: create entry */ /* NOTE: this is a hack to use the chain overlay * as global. I expect to be able to remove this @@ -504,9 +506,9 @@ ldap_chain_db_config( int rc; be->be_private = on->on_bi.bi_private; - if ( strncasecmp( argv[ 0 ], "chain-", sizeof( "chain-" ) - 1 ) == 0 ) { + if ( strncasecmp( argv[ 0 ], "chain-", STRLENOF( "chain-" ) ) == 0 ) { argv0 = argv[ 0 ]; - argv[ 0 ] = &argv[ 0 ][ sizeof( "chain-" ) - 1 ]; + argv[ 0 ] = &argv[ 0 ][ STRLENOF( "chain-" ) ]; } rc = lback->bi_db_config( be, fname, lineno, argc, argv ); if ( argv0 ) { @@ -704,7 +706,7 @@ chain_init( void ) int rc; rc = register_supported_control( LDAP_CONTROL_X_CHAINING_BEHAVIOR, - SLAP_CTRL_FRONTEND|SLAP_CTRL_ACCESS|SLAP_CTRL_HIDE, NULL, + /* SLAP_CTRL_FRONTEND| */ SLAP_CTRL_ACCESS|SLAP_CTRL_HIDE, NULL, ldap_chain_parse_ctrl, &sc_chainingBehavior ); if ( rc != LDAP_SUCCESS ) { fprintf( stderr, "Failed to register chaining behavior control: %d\n", rc ); diff --git a/servers/slapd/backover.c b/servers/slapd/backover.c index ee3ecafe6e..4f0082b0d6 100644 --- a/servers/slapd/backover.c +++ b/servers/slapd/backover.c @@ -467,33 +467,13 @@ overlay_is_inst( BackendDB *be, const char *over_type ) return 0; } -#if 0 -int -overlay_is_global( BackendDB *be ) -{ - BackendInfo *frontendBI; - - if ( !overlay_is_over( be ) ) { - return 0; - } - - frontendBI = frontendDB->bd_info; - if ( overlay_is_over( frontendDB ) ) { - frontendBI = ((slap_overinfo *)frontendBI->bi_private)->oi_orig; - } - - return ((slap_overinfo *)be->bd_info->bi_private)->oi_orig == frontendBI; -} -#endif - int overlay_register_control( BackendDB *be, const char *oid ) { int rc = 0; int gotit = 0; -#if 0 - if ( overlay_is_global( be ) ) { + if ( SLAP_DBFLAGS( be ) & SLAP_DBFLAG_GLOBAL_OVERLAY ) { int i; /* add to all backends... */ @@ -507,7 +487,7 @@ overlay_register_control( BackendDB *be, const char *oid ) if ( bd->be_controls == NULL || !ldap_charray_inlist( bd->be_controls, oid ) ) { - rc = ldap_charray_add( &be->be_controls, oid ); + rc = ldap_charray_add( &bd->be_controls, oid ); if ( rc ) { break; } @@ -515,7 +495,6 @@ overlay_register_control( BackendDB *be, const char *oid ) } } -#endif if ( rc == 0 && !gotit && !ldap_charray_inlist( be->be_controls, oid ) ) { rc = ldap_charray_add( &be->be_controls, oid ); @@ -549,6 +528,13 @@ overlay_config( BackendDB *be, const char *ov ) oi->oi_orig = be->bd_info; oi->oi_bi = *be->bd_info; + /* NOTE: the first time a global overlay is configured, + * frontendDB gets this flag; it is used later by overlays + * to determine if they're stacked on top of the frontendDB */ + if ( oi->oi_orig == frontendDB->bd_info ) { + SLAP_DBFLAGS( be ) |= SLAP_DBFLAG_GLOBAL_OVERLAY; + } + /* Save a pointer to ourself in bi_private. */ oi->oi_bi.bi_private = oi; diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index e2e739308f..6ab8ad2075 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -1593,7 +1593,8 @@ struct slap_backend_db { #define SLAP_DBFLAG_GLUE_INSTANCE 0x0010U /* a glue backend */ #define SLAP_DBFLAG_GLUE_SUBORDINATE 0x0020U /* child of a glue hierarchy */ #define SLAP_DBFLAG_GLUE_LINKED 0x0040U /* child is connected to parent */ -#define SLAP_DBFLAG_OVERLAY 0x0080U /* this db struct is an overlay */ +#define SLAP_DBFLAG_OVERLAY 0x0080U /* this db struct is an overlay */ +#define SLAP_DBFLAG_GLOBAL_OVERLAY 0x0100U /* this db struct is a global overlay */ #define SLAP_DBFLAG_SHADOW 0x8000U /* a shadow */ #define SLAP_DBFLAG_SYNC_SHADOW 0x1000U /* a sync shadow */ #define SLAP_DBFLAG_SLURP_SHADOW 0x2000U /* a slurp shadow */ -- 2.39.5