]> git.sur5r.net Git - openldap/commitdiff
fix and strengthen the structural objectClass test
authorPierangelo Masarati <ando@openldap.org>
Thu, 12 May 2005 00:43:29 +0000 (00:43 +0000)
committerPierangelo Masarati <ando@openldap.org>
Thu, 12 May 2005 00:43:29 +0000 (00:43 +0000)
servers/slapd/back-sql/entry-id.c
servers/slapd/back-sql/init.c

index d02857553b06dcf62dc782586107375cc1379ab7..49d3346c7e5715d73f6dc1741ae93f60c057a98b 100644 (file)
@@ -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;
index a6e6d292e3157cac527a1fb04213111728f6daa5..f3e744fe4bc1e698cf7aa06272407a0e05ec051f 100644 (file)
@@ -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 );