From: Kurt Zeilenga Date: Sun, 28 May 2000 20:44:08 +0000 (+0000) Subject: modify ldbm_modify_internal to return error text X-Git-Tag: LDBM_PRE_GIANT_RWLOCK~2822 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=4d835c05326cf9a0b1db8a938df64a551ef03ee5;p=openldap modify ldbm_modify_internal to return error text --- diff --git a/servers/slapd/attr.c b/servers/slapd/attr.c index 481d1c7adf..685d97bc9e 100644 --- a/servers/slapd/attr.c +++ b/servers/slapd/attr.c @@ -278,7 +278,6 @@ attr_delete( ) { Attribute **a; - Attribute *save; for ( a = attrs; *a != NULL; a = &(*a)->a_next ) { #ifdef SLAPD_SCHEMA_NOT_COMPAT @@ -287,18 +286,14 @@ attr_delete( if ( strcasecmp( (*a)->a_type, type ) == 0 ) #endif { - break; - } - } + Attribute *save = *a; + *a = (*a)->a_next; + attr_free( save ); - if ( *a == NULL ) { - return( 1 ); + return 0; + } } - save = *a; - *a = (*a)->a_next; - attr_free( save ); - - return( 0 ); + return 1; } diff --git a/servers/slapd/back-ldbm/modify.c b/servers/slapd/back-ldbm/modify.c index 552fae0880..fadc60fd12 100644 --- a/servers/slapd/back-ldbm/modify.c +++ b/servers/slapd/back-ldbm/modify.c @@ -33,11 +33,11 @@ int ldbm_modify_internal( Operation *op, const char *dn, Modifications *modlist, - Entry *e + Entry *e, + const char **text ) { int rc, err; - const char *text; Modification *mod; Modifications *ml; Attribute *save_attrs; @@ -55,14 +55,26 @@ int ldbm_modify_internal( switch ( mod->sm_op ) { case LDAP_MOD_ADD: err = add_values( e, mod, op->o_ndn ); + + if( err != LDAP_SUCCESS ) { + *text = "modify: add values failed"; + } break; case LDAP_MOD_DELETE: err = delete_values( e, mod, op->o_ndn ); + assert( err != LDAP_TYPE_OR_VALUE_EXISTS ); + if( err != LDAP_SUCCESS ) { + *text = "modify: delete values failed"; + } break; case LDAP_MOD_REPLACE: err = replace_values( e, mod, op->o_ndn ); + assert( err != LDAP_TYPE_OR_VALUE_EXISTS ); + if( err != LDAP_SUCCESS ) { + *text = "modify: replace values failed"; + } break; case SLAP_MOD_SOFTADD: @@ -75,7 +87,14 @@ int ldbm_modify_internal( if ( err == LDAP_TYPE_OR_VALUE_EXISTS ) { err = LDAP_SUCCESS; } + + if( err != LDAP_SUCCESS ) { + *text = "modify: (soft)add values failed"; + } break; + + default: + err = LDAP_OTHER; } if ( err != LDAP_SUCCESS ) { @@ -97,12 +116,12 @@ int ldbm_modify_internal( ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex ); /* check that the entry still obeys the schema */ - rc = entry_schema_check( e, save_attrs, &text ); + 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: %s\n", - text, 0, 0 ); + *text, 0, 0 ); return rc; } @@ -215,6 +234,7 @@ ldbm_back_modify( Entry *matched; Entry *e; int manageDSAit = get_manageDSAit( op ); + const char *text; Debug(LDAP_DEBUG_ARGS, "ldbm_back_modify:\n", 0, 0, 0); @@ -262,12 +282,12 @@ ldbm_back_modify( } /* Modify the entry */ - rc = ldbm_modify_internal( be, conn, op, ndn, modlist, e ); + rc = ldbm_modify_internal( be, conn, op, ndn, modlist, e, &text ); if( rc != LDAP_SUCCESS ) { if( rc != SLAPD_ABANDON ) { send_ldap_result( conn, op, rc, - NULL, NULL, NULL, NULL ); + NULL, text, NULL, NULL ); } goto error_return; diff --git a/servers/slapd/back-ldbm/modrdn.c b/servers/slapd/back-ldbm/modrdn.c index eeeea36b0e..40a33545d4 100644 --- a/servers/slapd/back-ldbm/modrdn.c +++ b/servers/slapd/back-ldbm/modrdn.c @@ -56,6 +56,7 @@ ldbm_back_modrdn( Entry *matched; int rootlock = 0; int rc = -1; + const char *text; /* Added to support LDAP v2 correctly (deleteoldrdn thing) */ char *new_rdn_val = NULL; /* Val of new rdn */ char *new_rdn_type = NULL; /* Type of new rdn */ @@ -359,7 +360,6 @@ ldbm_back_modrdn( #ifdef SLAPD_SCHEMA_NOT_COMPAT { int rc; - const char *text; mod[0].sml_desc = NULL; rc = slap_str2ad( new_rdn_type, &mod[0].sml_desc, &text ); @@ -407,7 +407,6 @@ ldbm_back_modrdn( #ifdef SLAPD_SCHEMA_NOT_COMPAT { int rc; - const char *text; mod[1].sml_desc = NULL; rc = slap_str2ad( old_rdn_type, &mod[1].sml_desc, &text ); @@ -468,12 +467,12 @@ ldbm_back_modrdn( } /* modify memory copy of entry */ - rc = ldbm_modify_internal( be, conn, op, dn, &mod[0], e ); + rc = ldbm_modify_internal( be, conn, op, dn, &mod[0], e, &text ); if( rc != LDAP_SUCCESS ) { if( rc != SLAPD_ABANDON ) { send_ldap_result( conn, op, rc, - NULL, NULL, NULL, NULL ); + NULL, text, NULL, NULL ); } goto return_results; diff --git a/servers/slapd/back-ldbm/passwd.c b/servers/slapd/back-ldbm/passwd.c index ae427fc76b..da370dad3f 100644 --- a/servers/slapd/back-ldbm/passwd.c +++ b/servers/slapd/back-ldbm/passwd.c @@ -136,7 +136,7 @@ ldbm_back_exop_passwd( ml.sml_next = NULL; rc = ldbm_modify_internal( be, - conn, op, op->o_ndn, &ml, e ); + conn, op, op->o_ndn, &ml, e, text ); #ifndef SLAPD_SCHEMA_NOT_COMPAT ch_free(ml.ml_type); diff --git a/servers/slapd/back-ldbm/proto-back-ldbm.h b/servers/slapd/back-ldbm/proto-back-ldbm.h index 475f45d36e..888aeedb9d 100644 --- a/servers/slapd/back-ldbm/proto-back-ldbm.h +++ b/servers/slapd/back-ldbm/proto-back-ldbm.h @@ -168,7 +168,8 @@ extern int ldbm_back_exop_passwd LDAP_P(( BackendDB *bd, /* returns LDAP error code indicating error OR SLAPD_ABANDON */ int ldbm_modify_internal LDAP_P((Backend *be, Connection *conn, Operation *op, - const char *dn, Modifications *mods, Entry *e )); + const char *dn, Modifications *mods, Entry *e, + const char ** )); #ifdef HAVE_CYRUS_SASL /*