Rework error handling. Add error descriptions.

Don't use LDAP_OPERATIONS_ERROR for internal errors.  Use LDAP_OTHER
instead.  (more changes needed in this area)
This commit is contained in:
Kurt Zeilenga 2000-03-03 22:37:06 +00:00
parent 58987407fe
commit 4710c74605
14 changed files with 56 additions and 50 deletions

View File

@ -48,8 +48,8 @@ do_add( Connection *conn, Operation *op )
LDAPModList *modlist = NULL;
LDAPModList **modtail = &modlist;
Modifications *mods = NULL;
char *text;
#endif
char *text;
int rc = LDAP_SUCCESS;
Debug( LDAP_DEBUG_TRACE, "do_add\n", 0, 0, 0 );
@ -181,11 +181,11 @@ do_add( Connection *conn, Operation *op )
}
/* make sure this backend recongizes critical controls */
rc = backend_check_controls( be, conn, op ) ;
rc = backend_check_controls( be, conn, op, &text ) ;
if( rc != LDAP_SUCCESS ) {
send_ldap_result( conn, op, rc,
NULL, NULL, NULL, NULL );
NULL, text, NULL, NULL );
goto done;
}
@ -238,8 +238,7 @@ do_add( Connection *conn, Operation *op )
#endif
if( rc != LDAP_SUCCESS ) {
send_ldap_result( conn, op, rc,
NULL, text,
NULL, NULL );
NULL, text, NULL, NULL );
goto done;
}
}

View File

@ -159,7 +159,7 @@ int ldbm_modify_internal(
/* modify indexes */
if ( index_add_mods( be, modlist, e->e_id ) != 0 ) {
/* our indices are likely hosed */
return LDAP_OPERATIONS_ERROR;
return LDAP_OTHER;
}
return LDAP_SUCCESS;
@ -241,7 +241,7 @@ ldbm_back_modify(
/* change the entry itself */
if ( id2entry_add( be, e ) != 0 ) {
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
send_ldap_result( conn, op, LDAP_OTHER,
NULL, NULL, NULL, NULL );
goto error_return;
}

View File

@ -143,7 +143,7 @@ ldbm_back_modrdn(
if( (p = dn2entry_w( be, p_ndn, NULL )) == NULL) {
Debug( LDAP_DEBUG_TRACE, "parent does not exist\n",
0, 0, 0);
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
send_ldap_result( conn, op, LDAP_OTHER,
NULL, NULL, NULL, NULL );
goto return_results;
}
@ -206,7 +206,7 @@ ldbm_back_modrdn(
Debug( LDAP_DEBUG_TRACE,
"ldbm_back_modrdn: newSup(ndn=%s) not here!\n",
np_ndn, 0, 0);
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
send_ldap_result( conn, op, LDAP_OTHER,
NULL, NULL, NULL, NULL );
goto return_results;
}
@ -422,7 +422,7 @@ ldbm_back_modrdn(
/* delete old one */
if ( dn2id_delete( be, e->e_ndn, e->e_id ) != 0 ) {
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
send_ldap_result( conn, op, LDAP_OTHER,
NULL, NULL, NULL, NULL );
goto return_results;
}
@ -440,7 +440,7 @@ ldbm_back_modrdn(
/* add new one */
if ( dn2id_add( be, e->e_ndn, e->e_id ) != 0 ) {
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
send_ldap_result( conn, op, LDAP_OTHER,
NULL, NULL, NULL, NULL );
goto return_results;
}
@ -466,7 +466,7 @@ ldbm_back_modrdn(
/* id2entry index */
if ( id2entry_add( be, e ) != 0 ) {
entry_free( e );
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
send_ldap_result( conn, op, LDAP_OTHER,
NULL, NULL, NULL, NULL );
goto return_results;
}

View File

@ -63,7 +63,7 @@ ldbm_back_exop_passwd(
new = slap_passwd_generate();
if( new == NULL || new->bv_len == 0 ) {
*text = ch_strdup("password generation failed.");
*text = "password generation failed.";
rc = LDAP_OPERATIONS_ERROR;
goto done;
}

View File

@ -592,7 +592,8 @@ int
backend_check_controls(
Backend *be,
Connection *conn,
Operation *op )
Operation *op,
char **text )
{
LDAPControl **ctrls;
ctrls = op->o_ctrls;
@ -604,6 +605,7 @@ backend_check_controls(
if( (*ctrls)->ldctl_iscritical &&
!charray_inlist( be->be_controls, (*ctrls)->ldctl_oid ) )
{
*text = "control unavailable in NamingContext";
return LDAP_UNAVAILABLE_CRITICAL_EXTENSION;
}
}

View File

@ -41,6 +41,7 @@ do_bind(
char *ndn;
ber_tag_t tag;
int rc = LDAP_SUCCESS;
char *text;
struct berval cred;
Backend *be;
@ -285,11 +286,11 @@ do_bind(
conn->c_authz_backend = be;
/* make sure this backend recongizes critical controls */
rc = backend_check_controls( be, conn, op ) ;
rc = backend_check_controls( be, conn, op, &text ) ;
if( rc != LDAP_SUCCESS ) {
send_ldap_result( conn, op, rc,
NULL, NULL, NULL, NULL );
NULL, text, NULL, NULL );
goto cleanup;
}

View File

@ -43,6 +43,7 @@ do_compare(
#else
Ava ava;
#endif
char *text;
desc.bv_val = NULL;
value.bv_val = NULL;
@ -140,11 +141,11 @@ do_compare(
}
/* make sure this backend recongizes critical controls */
rc = backend_check_controls( be, conn, op ) ;
rc = backend_check_controls( be, conn, op, &text ) ;
if( rc != LDAP_SUCCESS ) {
send_ldap_result( conn, op, rc,
NULL, NULL, NULL, NULL );
NULL, text, NULL, NULL );
goto cleanup;
}

View File

@ -31,7 +31,7 @@ do_delete(
Operation *op
)
{
char *dn, *ndn;
char *dn, *ndn, *text;
Backend *be;
int rc;
@ -79,11 +79,11 @@ do_delete(
}
/* make sure this backend recongizes critical controls */
rc = backend_check_controls( be, conn, op ) ;
rc = backend_check_controls( be, conn, op, &text ) ;
if( rc != LDAP_SUCCESS ) {
send_ldap_result( conn, op, rc,
NULL, NULL, NULL, NULL );
NULL, text, NULL, NULL );
goto cleanup;
}

View File

@ -49,6 +49,7 @@ do_modify(
Modifications *mods = NULL;
Backend *be;
int rc;
char *text;
Debug( LDAP_DEBUG_TRACE, "do_modify\n", 0, 0, 0 );
@ -180,11 +181,11 @@ do_modify(
}
/* make sure this backend recongizes critical controls */
rc = backend_check_controls( be, conn, op ) ;
rc = backend_check_controls( be, conn, op, &text ) ;
if( rc != LDAP_SUCCESS ) {
send_ldap_result( conn, op, rc,
NULL, NULL, NULL, NULL );
NULL, text, NULL, NULL );
goto cleanup;
}

View File

@ -53,6 +53,7 @@ do_modrdn(
Backend *newSuperior_be = NULL;
ber_len_t length;
int rc;
char *text;
Debug( LDAP_DEBUG_TRACE, "do_modrdn\n", 0, 0, 0 );
@ -108,7 +109,7 @@ do_modrdn(
Debug( LDAP_DEBUG_ANY, "do_modrdn: invalid new superior (%s)\n",
newSuperior, 0, 0 );
send_ldap_result( conn, op, rc = LDAP_INVALID_DN_SYNTAX, NULL,
"invalid (new superior) DN", NULL, NULL );
"new superior invalid", NULL, NULL );
goto cleanup;
}
@ -165,11 +166,11 @@ do_modrdn(
}
/* make sure this backend recongizes critical controls */
rc = backend_check_controls( be, conn, op ) ;
rc = backend_check_controls( be, conn, op, &text ) ;
if( rc != LDAP_SUCCESS ) {
send_ldap_result( conn, op, rc,
NULL, NULL, NULL, NULL );
NULL, text, NULL, NULL );
goto cleanup;
}
@ -192,7 +193,7 @@ do_modrdn(
rc = LDAP_AFFECTS_MULTIPLE_DSAS;
send_ldap_result( conn, op, rc,
NULL, NULL, NULL, NULL );
NULL, "cannot rename between DSAa", NULL, NULL );
goto cleanup;
}

View File

@ -175,7 +175,8 @@ LIBSLAPD_F (int) backend_unbind LDAP_P((Connection *conn, Operation *op));
LIBSLAPD_F( int ) backend_check_controls LDAP_P((
Backend *be,
Connection *conn,
Operation *op ));
Operation *op,
char **text ));
LIBSLAPD_F (int) backend_connection_init LDAP_P((Connection *conn));
LIBSLAPD_F (int) backend_connection_destroy LDAP_P((Connection *conn));

View File

@ -650,8 +650,8 @@ send_search_entry(
if ( ber == NULL ) {
Debug( LDAP_DEBUG_ANY, "ber_alloc failed\n", 0, 0, 0 );
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
NULL, "allocating BER error", NULL, NULL );
send_ldap_result( conn, op, LDAP_OTHER,
NULL, "BER allocation error", NULL, NULL );
goto error_return;
}
@ -661,8 +661,8 @@ send_search_entry(
if ( rc == -1 ) {
Debug( LDAP_DEBUG_ANY, "ber_printf failed\n", 0, 0, 0 );
ber_free( ber, 1 );
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
NULL, "encoding dn error", NULL, NULL );
send_ldap_result( conn, op, LDAP_OTHER,
NULL, "encoding DN error", NULL, NULL );
goto error_return;
}
@ -719,8 +719,8 @@ send_search_entry(
if (( rc = ber_printf( ber, "{s[" /*]}*/ , desc )) == -1 ) {
Debug( LDAP_DEBUG_ANY, "ber_printf failed\n", 0, 0, 0 );
ber_free( ber, 1 );
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
NULL, "encoding type error", NULL, NULL );
send_ldap_result( conn, op, LDAP_OTHER,
NULL, "encoding description error", NULL, NULL );
goto error_return;
}
@ -739,8 +739,8 @@ send_search_entry(
Debug( LDAP_DEBUG_ANY,
"ber_printf failed\n", 0, 0, 0 );
ber_free( ber, 1 );
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
NULL, "encoding value error", NULL, NULL );
send_ldap_result( conn, op, LDAP_OTHER,
NULL, "encoding values error", NULL, NULL );
goto error_return;
}
}
@ -749,7 +749,7 @@ send_search_entry(
if (( rc = ber_printf( ber, /*{[*/ "]}" )) == -1 ) {
Debug( LDAP_DEBUG_ANY, "ber_printf failed\n", 0, 0, 0 );
ber_free( ber, 1 );
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
send_ldap_result( conn, op, LDAP_OTHER,
NULL, "encode end error", NULL, NULL );
goto error_return;
}
@ -806,8 +806,8 @@ send_search_entry(
if (( rc = ber_printf( ber, "{s[" /*]}*/ , desc )) == -1 ) {
Debug( LDAP_DEBUG_ANY, "ber_printf failed\n", 0, 0, 0 );
ber_free( ber, 1 );
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
NULL, "encoding type error", NULL, NULL );
send_ldap_result( conn, op, LDAP_OTHER,
NULL, "encoding description error", NULL, NULL );
goto error_return;
}
@ -827,8 +827,8 @@ send_search_entry(
Debug( LDAP_DEBUG_ANY,
"ber_printf failed\n", 0, 0, 0 );
ber_free( ber, 1 );
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
NULL, "encoding value error", NULL, NULL );
send_ldap_result( conn, op, LDAP_OTHER,
NULL, "encoding values error", NULL, NULL );
goto error_return;
}
}
@ -837,7 +837,7 @@ send_search_entry(
if (( rc = ber_printf( ber, /*{[*/ "]}" )) == -1 ) {
Debug( LDAP_DEBUG_ANY, "ber_printf failed\n", 0, 0, 0 );
ber_free( ber, 1 );
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
send_ldap_result( conn, op, LDAP_OTHER,
NULL, "encode end error", NULL, NULL );
goto error_return;
}
@ -850,7 +850,7 @@ send_search_entry(
if ( rc == -1 ) {
Debug( LDAP_DEBUG_ANY, "ber_printf failed\n", 0, 0, 0 );
ber_free( ber, 1 );
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
send_ldap_result( conn, op, LDAP_OTHER,
NULL, "encode entry end error", NULL, NULL );
return( 1 );
}
@ -946,7 +946,7 @@ send_search_reference(
if ( ber == NULL ) {
Debug( LDAP_DEBUG_ANY,
"send_search_reference: ber_alloc failed\n", 0, 0, 0 );
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
send_ldap_result( conn, op, LDAP_OTHER,
NULL, "alloc BER error", NULL, NULL );
return -1;
}
@ -958,8 +958,8 @@ send_search_reference(
Debug( LDAP_DEBUG_ANY,
"send_search_reference: ber_printf failed\n", 0, 0, 0 );
ber_free( ber, 1 );
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
NULL, "encode dn error", NULL, NULL );
send_ldap_result( conn, op, LDAP_OTHER,
NULL, "encode DN error", NULL, NULL );
return -1;
}

View File

@ -58,8 +58,8 @@ schema_info( Connection *conn, Operation *op, char **attrs, int attrsonly )
{
/* Out of memory, do something about it */
entry_free( e );
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
NULL, NULL, NULL, NULL );
send_ldap_result( conn, op, LDAP_OTHER,
NULL, "out of memory", NULL, NULL );
return;
}

View File

@ -200,11 +200,11 @@ do_search(
}
/* make sure this backend recongizes critical controls */
rc = backend_check_controls( be, conn, op ) ;
rc = backend_check_controls( be, conn, op, &text ) ;
if( rc != LDAP_SUCCESS ) {
send_ldap_result( conn, op, rc,
NULL, NULL, NULL, NULL );
NULL, text, NULL, NULL );
goto return_results;
}