From: Pierangelo Masarati Date: Sun, 10 Nov 2002 18:16:43 +0000 (+0000) Subject: improve error messages X-Git-Tag: NO_SLAP_OP_BLOCKS~809 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=a9c902a7ca3e46f9437063ccfd98777bd3e93b15;p=openldap improve error messages --- diff --git a/servers/slapd/back-ldap/add.c b/servers/slapd/back-ldap/add.c index db13820427..21ada672c3 100644 --- a/servers/slapd/back-ldap/add.c +++ b/servers/slapd/back-ldap/add.c @@ -95,12 +95,12 @@ ldap_back_add( case REWRITE_REGEXEC_UNWILLING: send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, - NULL, "Unwilling to perform", NULL, NULL ); + NULL, "Operation not allowed", NULL, NULL ); return( -1 ); case REWRITE_REGEXEC_ERR: send_ldap_result( conn, op, LDAP_OTHER, - NULL, "Operations error", NULL, NULL ); + NULL, "Rewrite error", NULL, NULL ); return( -1 ); } #else /* !ENABLE_REWRITE */ @@ -154,12 +154,15 @@ ldap_back_add( #ifdef ENABLE_REWRITE /* * FIXME: dn-valued attrs should be rewritten - * to allow their use in ACLs at the back-ldap - * level. + * to allow their use in ACLs at back-ldap level. */ if ( strcmp( a->a_desc->ad_type->sat_syntax->ssyn_oid, SLAPD_DN_SYNTAX ) == 0 ) { - ldap_dnattr_rewrite( li->rwinfo, a->a_vals, conn ); + /* + * FIXME: rewrite could fail; in this case + * the operation should give up, right? + */ + (void)ldap_dnattr_rewrite( li->rwinfo, a->a_vals, conn ); } #endif /* ENABLE_REWRITE */ diff --git a/servers/slapd/back-ldap/bind.c b/servers/slapd/back-ldap/bind.c index e65ea665a6..501e4d9802 100644 --- a/servers/slapd/back-ldap/bind.c +++ b/servers/slapd/back-ldap/bind.c @@ -102,12 +102,12 @@ ldap_back_bind( case REWRITE_REGEXEC_UNWILLING: send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, - NULL, "Unwilling to perform", NULL, NULL ); + NULL, "Operation not allowed", NULL, NULL ); return( -1 ); case REWRITE_REGEXEC_ERR: send_ldap_result( conn, op, LDAP_OTHER, - NULL, "Operations error", NULL, NULL ); + NULL, "Rewrite error", NULL, NULL ); return( -1 ); } #else /* !ENABLE_REWRITE */ @@ -228,7 +228,7 @@ ldap_back_getconn(struct ldapinfo *li, Connection *conn, Operation *op) if (err != LDAP_SUCCESS) { err = ldap_back_map_result(err); send_ldap_result( conn, op, err, - NULL, "ldap_init failed", NULL, NULL ); + NULL, "ldap_initialize() failed", NULL, NULL ); return( NULL ); } /* Set LDAP version. This will always succeed: If the client @@ -263,7 +263,8 @@ ldap_back_getconn(struct ldapinfo *li, Connection *conn, Operation *op) &lc->bound_dn.bv_val ) ) { case REWRITE_REGEXEC_OK: if ( lc->bound_dn.bv_val == NULL ) { - ber_dupbv( &lc->bound_dn, &lc->conn->c_dn ); + ber_dupbv( &lc->bound_dn, + &lc->conn->c_dn ); } #ifdef NEW_LOGGING LDAP_LOG( BACK_LDAP, DETAIL1, @@ -283,25 +284,28 @@ ldap_back_getconn(struct ldapinfo *li, Connection *conn, Operation *op) case REWRITE_REGEXEC_UNWILLING: send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, - NULL, "Unwilling to perform", + NULL, "Operation not allowed", NULL, NULL ); return( NULL ); case REWRITE_REGEXEC_ERR: send_ldap_result( conn, op, LDAP_OTHER, - NULL, "Operations error", + NULL, "Rewrite error", NULL, NULL ); return( NULL ); } + #else /* !ENABLE_REWRITE */ struct berval bv; ldap_back_dn_massage( li, &lc->conn->c_dn, &bv, 0, 1 ); - if ( bv.bv_val == lc->conn->c_dn.bv_val ) + if ( bv.bv_val == lc->conn->c_dn.bv_val ) { ber_dupbv( &lc->bound_dn, &bv ); - else + } else { lc->bound_dn = bv; + } #endif /* !ENABLE_REWRITE */ + } else { lc->bound_dn.bv_val = NULL; lc->bound_dn.bv_len = 0; diff --git a/servers/slapd/back-ldap/compare.c b/servers/slapd/back-ldap/compare.c index 2b677edb5a..e4c966f9e9 100644 --- a/servers/slapd/back-ldap/compare.c +++ b/servers/slapd/back-ldap/compare.c @@ -85,12 +85,12 @@ ldap_back_compare( case REWRITE_REGEXEC_UNWILLING: send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, - NULL, "Unwilling to perform", NULL, NULL ); + NULL, "Operation not allowed", NULL, NULL ); return( -1 ); case REWRITE_REGEXEC_ERR: send_ldap_result( conn, op, LDAP_OTHER, - NULL, "Operations error", NULL, NULL ); + NULL, "Rewrite error", NULL, NULL ); return( -1 ); } #else /* !ENABLE_REWRITE */ diff --git a/servers/slapd/back-ldap/delete.c b/servers/slapd/back-ldap/delete.c index d545f77b14..3766df2db9 100644 --- a/servers/slapd/back-ldap/delete.c +++ b/servers/slapd/back-ldap/delete.c @@ -85,12 +85,12 @@ ldap_back_delete( case REWRITE_REGEXEC_UNWILLING: send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, - NULL, "Unwilling to perform", NULL, NULL ); + NULL, "Operation not allowed", NULL, NULL ); return( -1 ); case REWRITE_REGEXEC_ERR: send_ldap_result( conn, op, LDAP_OTHER, - NULL, "Operations error", NULL, NULL ); + NULL, "Rewrite error", NULL, NULL ); return( -1 ); } #else /* !ENABLE_REWRITE */ diff --git a/servers/slapd/back-ldap/modify.c b/servers/slapd/back-ldap/modify.c index bb45b385c0..8deeeaa888 100644 --- a/servers/slapd/back-ldap/modify.c +++ b/servers/slapd/back-ldap/modify.c @@ -89,12 +89,12 @@ ldap_back_modify( case REWRITE_REGEXEC_UNWILLING: send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, - NULL, "Unwilling to perform", NULL, NULL ); + NULL, "Operation not allowed", NULL, NULL ); return( -1 ); case REWRITE_REGEXEC_ERR: send_ldap_result( conn, op, LDAP_OTHER, - NULL, "Operations error", NULL, NULL ); + NULL, "Rewrite error", NULL, NULL ); return( -1 ); } #else /* !ENABLE_REWRITE */ diff --git a/servers/slapd/back-ldap/modrdn.c b/servers/slapd/back-ldap/modrdn.c index 8c7eee5869..2eb905c844 100644 --- a/servers/slapd/back-ldap/modrdn.c +++ b/servers/slapd/back-ldap/modrdn.c @@ -96,13 +96,13 @@ ldap_back_modrdn( case REWRITE_REGEXEC_UNWILLING: send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, - NULL, "Unwilling to perform", + NULL, "Operation not allowed", NULL, NULL ); return( -1 ); case REWRITE_REGEXEC_ERR: send_ldap_result( conn, op, LDAP_OTHER, - NULL, "Operations error", + NULL, "Rewrite error", NULL, NULL ); return( -1 ); } @@ -134,12 +134,12 @@ ldap_back_modrdn( case REWRITE_REGEXEC_UNWILLING: send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, - NULL, "Unwilling to perform", NULL, NULL ); + NULL, "Operation not allowed", NULL, NULL ); return( -1 ); case REWRITE_REGEXEC_ERR: send_ldap_result( conn, op, LDAP_OTHER, - NULL, "Operations error", NULL, NULL ); + NULL, "Rewrite error", NULL, NULL ); return( -1 ); } #else /* !ENABLE_REWRITE */ diff --git a/servers/slapd/back-ldap/search.c b/servers/slapd/back-ldap/search.c index 47f211c5da..e2990e81d8 100644 --- a/servers/slapd/back-ldap/search.c +++ b/servers/slapd/back-ldap/search.c @@ -172,13 +172,13 @@ ldap_back_search( case REWRITE_REGEXEC_UNWILLING: send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, - NULL, "Unwilling to perform", NULL, NULL ); + NULL, "Operation not allowed", NULL, NULL ); rc = -1; goto finish; case REWRITE_REGEXEC_ERR: send_ldap_result( conn, op, LDAP_OTHER, - NULL, "Operations error", NULL, NULL ); + NULL, "Rewrite error", NULL, NULL ); rc = -1; goto finish; } @@ -211,8 +211,13 @@ ldap_back_search( case REWRITE_REGEXEC_UNWILLING: send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, - NULL, "Unwilling to perform", NULL, NULL ); + NULL, "Operation not allowed", NULL, NULL ); + rc = -1; + goto finish; + case REWRITE_REGEXEC_ERR: + send_ldap_result( conn, op, LDAP_OTHER, + NULL, "Rewrite error", NULL, NULL ); rc = -1; goto finish; } @@ -251,9 +256,9 @@ ldap_back_search( mapped_attrs[count] = NULL; } - if ((msgid = ldap_search(lc->ld, mbase.bv_val, scope, mapped_filter, mapped_attrs, - attrsonly)) == -1) - { + msgid = ldap_search(lc->ld, mbase.bv_val, scope, mapped_filter, + mapped_attrs, attrsonly); + if ( msgid == -1 ) { fail:; rc = ldap_back_op_result(lc, op); goto finish; @@ -364,19 +369,18 @@ fail:; break; case REWRITE_REGEXEC_UNWILLING: - send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, - NULL, "Unwilling to perform", - NULL, NULL ); case REWRITE_REGEXEC_ERR: - rc = -1; - goto finish; + /* FIXME: no error, but no matched ... */ + mmatch = NULL; + break; } } if ( v2refs ) { sres = LDAP_REFERRAL; } + send_search_result( conn, op, sres, mmatch, err, v2refs, NULL, count ); diff --git a/servers/slapd/back-meta/add.c b/servers/slapd/back-meta/add.c index e0d52e1173..6408654e9d 100644 --- a/servers/slapd/back-meta/add.c +++ b/servers/slapd/back-meta/add.c @@ -131,12 +131,12 @@ meta_back_add( case REWRITE_REGEXEC_UNWILLING: send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, - NULL, NULL, NULL, NULL ); + NULL, "Operation not allowed", NULL, NULL ); return -1; case REWRITE_REGEXEC_ERR: send_ldap_result( conn, op, LDAP_OTHER, - NULL, NULL, NULL, NULL ); + NULL, "Rewrite error", NULL, NULL ); return -1; } diff --git a/servers/slapd/back-meta/compare.c b/servers/slapd/back-meta/compare.c index 71475fdc39..75a4c868e4 100644 --- a/servers/slapd/back-meta/compare.c +++ b/servers/slapd/back-meta/compare.c @@ -138,7 +138,7 @@ meta_back_compare( case REWRITE_REGEXEC_UNWILLING: send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, - NULL, "Unwilling to perform", + NULL, "Operation not allowed", NULL, NULL ); return -1; @@ -324,7 +324,7 @@ finish:; case REWRITE_REGEXEC_UNWILLING: send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, - NULL, "Unwilling to perform", + NULL, "Operation not allowed", NULL, NULL ); rc = -1; goto cleanup; diff --git a/servers/slapd/back-meta/conn.c b/servers/slapd/back-meta/conn.c index 249555836e..e9deeb0051 100644 --- a/servers/slapd/back-meta/conn.c +++ b/servers/slapd/back-meta/conn.c @@ -286,7 +286,7 @@ init_one_conn( case REWRITE_REGEXEC_UNWILLING: send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, - NULL, "Unwilling to perform", + NULL, "Operation not allowed", NULL, NULL ); return LDAP_UNWILLING_TO_PERFORM; diff --git a/servers/slapd/back-meta/delete.c b/servers/slapd/back-meta/delete.c index daeada0ad3..4909e73a62 100644 --- a/servers/slapd/back-meta/delete.c +++ b/servers/slapd/back-meta/delete.c @@ -118,12 +118,12 @@ meta_back_delete( case REWRITE_REGEXEC_UNWILLING: send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, - NULL, NULL, NULL, NULL ); + NULL, "Operation not allowed", NULL, NULL ); return -1; case REWRITE_REGEXEC_ERR: send_ldap_result( conn, op, LDAP_OTHER, - NULL, NULL, NULL, NULL ); + NULL, "Rewrite error", NULL, NULL ); return -1; } diff --git a/servers/slapd/back-meta/modify.c b/servers/slapd/back-meta/modify.c index 7b3208bc53..57dc40f90b 100644 --- a/servers/slapd/back-meta/modify.c +++ b/servers/slapd/back-meta/modify.c @@ -122,12 +122,12 @@ meta_back_modify( case REWRITE_REGEXEC_UNWILLING: send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, - NULL, NULL, NULL, NULL ); + NULL, "Operation not allowed", NULL, NULL ); return -1; case REWRITE_REGEXEC_ERR: send_ldap_result( conn, op, LDAP_OTHER, - NULL, NULL, NULL, NULL ); + NULL, "Rewrite error", NULL, NULL ); return -1; } diff --git a/servers/slapd/back-meta/modrdn.c b/servers/slapd/back-meta/modrdn.c index c0f6d1437f..336001bdd2 100644 --- a/servers/slapd/back-meta/modrdn.c +++ b/servers/slapd/back-meta/modrdn.c @@ -155,12 +155,13 @@ meta_back_modrdn( case REWRITE_REGEXEC_UNWILLING: send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, - NULL, NULL, NULL, NULL ); + NULL, "Operation not allowed", + NULL, NULL ); return -1; case REWRITE_REGEXEC_ERR: send_ldap_result( conn, op, LDAP_OTHER, - NULL, NULL, NULL, NULL ); + NULL, "Rewrite error", NULL, NULL ); return -1; } } @@ -185,12 +186,12 @@ meta_back_modrdn( case REWRITE_REGEXEC_UNWILLING: send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, - NULL, NULL, NULL, NULL ); + NULL, "Operation not allowed", NULL, NULL ); return -1; case REWRITE_REGEXEC_ERR: send_ldap_result( conn, op, LDAP_OTHER, - NULL, NULL, NULL, NULL ); + NULL, "Rewrite error", NULL, NULL ); return -1; } diff --git a/servers/slapd/back-meta/search.c b/servers/slapd/back-meta/search.c index 0f6bce2dc7..35b0aae92d 100644 --- a/servers/slapd/back-meta/search.c +++ b/servers/slapd/back-meta/search.c @@ -296,13 +296,14 @@ meta_back_search( case REWRITE_REGEXEC_UNWILLING: send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, - NULL, NULL, NULL, NULL ); + NULL, "Operation not allowed", + NULL, NULL ); rc = -1; goto finish; case REWRITE_REGEXEC_ERR: send_ldap_result( conn, op, LDAP_OTHER, - NULL, NULL, NULL, NULL ); + NULL, "rewrite error", NULL, NULL ); rc = -1; goto finish; } @@ -335,13 +336,14 @@ meta_back_search( case REWRITE_REGEXEC_UNWILLING: send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, - NULL, NULL, NULL, NULL ); + NULL, "Operation not allowed", + NULL, NULL ); rc = -1; goto finish; case REWRITE_REGEXEC_ERR: send_ldap_result( conn, op, LDAP_OTHER, - NULL, NULL, NULL, NULL ); + NULL, "Rewrite error", NULL, NULL ); rc = -1; goto finish; } @@ -601,16 +603,11 @@ meta_back_search( break; case REWRITE_REGEXEC_UNWILLING: - send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, - NULL, NULL, NULL, NULL ); - rc = -1; - goto finish; case REWRITE_REGEXEC_ERR: - send_ldap_result( conn, op, LDAP_OTHER, - NULL, NULL, NULL, NULL ); - rc = -1; - goto finish; + /* FIXME: no error, but no matched ... */ + mmatch = NULL; + break; } } @@ -691,8 +688,10 @@ meta_send_entry( } break; - case REWRITE_REGEXEC_ERR: case REWRITE_REGEXEC_UNWILLING: + return LDAP_UNWILLING_TO_PERFORM; + + case REWRITE_REGEXEC_ERR: return LDAP_OTHER; }