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
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 ) {
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 );
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... */
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;
}
}
}
-#endif
if ( rc == 0 && !gotit && !ldap_charray_inlist( be->be_controls, oid ) ) {
rc = ldap_charray_add( &be->be_controls, oid );
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;
#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 */