From 3bad06d52b8b0272f9baf1f5a304568bd3a03611 Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Tue, 25 Apr 2000 13:07:14 +0000 Subject: [PATCH] entry_schema_check() rename --- servers/slapd/back-ldbm/add.c | 36 +++++++++++++++++--------------- servers/slapd/back-ldbm/modify.c | 13 +++++++----- servers/slapd/tools/slapadd.c | 7 ++++--- 3 files changed, 31 insertions(+), 25 deletions(-) diff --git a/servers/slapd/back-ldbm/add.c b/servers/slapd/back-ldbm/add.c index 44c70c63cf..8623e25040 100644 --- a/servers/slapd/back-ldbm/add.c +++ b/servers/slapd/back-ldbm/add.c @@ -29,7 +29,7 @@ ldbm_back_add( Entry *p = NULL; int rootlock = 0; int rc; - + char *text; #ifdef SLAPD_SCHEMA_NOT_COMPAT static AttributeDescription *children = NULL; #else @@ -50,15 +50,17 @@ ldbm_back_add( return( -1 ); } - if ( schema_check_entry( e ) != 0 ) { + rc = entry_schema_check( e, NULL, &text ); + + if ( rc != LDAP_SUCCESS ) { ldap_pvt_thread_mutex_unlock(&li->li_add_mutex); - Debug( LDAP_DEBUG_TRACE, "entry failed schema check\n", - 0, 0, 0 ); + Debug( LDAP_DEBUG_TRACE, "entry failed schema check: %s\n", + text, 0, 0 ); entry_free( e ); - send_ldap_result( conn, op, LDAP_OBJECT_CLASS_VIOLATION, - NULL, NULL, NULL, NULL ); + send_ldap_result( conn, op, rc, + NULL, text, NULL, NULL ); return( -1 ); } @@ -121,10 +123,10 @@ ldbm_back_add( /* free parent and writer lock */ cache_return_entry_w( &li->li_cache, p ); - Debug( LDAP_DEBUG_TRACE, "no access to parent\n", 0, + Debug( LDAP_DEBUG_TRACE, "no write access to parent\n", 0, 0, 0 ); send_ldap_result( conn, op, LDAP_INSUFFICIENT_ACCESS, - NULL, NULL, NULL, NULL ); + NULL, "no write access to parent", NULL, NULL ); entry_free( e ); @@ -141,7 +143,7 @@ ldbm_back_add( 0, 0 ); send_ldap_result( conn, op, LDAP_ALIAS_PROBLEM, - NULL, NULL, NULL, NULL ); + NULL, "parent is an alias", NULL, NULL ); entry_free( e ); return -1; @@ -223,8 +225,8 @@ ldbm_back_add( entry_free( e ); send_ldap_result( conn, op, - rc > 0 ? LDAP_ALREADY_EXISTS : LDAP_OPERATIONS_ERROR, - NULL, NULL, NULL, NULL ); + rc > 0 ? LDAP_ALREADY_EXISTS : LDAP_OTHER, + NULL, rc > 0 ? NULL : "cache add failed", NULL, NULL ); return( -1 ); } @@ -240,8 +242,8 @@ ldbm_back_add( if ( index_add_entry( be, e ) != 0 ) { Debug( LDAP_DEBUG_TRACE, "index_add_entry failed\n", 0, 0, 0 ); - send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, - NULL, NULL, NULL, NULL ); + send_ldap_result( conn, op, LDAP_OTHER, + NULL, "index generation failed", NULL, NULL ); goto return_results; } @@ -250,8 +252,8 @@ ldbm_back_add( if ( dn2id_add( be, e->e_ndn, e->e_id ) != 0 ) { Debug( LDAP_DEBUG_TRACE, "dn2id_add failed\n", 0, 0, 0 ); - send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, - NULL, NULL, NULL, NULL ); + send_ldap_result( conn, op, LDAP_OTHER, + NULL, "DN index generation failed", NULL, NULL ); goto return_results; } @@ -261,8 +263,8 @@ ldbm_back_add( Debug( LDAP_DEBUG_TRACE, "id2entry_add failed\n", 0, 0, 0 ); (void) dn2id_delete( be, e->e_ndn, e->e_id ); - send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, - NULL, NULL, NULL, NULL ); + send_ldap_result( conn, op, LDAP_OTHER, + NULL, "entry store failed", NULL, NULL ); goto return_results; } diff --git a/servers/slapd/back-ldbm/modify.c b/servers/slapd/back-ldbm/modify.c index adce8f5b15..c98662ee7b 100644 --- a/servers/slapd/back-ldbm/modify.c +++ b/servers/slapd/back-ldbm/modify.c @@ -36,7 +36,8 @@ int ldbm_modify_internal( Entry *e ) { - int err; + int rc, err; + char *text; Modification *mod; Modifications *ml; Attribute *save_attrs; @@ -105,11 +106,13 @@ int ldbm_modify_internal( ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex ); /* check that the entry still obeys the schema */ - if ( schema_check_entry( e ) != 0 ) { + rc = entry_schema_check( e, save_attrs, &text ); + if ( rc != LDAP_SUCCESS ) { attrs_free( e->e_attrs ); e->e_attrs = save_attrs; - Debug( LDAP_DEBUG_ANY, "entry failed schema check\n", 0, 0, 0 ); - return LDAP_OBJECT_CLASS_VIOLATION; + Debug( LDAP_DEBUG_ANY, "entry failed schema check: %s\n", + text, 0, 0 ); + return rc; } /* check for abandon */ @@ -397,7 +400,7 @@ delete_values( Debug( LDAP_DEBUG_ARGS, "could not find value for attr %s\n", mod->mod_type, 0, 0 ); - return( LDAP_NO_SUCH_ATTRIBUTE ); + return LDAP_NO_SUCH_ATTRIBUTE; } } #endif diff --git a/servers/slapd/tools/slapadd.c b/servers/slapd/tools/slapadd.c index fb4694985d..f92d98c366 100644 --- a/servers/slapd/tools/slapadd.c +++ b/servers/slapd/tools/slapadd.c @@ -69,9 +69,10 @@ main( int argc, char **argv ) if( !noschemacheck ) { /* check schema */ - if ( schema_check_entry( e ) != 0 ) { - fprintf( stderr, "%s: schema violation in entry dn=\"%s\" (line=%d)\n", - progname, e->e_dn, lineno ); + char *text; + if ( entry_schema_check( e, NULL, &text ) != LDAP_SUCCESS ) { + fprintf( stderr, "%s: dn=\"%s\" (line=%d): %s\n", + progname, e->e_dn, lineno, text ); rc = EXIT_FAILURE; entry_free( e ); if( continuemode ) continue; -- 2.39.5