From: Pierangelo Masarati Date: Thu, 12 May 2005 00:43:29 +0000 (+0000) Subject: fix and strengthen the structural objectClass test X-Git-Tag: OPENLDAP_AC_BP~664 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=3ce45e11bb7b4c0cc888173e3431f92bdeefa88e;p=openldap fix and strengthen the structural objectClass test --- diff --git a/servers/slapd/back-sql/entry-id.c b/servers/slapd/back-sql/entry-id.c index d02857553b..49d3346c7e 100644 --- a/servers/slapd/back-sql/entry-id.c +++ b/servers/slapd/back-sql/entry-id.c @@ -938,19 +938,28 @@ next:; || an_find( bsi->bsi_attrs, &AllOper ) || an_find( bsi->bsi_attrs, &slap_schema.si_ad_structuralObjectClass->ad_cname ) ) { - struct berval bv[ 2 ]; - - bv[ 0 ] = bsi->bsi_oc->bom_oc->soc_cname; - BER_BVZERO( &bv[ 1 ] ); - if ( BACKSQL_CHECK_SCHEMA( bi ) ) { + Attribute *a; const char *text = NULL; char textbuf[ 1024 ]; size_t textlen = sizeof( textbuf ); - struct berval soc; - int rc; + struct berval soc, + bv[ 2 ], + *nvals; + int rc = LDAP_SUCCESS; + + a = attr_find( bsi->bsi_e->e_attrs, + slap_schema.si_ad_objectClass ); + if ( a != NULL ) { + nvals = a->a_nvals; + + } else { + bv[ 0 ] = bsi->bsi_oc->bom_oc->soc_cname; + BER_BVZERO( &bv[ 1 ] ); + nvals = bv; + } - rc = structural_class( bv, &soc, NULL, + rc = structural_class( nvals, &soc, NULL, &text, textbuf, textlen ); if ( rc != LDAP_SUCCESS ) { Debug( LDAP_DEBUG_TRACE, "backsql_id2entry(%s): " @@ -960,11 +969,23 @@ next:; entry_clean( bsi->bsi_e ); return rc; } + + if ( !bvmatch( &soc, &bsi->bsi_oc->bom_oc->soc_cname ) ) { + Debug( LDAP_DEBUG_TRACE, "backsql_id2entry(%s): " + "computed structuralObjectClass %s " + "does not match objectClass %s associated " + "to entry\n", + bsi->bsi_e->e_name.bv_val, soc.bv_val, + bsi->bsi_oc->bom_oc->soc_cname.bv_val ); + entry_clean( bsi->bsi_e ); + return rc; + } } rc = attr_merge_normalize_one( bsi->bsi_e, slap_schema.si_ad_structuralObjectClass, - &bv[ 0 ], bsi->bsi_op->o_tmpmemctx ); + &bsi->bsi_oc->bom_oc->soc_cname, + bsi->bsi_op->o_tmpmemctx ); if ( rc != LDAP_SUCCESS ) { entry_clean( bsi->bsi_e ); return rc; diff --git a/servers/slapd/back-sql/init.c b/servers/slapd/back-sql/init.c index a6e6d292e3..f3e744fe4b 100644 --- a/servers/slapd/back-sql/init.c +++ b/servers/slapd/back-sql/init.c @@ -98,7 +98,7 @@ backsql_db_init( backsql_info *bi; Debug( LDAP_DEBUG_TRACE, "==>backsql_db_init()\n", 0, 0, 0 ); - bi = (backsql_info *)ch_calloc( 1, sizeof( backsql_info ) ); + bi = (backsql_info *)ch_malloc( sizeof( backsql_info ) ); memset( bi, '\0', sizeof( backsql_info ) ); ldap_pvt_thread_mutex_init( &bi->sql_dbconn_mutex ); ldap_pvt_thread_mutex_init( &bi->sql_schema_mutex );