diff --git a/servers/slapd/backover.c b/servers/slapd/backover.c index 07388ec662..33b31d5400 100644 --- a/servers/slapd/backover.c +++ b/servers/slapd/backover.c @@ -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; diff --git a/servers/slapd/overlays/rwm.c b/servers/slapd/overlays/rwm.c index 2880ed8f6c..5626eb3c71 100644 --- a/servers/slapd/overlays/rwm.c +++ b/servers/slapd/overlays/rwm.c @@ -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; diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index 6c18cb88bb..9004133dee 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -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];