Commit 3ce45e11 authored by Pierangelo Masarati's avatar Pierangelo Masarati
Browse files

fix and strengthen the structural objectClass test

parent 740835df
......@@ -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;
......
......@@ -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 );
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment