]> git.sur5r.net Git - openldap/commitdiff
Rework error handling. Add error descriptions.
authorKurt Zeilenga <kurt@openldap.org>
Fri, 3 Mar 2000 22:37:06 +0000 (22:37 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Fri, 3 Mar 2000 22:37:06 +0000 (22:37 +0000)
Don't use LDAP_OPERATIONS_ERROR for internal errors.  Use LDAP_OTHER
instead.  (more changes needed in this area)

14 files changed:
servers/slapd/add.c
servers/slapd/back-ldbm/modify.c
servers/slapd/back-ldbm/modrdn.c
servers/slapd/back-ldbm/passwd.c
servers/slapd/backend.c
servers/slapd/bind.c
servers/slapd/compare.c
servers/slapd/delete.c
servers/slapd/modify.c
servers/slapd/modrdn.c
servers/slapd/proto-slap.h
servers/slapd/result.c
servers/slapd/schema.c
servers/slapd/search.c

index 3b20cde293553700fd9554145957ff9eb847f6d8..ed710f0afaee49e9b17270b7ecc10b44324d9451 100644 (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;
                                }
                        }
index b504462893373e4c91d2b8cf2391d5aee42ffa2f..54c71a8d76d5b8a9d07d69ac0fa25aa0d46556d7 100644 (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;
        }
index 7c58eb0baf46cd41c478d6a5f9bda82b70eab688..0d8a3114a42dfb70e36ad214f2a65dc149ac6f06 100644 (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;
        }
index 7ba0f5d9becac3dfbf99422a382c9e197c358798..bafe00d6af79aae162cc9ca782d7172df88da1be 100644 (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;
                }
index 353a025f167550dbf78765271dbd5332286a34cd..1ad03e506d7691d54f3a320d506eea3e44690d2a 100644 (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;
                }
        }
index 7f725d6df2848d92ec012e02bc1029d84b3cecf7..364f80320129984e3bad4fdc5be0be6f95e14228 100644 (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;
        }
 
index ae6d4e6ea26442cc169f559f11db6f9519293d35..1fbd5d3e38c1a465412d52ece078cdbb8581da36 100644 (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;
        }
 
index b63367214ad1726b40b62f433669ede3ea01dcc3..79582c33001ee9c44b60919ea7361b052305073a 100644 (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;
        }
 
index 7f953276a14ef9b9d854670e72dd21382ce70ddb..9c849cdcaed02dfab179509148ede23c8030b4f3 100644 (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;
        }
 
index c6fd2ae6cf056de0cbd23a66c9cb729394aa12e6..673af6881e0e7a48e3559d18f1fee4a91948fbd1 100644 (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;
                }
index 0ade752f5b63c8cea1fd79d52427c1cc05838d74..d18feb867aaa8cd876a0d097c522314d8f4aabf4 100644 (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));
index 6ea2c94fd64b91f15f69762642fdcab9be05c259..cbd50098a9f3ef10d78ea799c12021a959ad4800 100644 (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;
        }
 
index 3318ee1aa9a829a322eca67a1180d003e5e0c9aa..351e6cb2f239e6a4184f9a460553dbff803a6197 100644 (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;
        }
        
index 41784771d1b5fb82c5d904f97e1b4e2efc976f55..590817048ced918020c760911d24a53c4030588c 100644 (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;
        }