Do not use. backend/overlay code needs to be fixed accordingly.
In particular, code which currently frees configuration in _db_close()
must be changed to free only in _db_destroy().
After restructuring, it must be possible to call _db_close()/_db_open()
multiple times in succession without requiring _db_config() in between.
}
if(be != NULL) {
+ /* silent noop if disabled */
+ if ( SLAP_DBDISABLED( be ))
+ return 0;
if ( be->bd_info->bi_open ) {
rc = be->bd_info->bi_open( be->bd_info );
if ( rc != 0 ) {
i = -1;
LDAP_STAILQ_FOREACH(be, &backendDB, be_next) {
i++;
+ if ( SLAP_DBDISABLED( be ))
+ continue;
if ( be->be_suffix == NULL ) {
Debug( LDAP_DEBUG_ANY,
"backend_startup: warning, database %d (%s) "
/* close each backend database */
LDAP_STAILQ_FOREACH( be, &backendDB, be_next ) {
+ if ( SLAP_DBDISABLED( be ))
+ continue;
if ( be->bd_info->bi_db_close ) {
be->bd_info->bi_db_close( be, NULL );
}
Backend *be;
LDAP_STAILQ_FOREACH( be, &backendDB, be_next ) {
- if ( be->be_nsuffix == NULL || SLAP_DBHIDDEN( be )) {
+ if ( be->be_nsuffix == NULL || SLAP_DBHIDDEN( be ) || SLAP_DBDISABLED( be )) {
continue;
}
}
for (; on && rc == 0; on=on->on_next) {
+ if ( on->on_bi.bi_flags & SLAPO_BFLAG_DISABLED )
+ continue;
db.bd_info = &on->on_bi;
if ( db.bd_info->bi_db_open ) {
rc = db.bd_info->bi_db_open( &db, cr );
int rc = 0;
for (; on && rc == 0; on=on->on_next) {
+ if ( on->on_bi.bi_flags & SLAPO_BFLAG_DISABLED )
+ continue;
be->bd_info = &on->on_bi;
if ( be->bd_info->bi_db_close ) {
rc = be->bd_info->bi_db_close( be, cr );
}
for (; on && rc == 0; on=on->on_next) {
+ if ( on->on_bi.bi_flags & SLAPO_BFLAG_DISABLED )
+ continue;
be->bd_info = &on->on_bi;
if ( be->bd_info->bi_db_destroy ) {
rc = be->bd_info->bi_db_destroy( be, cr );
db.be_flags |= SLAP_DBFLAG_OVERLAY;
op->o_bd = &db;
for (; on; on=on->on_next ) {
+ if ( on->on_bi.bi_flags & SLAPO_BFLAG_DISABLED )
+ continue;
if ( on->on_response ) {
db.bd_info = (BackendInfo *)on;
rc = on->on_response( op, rs );
on = oi->oi_list;
for ( ; on; on = on->on_next ) {
+ if ( on->on_bi.bi_flags & SLAPO_BFLAG_DISABLED )
+ continue;
if ( on->on_bi.bi_access_allowed ) {
/* NOTE: do not copy the structure until required */
if ( !SLAP_ISOVERLAY( op->o_bd ) ) {
int rc = SLAP_CB_CONTINUE;
for ( ; on; on = on->on_next ) {
+ if ( on->on_bi.bi_flags & SLAPO_BFLAG_DISABLED )
+ continue;
if ( on->on_bi.bi_entry_get_rw ) {
/* NOTE: do not copy the structure until required */
if ( !SLAP_ISOVERLAY( op->o_bd ) ) {
int rc = SLAP_CB_CONTINUE;
for ( ; on; on = on->on_next ) {
+ if ( on->on_bi.bi_flags & SLAPO_BFLAG_DISABLED )
+ continue;
if ( on->on_bi.bi_entry_release_rw ) {
/* NOTE: do not copy the structure until required */
if ( !SLAP_ISOVERLAY( op->o_bd ) ) {
on = oi->oi_list;
for ( ; on; on = on->on_next ) {
+ if ( on->on_bi.bi_flags & SLAPO_BFLAG_DISABLED )
+ continue;
if ( on->on_bi.bi_acl_group ) {
/* NOTE: do not copy the structure until required */
if ( !SLAP_ISOVERLAY( op->o_bd ) ) {
on = oi->oi_list;
for ( ; on; on = on->on_next ) {
+ if ( on->on_bi.bi_flags & SLAPO_BFLAG_DISABLED )
+ continue;
if ( on->on_bi.bi_acl_attribute ) {
/* NOTE: do not copy the structure until required */
if ( !SLAP_ISOVERLAY( op->o_bd ) ) {
int rc = SLAP_CB_CONTINUE;
for (; on; on=on->on_next ) {
+ if ( on->on_bi.bi_flags & SLAPO_BFLAG_DISABLED )
+ continue;
func = &on->on_bi.bi_op_bind;
if ( func[which] ) {
op->o_bd->bd_info = (BackendInfo *)on;
}
for ( ; on; on = on->on_next ) {
+ if ( on->on_bi.bi_flags & SLAPO_BFLAG_DISABLED )
+ continue;
func = &on->on_bi.bi_connection_init;
if ( func[ which ] ) {
bd->bd_info = (BackendInfo *)on;
CFG_SYNC_SUBENTRY,
CFG_LTHREADS,
CFG_IX_HASH64,
+ CFG_DISABLED,
CFG_LAST
};
{ "defaultSearchBase", "dn", 2, 2, 0, ARG_PRE_BI|ARG_PRE_DB|ARG_DN|ARG_QUOTE|ARG_MAGIC,
&config_search_base, "( OLcfgGlAt:14 NAME 'olcDefaultSearchBase' "
"SYNTAX OMsDN SINGLE-VALUE )", NULL, NULL },
+ { "disabled", "on|off", 2, 2, 0, ARG_DB|ARG_ON_OFF|ARG_MAGIC|CFG_DISABLED,
+ &config_generic, "( OLcfgDbAt:0.21 NAME 'olcDisabled' "
+ "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
{ "disallows", "features", 2, 0, 8, ARG_PRE_DB|ARG_MAGIC,
&config_disallows, "( OLcfgGlAt:15 NAME 'olcDisallows' "
"EQUALITY caseIgnoreMatch "
"DESC 'OpenLDAP Database-specific options' "
"SUP olcConfig STRUCTURAL "
"MUST olcDatabase "
- "MAY ( olcHidden $ olcSuffix $ olcSubordinate $ olcAccess $ "
+ "MAY ( olcDisabled $ olcHidden $ olcSuffix $ olcSubordinate $ olcAccess $ "
"olcAddContentAcl $ olcLastMod $ olcLimits $ "
"olcMaxDerefDepth $ olcPlugin $ olcReadOnly $ olcReplica $ "
"olcReplicaArgsFile $ olcReplicaPidFile $ olcReplicationInterval $ "
"NAME 'olcOverlayConfig' "
"DESC 'OpenLDAP Overlay-specific options' "
"SUP olcConfig STRUCTURAL "
- "MUST olcOverlay )", Cft_Overlay, NULL, cfAddOverlay },
+ "MUST olcOverlay "
+ "MAY olcDisabled )", Cft_Overlay, NULL, cfAddOverlay },
{ "( OLcfgGlOc:6 "
"NAME 'olcIncludeFile' "
"DESC 'OpenLDAP configuration include file' "
case CFG_DEPTH:
c->value_int = c->be->be_max_deref_depth;
break;
+ case CFG_DISABLED:
+ if ( c->bi ) {
+ /* overlay */
+ if ( c->bi->bi_flags & SLAPO_BFLAG_DISABLED ) {
+ c->value_int = 1;
+ } else {
+ rc = 1;
+ }
+ } else {
+ /* database */
+ if ( SLAP_DBDISABLED( c->be )) {
+ c->value_int = 1;
+ } else {
+ rc = 1;
+ }
+ }
+ break;
case CFG_HIDDEN:
if ( SLAP_DBHIDDEN( c->be )) {
c->value_int = 1;
c->be->be_flags &= ~SLAP_DBFLAG_HIDDEN;
break;
+ case CFG_DISABLED:
+ if ( c->bi ) {
+ c->bi->bi_flags &= ~SLAP_DBFLAG_DISABLED;
+ if ( c->bi->bi_db_open ) {
+ BackendInfo *bi_orig = c->be->bd_info;
+ c->be->bd_info = c->bi;
+ rc = c->bi->bi_db_open( c->be, &c->reply );
+ c->be->bd_info = bi_orig;
+ }
+ } else {
+ c->be->be_flags &= ~SLAP_DBFLAG_DISABLED;
+ rc = backend_startup_one( c->be, &c->reply );
+ }
+ break;
+
case CFG_IX_HASH64:
slap_hash64( 0 );
break;
SLAP_DBFLAGS(c->be) &= ~SLAP_DBFLAG_MONITORING;
break;
+ case CFG_DISABLED:
+ if ( c->bi ) {
+ if (c->value_int) {
+ if ( c->bi->bi_db_close ) {
+ BackendInfo *bi_orig = c->be->bd_info;
+ c->be->bd_info = c->bi;
+ c->bi->bi_db_close( c->be, &c->reply );
+ c->be->bd_info = bi_orig;
+ }
+ c->bi->bi_flags |= SLAPO_BFLAG_DISABLED;
+ } else {
+ c->bi->bi_flags &= ~SLAPO_BFLAG_DISABLED;
+ }
+ } else {
+ if (c->value_int) {
+ backend_shutdown( c->be );
+ SLAP_DBFLAGS(c->be) |= SLAP_DBFLAG_DISABLED;
+ } else {
+ SLAP_DBFLAGS(c->be) &= ~SLAP_DBFLAG_DISABLED;
+ }
+ }
+ break;
+
case CFG_HIDDEN:
if (c->value_int)
SLAP_DBFLAGS(c->be) |= SLAP_DBFLAG_HIDDEN;
#define SLAP_DBFLAG_ACL_ADD 0x20000U /* check attr ACLs on adds */
#define SLAP_DBFLAG_SYNC_SUBENTRY 0x40000U /* use subentry for context */
#define SLAP_DBFLAG_MULTI_SHADOW 0x80000U /* uses mirrorMode/multi-master */
+#define SLAP_DBFLAG_DISABLED 0x100000U
slap_mask_t be_flags;
#define SLAP_DBFLAGS(be) ((be)->be_flags)
#define SLAP_NOLASTMOD(be) (SLAP_DBFLAGS(be) & SLAP_DBFLAG_NOLASTMOD)
#define SLAP_LASTMOD(be) (!SLAP_NOLASTMOD(be))
#define SLAP_DBHIDDEN(be) (SLAP_DBFLAGS(be) & SLAP_DBFLAG_HIDDEN)
+#define SLAP_DBDISABLED(be) (SLAP_DBFLAGS(be) & SLAP_DBFLAG_DISABLED)
#define SLAP_DB_ONE_SUFFIX(be) (SLAP_DBFLAGS(be) & SLAP_DBFLAG_ONE_SUFFIX)
#define SLAP_ISOVERLAY(be) (SLAP_DBFLAGS(be) & SLAP_DBFLAG_OVERLAY)
#define SLAP_ISGLOBALOVERLAY(be) (SLAP_DBFLAGS(be) & SLAP_DBFLAG_GLOBAL_OVERLAY)
#define SLAPO_BFLAG_SINGLE 0x01000000U
#define SLAPO_BFLAG_DBONLY 0x02000000U
#define SLAPO_BFLAG_GLOBONLY 0x04000000U
+#define SLAPO_BFLAG_DISABLED 0x08000000U
#define SLAPO_BFLAG_MASK 0xFF000000U
#define SLAP_BFLAGS(be) ((be)->bd_info->bi_flags)
#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)
+#define SLAPO_DISABLED(be) (SLAP_BFLAGS(be) & SLAPO_BFLAG_DISABLED)
char **bi_controls; /* supported controls */
char bi_ctrls[SLAP_MAX_CIDS + 1];