From: Pierangelo Masarati Date: Thu, 12 May 2005 00:03:50 +0000 (+0000) Subject: remove global_schemacheck X-Git-Tag: OPENLDAP_AC_BP~665 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=740835dff9c50a3b71bc12d2e9d1b2e43965e1d3;p=openldap remove global_schemacheck --- diff --git a/servers/slapd/back-sql/add.c b/servers/slapd/back-sql/add.c index 40aac5a3e4..03accfc5ea 100644 --- a/servers/slapd/back-sql/add.c +++ b/servers/slapd/back-sql/add.c @@ -986,7 +986,7 @@ backsql_add( Operation *op, SlapReply *rs ) op->ora_e->e_name.bv_val, 0, 0 ); /* check schema */ - if ( global_schemacheck ) { + if ( BACKSQL_CHECK_SCHEMA( bi ) ) { char textbuf[ SLAP_TEXT_BUFLEN ] = { '\0' }; rs->sr_err = entry_schema_check( op->o_bd, op->ora_e, diff --git a/servers/slapd/back-sql/back-sql.h b/servers/slapd/back-sql/back-sql.h index d905d2bf23..9945a615db 100644 --- a/servers/slapd/back-sql/back-sql.h +++ b/servers/slapd/back-sql/back-sql.h @@ -508,6 +508,7 @@ typedef struct backsql_info { #define BSQLF_FETCH_ALL_USERATTRS 0x0200 #define BSQLF_FETCH_ALL_OPATTRS 0x0400 #define BSQLF_FETCH_ALL_ATTRS (BSQLF_FETCH_ALL_USERATTRS|BSQLF_FETCH_ALL_OPATTRS) +#define BSQLF_CHECK_SCHEMA 0x0800 #define BACKSQL_ISF(si, f) \ (((si)->sql_flags & f) == f) @@ -538,6 +539,8 @@ typedef struct backsql_info { BACKSQL_ISF(si, BSQLF_FETCH_ALL_OPATTRS) #define BACKSQL_FETCH_ALL_ATTRS(si) \ BACKSQL_ISF(si, BSQLF_FETCH_ALL_ATTRS) +#define BACKSQL_CHECK_SCHEMA(si) \ + BACKSQL_ISF(si, BSQLF_CHECK_SCHEMA) Entry *sql_baseObject; #ifdef BACKSQL_ARBITRARY_KEY diff --git a/servers/slapd/back-sql/config.c b/servers/slapd/back-sql/config.c index 9e82f0b358..1a89a0da84 100644 --- a/servers/slapd/back-sql/config.c +++ b/servers/slapd/back-sql/config.c @@ -561,6 +561,36 @@ backsql_db_config( return -1; } + } else if ( !strcasecmp( argv[ 0 ], "check_schema") ) { + if ( argc < 2 ) { + Debug( LDAP_DEBUG_TRACE, + "<==backsql_db_config (%s line %d): " + "missing { yes | no }" + "in \"check_schema\" directive\n", + fname, lineno, 0 ); + return 1; + } + + if ( strcasecmp( argv[ 1 ], "yes" ) == 0 ) { + bi->sql_flags |= BSQLF_CHECK_SCHEMA; + + } else if ( strcasecmp( argv[ 1 ], "no" ) == 0 ) { + bi->sql_flags &= ~BSQLF_CHECK_SCHEMA; + + } else { + Debug( LDAP_DEBUG_TRACE, + "<==backsql_db_config (%s line %d): " + "\"check_schema\" directive arg " + "must be \"yes\" or \"no\"\n", + fname, lineno, 0 ); + return 1; + + } + Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): " + "check_schema=%s\n", + BACKSQL_CHECK_SCHEMA( bi ) ? "yes" : "no", + 0, 0 ); + } else { return SLAP_CONF_UNKNOWN; } diff --git a/servers/slapd/back-sql/entry-id.c b/servers/slapd/back-sql/entry-id.c index 071be1e47a..d02857553b 100644 --- a/servers/slapd/back-sql/entry-id.c +++ b/servers/slapd/back-sql/entry-id.c @@ -934,40 +934,41 @@ next:; } } - if ( global_schemacheck ) { - const char *text = NULL; - char textbuf[ 1024 ]; - size_t textlen = sizeof( textbuf ); + if ( ( bsi->bsi_flags & BSQL_SF_ALL_OPER ) + || an_find( bsi->bsi_attrs, &AllOper ) + || an_find( bsi->bsi_attrs, &slap_schema.si_ad_structuralObjectClass->ad_cname ) ) + { struct berval bv[ 2 ]; - struct berval soc; - int rc; bv[ 0 ] = bsi->bsi_oc->bom_oc->soc_cname; BER_BVZERO( &bv[ 1 ] ); - rc = structural_class( bv, &soc, NULL, - &text, textbuf, textlen ); - if ( rc != LDAP_SUCCESS ) { - Debug( LDAP_DEBUG_TRACE, "backsql_id2entry(%s): " - "structural_class() failed %d (%s)\n", - bsi->bsi_e->e_name.bv_val, - rc, text ? text : "" ); - entry_clean( bsi->bsi_e ); - return rc; - } + if ( BACKSQL_CHECK_SCHEMA( bi ) ) { + const char *text = NULL; + char textbuf[ 1024 ]; + size_t textlen = sizeof( textbuf ); + struct berval soc; + int rc; - if ( ( bsi->bsi_flags & BSQL_SF_ALL_OPER ) - || an_find( bsi->bsi_attrs, &AllOper ) - || an_find( bsi->bsi_attrs, &slap_schema.si_ad_structuralObjectClass->ad_cname ) ) - { - rc = attr_merge_normalize_one( bsi->bsi_e, - slap_schema.si_ad_structuralObjectClass, - &soc, bsi->bsi_op->o_tmpmemctx ); + rc = structural_class( bv, &soc, NULL, + &text, textbuf, textlen ); if ( rc != LDAP_SUCCESS ) { + Debug( LDAP_DEBUG_TRACE, "backsql_id2entry(%s): " + "structural_class() failed %d (%s)\n", + bsi->bsi_e->e_name.bv_val, + rc, text ? text : "" ); 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 ); + if ( rc != LDAP_SUCCESS ) { + entry_clean( bsi->bsi_e ); + return rc; + } } done:; diff --git a/servers/slapd/back-sql/init.c b/servers/slapd/back-sql/init.c index 4a236a1718..a6e6d292e3 100644 --- a/servers/slapd/back-sql/init.c +++ b/servers/slapd/back-sql/init.c @@ -474,6 +474,7 @@ backsql_db_open( /* enable if only one suffix is defined */ bi->sql_flags |= BSQLF_USE_SUBTREE_SHORTCUT; } + bi->sql_flags |= BSQLF_CHECK_SCHEMA; Debug( LDAP_DEBUG_TRACE, "<==backsql_db_open(): " "test succeeded, schema map loaded\n", 0, 0, 0 ); diff --git a/servers/slapd/back-sql/modify.c b/servers/slapd/back-sql/modify.c index 8f5be4fc39..b75697a2d8 100644 --- a/servers/slapd/back-sql/modify.c +++ b/servers/slapd/back-sql/modify.c @@ -155,7 +155,7 @@ backsql_modify( Operation *op, SlapReply *rs ) goto do_transact; } - if ( global_schemacheck ) { + if ( BACKSQL_CHECK_SCHEMA( bi ) ) { char textbuf[ SLAP_TEXT_BUFLEN ] = { '\0' }; entry_clean( &m ); diff --git a/servers/slapd/back-sql/modrdn.c b/servers/slapd/back-sql/modrdn.c index 55acd62d2d..7c6c36baea 100644 --- a/servers/slapd/back-sql/modrdn.c +++ b/servers/slapd/back-sql/modrdn.c @@ -446,7 +446,7 @@ backsql_modrdn( Operation *op, SlapReply *rs ) goto done; } - if ( global_schemacheck ) { + if ( BACKSQL_CHECK_SCHEMA( bi ) ) { char textbuf[ SLAP_TEXT_BUFLEN ] = { '\0' }; entry_clean( &r );