remove global_schemacheck

This commit is contained in:
Pierangelo Masarati 2005-05-12 00:03:50 +00:00
parent bb49be254a
commit 740835dff9
7 changed files with 61 additions and 26 deletions

View File

@ -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,

View File

@ -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

View File

@ -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;
}

View File

@ -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:;

View File

@ -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 );

View File

@ -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 );

View File

@ -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 );