From: Howard Chu Date: Wed, 7 Nov 2007 04:31:06 +0000 (+0000) Subject: ITS#5186 check for multiple suffixes at config time, not open time X-Git-Tag: OPENLDAP_REL_ENG_2_4_9~20^2~460 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=0f1bad6fb0e8a9e9b698f483bd244f460a284f3e;p=openldap ITS#5186 check for multiple suffixes at config time, not open time --- diff --git a/servers/slapd/back-bdb/init.c b/servers/slapd/back-bdb/init.c index ff7957f237..bca81d8f50 100644 --- a/servers/slapd/back-bdb/init.c +++ b/servers/slapd/back-bdb/init.c @@ -87,6 +87,10 @@ bdb_db_init( BackendDB *be, ConfigReply *cr ) be->be_private = bdb; be->be_cf_ocs = be->bd_info->bi_cf_ocs; +#ifndef BDB_MULTIPLE_SUFFIXES + SLAP_DBFLAGS( be ) |= SLAP_DBFLAG_ONE_SUFFIX; +#endif + rc = bdb_monitor_db_init( be ); return rc; @@ -119,19 +123,6 @@ bdb_db_open( BackendDB *be, ConfigReply *cr ) LDAP_XSTRING(bdb_db_open) ": \"%s\"\n", be->be_suffix[0].bv_val, 0, 0 ); -#ifndef BDB_MULTIPLE_SUFFIXES - if ( be->be_suffix[1].bv_val ) { - if (cr) { - snprintf(cr->msg, sizeof(cr->msg), - "database \"%s\": only one suffix allowed.", - be->be_suffix[0].bv_val); - Debug( LDAP_DEBUG_ANY, - LDAP_XSTRING(bdb_db_open) ": %s\n", cr->msg, 0, 0 ); - } - return -1; - } -#endif - /* Check existence of dbenv_home. Any error means trouble */ rc = stat( bdb->bi_dbenv_home, &stat1 ); if( rc != 0 ) { diff --git a/servers/slapd/bconfig.c b/servers/slapd/bconfig.c index d76ac9b1af..a0fa915259 100644 --- a/servers/slapd/bconfig.c +++ b/servers/slapd/bconfig.c @@ -2244,8 +2244,17 @@ config_suffix(ConfigArgs *c) } #endif + if (SLAP_DB_ONE_SUFFIX( c->be ) && c->be->be_suffix ) { + snprintf( c->cr_msg, sizeof( c->cr_msg ), "<%s> Only one suffix is allowed on this %s backend", + c->argv[0], c->be->bd_info->bi_type ); + Debug(LDAP_DEBUG_ANY, "%s: %s\n", + c->log, c->cr_msg, 0); + return(1); + } + pdn = c->value_dn; ndn = c->value_ndn; + if (SLAP_DBHIDDEN( c->be )) tbe = NULL; else diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index eb387104e6..abafe18bdd 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -1764,6 +1764,7 @@ struct BackendDB { #define SLAP_DBFLAG_NOLASTMOD 0x0001U #define SLAP_DBFLAG_NO_SCHEMA_CHECK 0x0002U #define SLAP_DBFLAG_HIDDEN 0x0004U +#define SLAP_DBFLAG_ONE_SUFFIX 0x0008U #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 */ @@ -1781,6 +1782,7 @@ struct BackendDB { #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_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 SLAP_DBMONITORING(be) (SLAP_DBFLAGS(be) & SLAP_DBFLAG_MONITORING)