CfEntryInfo *cb_root;
BackendDB cb_db; /* underlying database */
int cb_got_ldif;
+#define BCONFIG_GOT_LDIF 0x1
+#define BCONFIG_GOT_FRONTEND 0x2
+#define BCONFIG_GOT_CONFIG 0x4
int cb_use_ldif;
ldap_pvt_thread_rdwr_t cb_rwlock;
} CfBackInfo;
setup_cookie *sc = op->o_callback->sc_private;
struct berval pdn;
- sc->cfb->cb_got_ldif = 1;
+ sc->cfb->cb_got_ldif |= BCONFIG_GOT_LDIF;
/* Does the frontend exist? */
if ( !sc->got_frontend ) {
if ( !strncmp( rs->sr_entry->e_nname.bv_val,
op->o_noop = i;
sc->got_frontend++;
} else {
+ sc->cfb->cb_got_ldif |= BCONFIG_GOT_FRONTEND;
sc->got_frontend++;
goto ok;
}
sc->config = config_build_entry( op, rs, sc->cfb->cb_root,
sc->ca, &rdn, &CFOC_DATABASE, sc->ca->be->be_cf_ocs );
op->o_noop = i;
+ } else {
+ sc->cfb->cb_got_ldif |= BCONFIG_GOT_CONFIG;
}
sc->got_config++;
}
rs_reinit( &rs, REP_RESULT );
op->ora_e = sc.frontend;
rc = op->o_bd->be_add( op, &rs );
+ if ( rc == LDAP_SUCCESS ) {
+ cfb->cb_got_ldif |= BCONFIG_GOT_FRONTEND;
+ }
}
if ( rc == LDAP_SUCCESS && sc.config ) {
rs_reinit( &rs, REP_RESULT );
op->ora_e = sc.config;
rc = op->o_bd->be_add( op, &rs );
+ if ( rc == LDAP_SUCCESS ) {
+ cfb->cb_got_ldif |= BCONFIG_GOT_CONFIG;
+ }
}
ldap_pvt_thread_pool_context_reset( thrctx );
} else {
return 1;
/* Assume it's slapadd with a config dir, let it continue */
rc = 0;
- cfb->cb_got_ldif = 1;
+ cfb->cb_got_ldif = BCONFIG_GOT_LDIF;
cfb->cb_use_ldif = 1;
goto done;
}
return NULL;
}
-static int entry_put_got_frontend=0;
-static int entry_put_got_config=0;
static ID
config_tool_entry_put( BackendDB *be, Entry *e, struct berval *text )
{
int isFrontendChild = 0;
/* Create entry for frontend database if it does not exist already */
- if ( !entry_put_got_frontend ) {
+ if ( !(cfb->cb_got_ldif & BCONFIG_GOT_FRONTEND) ) {
if ( !strncmp( e->e_nname.bv_val, "olcDatabase",
STRLENOF( "olcDatabase" ))) {
if ( strncmp( e->e_nname.bv_val +
if ( ce && bi && bi->bi_tool_entry_put &&
bi->bi_tool_entry_put( &cfb->cb_db, ce, text ) != NOID ) {
- entry_put_got_frontend++;
+ cfb->cb_got_ldif |= BCONFIG_GOT_FRONTEND;
} else {
text->bv_val = "autocreation of \"olcDatabase={-1}frontend\" failed";
text->bv_len = STRLENOF("autocreation of \"olcDatabase={-1}frontend\" failed");
return NOID;
}
} else {
- entry_put_got_frontend++;
+ cfb->cb_got_ldif |= BCONFIG_GOT_FRONTEND;
isFrontend = 1;
}
}
/* Child entries of the frontend database, e.g. slapo-chain's back-ldap
* instances, may appear before the config database entry in the ldif, skip
* auto-creation of olcDatabase={0}config in such a case */
- if ( !entry_put_got_config &&
+ if ( !(cfb->cb_got_ldif & BCONFIG_GOT_CONFIG) &&
!strncmp( e->e_nname.bv_val, "olcDatabase", STRLENOF( "olcDatabase" ))) {
struct berval pdn;
dnParent( &e->e_nname, &pdn );
}
/* Create entry for config database if it does not exist already */
- if ( !entry_put_got_config && !isFrontend && !isFrontendChild ) {
+ if ( !(cfb->cb_got_ldif & BCONFIG_GOT_CONFIG) && !isFrontend &&
+ !isFrontendChild ) {
if ( !strncmp( e->e_nname.bv_val, "olcDatabase",
STRLENOF( "olcDatabase" ))) {
if ( strncmp( e->e_nname.bv_val +
}
if (ce && bi && bi->bi_tool_entry_put &&
bi->bi_tool_entry_put( &cfb->cb_db, ce, text ) != NOID ) {
- entry_put_got_config++;
+ cfb->cb_got_ldif |= BCONFIG_GOT_CONFIG;
} else {
text->bv_val = "autocreation of \"olcDatabase={0}config\" failed";
text->bv_len = STRLENOF("autocreation of \"olcDatabase={0}config\" failed");
return NOID;
}
} else {
- entry_put_got_config++;
+ cfb->cb_got_ldif |= BCONFIG_GOT_CONFIG;
}
}
}