diff --git a/servers/slapd/bconfig.c b/servers/slapd/bconfig.c index 3004898cf5..e6e7401f02 100644 --- a/servers/slapd/bconfig.c +++ b/servers/slapd/bconfig.c @@ -1147,6 +1147,36 @@ config_copy_controls( Operation *op, SlapReply *rs ) static int config_unique_db; +static int +CfOc_cmp( const void *c1, const void *c2 ); + +static int +config_check_db_class(ConfigArgs *c) { + Entry *e; + Attribute *oc_at; + ObjectClass *oc; + BackendInfo *bi; + ConfigOCs co, *bi_ocs, *coptr; + if (!c->ca_op) { + return 0; + } + if ((bi = backend_info(c->argv[1])) == NULL) { + return 0; + } + e = c->ca_op->ora_e; + /* should be present or merged at this point */ + if ((oc_at = attr_find( e->e_attrs, slap_schema.si_ad_objectClass )) == NULL) + return 0; + if ( (oc = oc_bvfind( &oc_at->a_nvals[oc_at->a_numvals-1])) == NULL ) + return 0; + co.co_name = &oc->soc_cname; + if ((coptr = ldap_avl_find( CfOcTree, &co, CfOc_cmp )) == NULL) + return 0; + bi_ocs = bi->bi_cf_ocs; + if ( coptr != bi_ocs ) + return -1; + return 0; +} static int config_generic(ConfigArgs *c) { int i; @@ -1939,6 +1969,10 @@ config_generic(ConfigArgs *c) { c->be = frontendDB; config_unique_db |= GOT_FRONTEND; } else { + if (config_check_db_class(c) != 0) { + sprintf( c->cr_msg, "Entry object class is inconsistent with backend type"); + return (1); + } c->be = backend_db_init(c->argv[1], NULL, c->valx, &c->reply); if ( !c->be ) { if ( c->cr_msg[0] == 0 )