mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-12-24 00:29:35 -05:00
modify ldbm_modify_internal to return error text
This commit is contained in:
parent
7a97873274
commit
4d835c0532
5 changed files with 38 additions and 23 deletions
|
|
@ -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 );
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if ( *a == NULL ) {
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
save = *a;
|
||||
*a = (*a)->a_next;
|
||||
attr_free( save );
|
||||
|
||||
return( 0 );
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
/*
|
||||
|
|
|
|||
Loading…
Reference in a new issue