let overlays define if they must appear exactly once in a chain, and if they must be global/per-db only, and holler in case

This commit is contained in:
Pierangelo Masarati 2006-01-14 18:02:35 +00:00
parent 7f826af5fd
commit a029490fe8
3 changed files with 41 additions and 6 deletions

View File

@ -952,15 +952,33 @@ overlay_config( BackendDB *be, const char *ov )
* overlay info structure
*/
if ( !overlay_is_over( be ) ) {
int isglobal = 0;
/* 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 ( be->bd_info == frontendDB->bd_info || SLAP_ISGLOBALOVERLAY( be ) ) {
isglobal = 1;
if ( on->on_bi.bi_flags & SLAPO_BFLAG_DBONLY ) {
Debug( LDAP_DEBUG_ANY, "overlay_config(): "
"overlay \"%s\" cannot be global.\n",
ov, 0, 0 );
return 1;
}
} else if ( on->on_bi.bi_flags & SLAPO_BFLAG_GLOBONLY ) {
Debug( LDAP_DEBUG_ANY, "overlay_config(): "
"overlay \"%s\" can only be global.\n",
ov, 0, 0 );
return 1;
}
oi = ch_malloc( sizeof( slap_overinfo ) );
oi->oi_orig = be->bd_info;
oi->oi_bi = *be->bd_info;
oi->oi_origdb = be;
/* 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 ) {
if ( isglobal ) {
SLAP_DBFLAGS( be ) |= SLAP_DBFLAG_GLOBAL_OVERLAY;
}
@ -1015,8 +1033,11 @@ overlay_config( BackendDB *be, const char *ov )
} else {
if ( overlay_is_inst( be, ov ) ) {
Debug( LDAP_DEBUG_ANY, "overlay_config(): "
"warning, overlay \"%s\" "
"already in list\n", ov, 0, 0 );
"overlay \"%s\" already in list\n",
ov, 0, 0 );
if ( SLAPO_SINGLE( be ) ) {
return 1;
}
}
oi = be->bd_info->bi_private;

View File

@ -1509,6 +1509,9 @@ rwm_initialize(void)
memset( &rwm, 0, sizeof( slap_overinst ) );
rwm.on_bi.bi_type = "rwm";
rwm.on_bi.bi_flags =
SLAPO_BFLAG_SINGLE |
0;
rwm.on_bi.bi_db_init = rwm_db_init;
rwm.on_bi.bi_db_config = rwm_db_config;

View File

@ -2160,6 +2160,12 @@ struct slap_backend_info {
#define SLAP_BFLAG_SUBENTRIES 0x4000U
#define SLAP_BFLAG_DYNAMIC 0x8000U
/* overlay specific */
#define SLAPO_BFLAG_SINGLE 0x01000000U
#define SLAPO_BFLAG_DBONLY 0x02000000U
#define SLAPO_BFLAG_GLOBONLY 0x04000000U
#define SLAPO_BFLAG_MASK 0xFF000000U
#define SLAP_BFLAGS(be) ((be)->bd_info->bi_flags)
#define SLAP_MONITOR(be) (SLAP_BFLAGS(be) & SLAP_BFLAG_MONITOR)
#define SLAP_CONFIG(be) (SLAP_BFLAGS(be) & SLAP_BFLAG_CONFIG)
@ -2172,6 +2178,11 @@ struct slap_backend_info {
#define SLAP_NOLASTMODCMD(be) (SLAP_BFLAGS(be) & SLAP_BFLAG_NOLASTMODCMD)
#define SLAP_LASTMODCMD(be) (!SLAP_NOLASTMODCMD(be))
/* overlay specific */
#define SLAPO_SINGLE(be) (SLAP_BFLAGS(be) & SLAPO_BFLAG_SINGLE)
#define SLAPO_DBONLY(be) (SLAP_BFLAGS(be) & SLAPO_BFLAG_DBONLY)
#define SLAPO_GLOBONLY(be) (SLAP_BFLAGS(be) & SLAPO_BFLAG_GLOBONLY)
char **bi_controls; /* supported controls */
char bi_ctrls[SLAP_MAX_CIDS + 1];