X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=libraries%2Flibldap%2Ferror.c;h=250f2b9f1adef00c3b5018396d4b91074dc84fc9;hb=ae471f78c32d7531c729aa88116b8b413cc200bf;hp=c6ac44b9b024ab426a8aa3ecf317c8b47a53a0fa;hpb=a2705b84c7442232e2908ae3c7ebc338720c5c66;p=openldap diff --git a/libraries/libldap/error.c b/libraries/libldap/error.c index c6ac44b9b0..250f2b9f1a 100644 --- a/libraries/libldap/error.c +++ b/libraries/libldap/error.c @@ -1,7 +1,7 @@ /* $OpenLDAP$ */ /* This work is part of OpenLDAP Software . * - * Copyright 1998-2004 The OpenLDAP Foundation. + * Copyright 1998-2008 The OpenLDAP Foundation. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -12,9 +12,6 @@ * top-level directory of the distribution or, alternatively, at * . */ -/* Portions Copyright (C) The Internet Society (1997) - * ASN.1 fragments are from RFC 2251; see RFC for full legal notices. - */ #include "portable.h" @@ -65,7 +62,6 @@ static struct ldaperror ldap_builtin_errlist[] = { {LDAP_IS_LEAF, N_("Entry is a leaf")}, {LDAP_ALIAS_DEREF_PROBLEM, N_("Alias dereferencing problem")}, - {LDAP_PROXY_AUTHZ_FAILURE, N_("Proxy Authorization Failure")}, {LDAP_INAPPROPRIATE_AUTH, N_("Inappropriate authentication")}, {LDAP_INVALID_CREDENTIALS, N_("Invalid credentials")}, {LDAP_INSUFFICIENT_ACCESS, N_("Insufficient access")}, @@ -83,7 +79,34 @@ static struct ldaperror ldap_builtin_errlist[] = { {LDAP_RESULTS_TOO_LARGE, N_("Results too large")}, {LDAP_AFFECTS_MULTIPLE_DSAS, N_("Operation affects multiple DSAs")}, - {LDAP_OTHER, N_("Internal (implementation specific) error")}, + {LDAP_OTHER, N_("Other (e.g., implementation specific) error")}, + + {LDAP_CANCELLED, N_("Cancelled")}, + {LDAP_NO_SUCH_OPERATION, N_("No Operation to Cancel")}, + {LDAP_TOO_LATE, N_("Too Late to Cancel")}, + {LDAP_CANNOT_CANCEL, N_("Cannot Cancel")}, + + {LDAP_ASSERTION_FAILED, N_("Assertion Failed")}, + {LDAP_X_ASSERTION_FAILED, N_("Assertion Failed (X)")}, + + {LDAP_PROXIED_AUTHORIZATION_DENIED, N_("Proxied Authorization Denied")}, + {LDAP_X_PROXY_AUTHZ_FAILURE, N_("Proxy Authorization Failure (X)")}, + + {LDAP_SYNC_REFRESH_REQUIRED, N_("Content Sync Refresh Required")}, + {LDAP_X_SYNC_REFRESH_REQUIRED, N_("Content Sync Refresh Required (X)")}, + + {LDAP_X_NO_OPERATION, N_("No Operation (X)")}, + + {LDAP_CUP_RESOURCES_EXHAUSTED, N_("LCUP Resources Exhausted")}, + {LDAP_CUP_SECURITY_VIOLATION, N_("LCUP Security Violation")}, + {LDAP_CUP_INVALID_DATA, N_("LCUP Invalid Data")}, + {LDAP_CUP_UNSUPPORTED_SCHEME, N_("LCUP Unsupported Scheme")}, + {LDAP_CUP_RELOAD_REQUIRED, N_("LCUP Reload Required")}, + +#ifdef LDAP_X_TXN + {LDAP_X_TXN_SPECIFY_OKAY, N_("TXN specify okay")}, + {LDAP_X_TXN_ID_INVALID, N_("TXN ID is invalid")}, +#endif /* API ResultCodes */ {LDAP_SERVER_DOWN, N_("Can't contact LDAP server")}, @@ -105,22 +128,6 @@ static struct ldaperror ldap_builtin_errlist[] = { {LDAP_CLIENT_LOOP, N_("Client Loop")}, {LDAP_REFERRAL_LIMIT_EXCEEDED, N_("Referral Limit Exceeded")}, - {LDAP_SYNC_REFRESH_REQUIRED, N_("Content Sync Refresh Required")}, - - {LDAP_NO_OPERATION, N_("No Operation")}, - {LDAP_ASSERTION_FAILED, N_("Assertion Failed")}, - - {LDAP_CUP_RESOURCES_EXHAUSTED, N_("LCUP Resources Exhausted")}, - {LDAP_CUP_SECURITY_VIOLATION, N_("LCUP Security Violation")}, - {LDAP_CUP_INVALID_DATA, N_("LCUP Invalid Data")}, - {LDAP_CUP_UNSUPPORTED_SCHEME, N_("LCUP Unsupported Scheme")}, - {LDAP_CUP_RELOAD_REQUIRED, N_("LCUP Reload Required")}, - - {LDAP_CANCELLED, N_("Cancelled")}, - {LDAP_NO_SUCH_OPERATION, N_("No Operation to Cancel")}, - {LDAP_TOO_LATE, N_("Too Late to Cancel")}, - {LDAP_CANNOT_CANCEL, N_("Cannot Cancel")}, - {0, NULL} }; @@ -179,7 +186,7 @@ ldap_perror( LDAP *ld, LDAP_CONST char *str ) assert( ld != NULL ); assert( LDAP_VALID( ld ) ); - assert( str ); + assert( str != NULL ); e = ldap_int_error( ld->ld_errno ); @@ -273,25 +280,20 @@ ldap_parse_result( #ifdef LDAP_R_COMPILE ldap_pvt_thread_mutex_lock( &ld->ld_res_mutex ); #endif - /* Find the next result... */ - if ( r->lm_chain == NULL ) { - if ((r->lm_msgtype == LDAP_RES_SEARCH_ENTRY) || - (r->lm_msgtype == LDAP_RES_SEARCH_REFERENCE) || - (r->lm_msgtype == LDAP_RES_INTERMEDIATE)) { - lm = NULL; - } else { - lm = r; - } - } else { - if ((r->lm_chain_tail->lm_chain->lm_msgtype - == LDAP_RES_SEARCH_ENTRY) || - (r->lm_chain_tail->lm_chain->lm_msgtype - == LDAP_RES_SEARCH_REFERENCE) || - (r->lm_chain_tail->lm_chain->lm_msgtype - == LDAP_RES_INTERMEDIATE)) { + /* Find the result, last msg in chain... */ + lm = r->lm_chain_tail; + /* FIXME: either this is not possible (assert?) + * or it should be handled */ + if ( lm != NULL ) { + switch ( lm->lm_msgtype ) { + case LDAP_RES_SEARCH_ENTRY: + case LDAP_RES_SEARCH_REFERENCE: + case LDAP_RES_INTERMEDIATE: lm = NULL; - } else { - lm = r->lm_chain_tail->lm_chain; + break; + + default: + break; } } @@ -321,11 +323,13 @@ ldap_parse_result( ber = ber_dup( lm->lm_ber ); if ( ld->ld_version < LDAP_VERSION2 ) { - tag = ber_scanf( ber, "{ia}", + tag = ber_scanf( ber, "{iA}", &ld->ld_errno, &ld->ld_error ); + } else { ber_len_t len; - tag = ber_scanf( ber, "{iaa" /*}*/, + + tag = ber_scanf( ber, "{iAA" /*}*/, &ld->ld_errno, &ld->ld_matched, &ld->ld_error ); if( tag != LBER_ERROR ) { @@ -387,37 +391,21 @@ ldap_parse_result( } if ( errcode == LDAP_SUCCESS ) { if( matcheddnp != NULL ) { - *matcheddnp = LDAP_STRDUP( ld->ld_matched ); + if ( ld->ld_matched ) + { + *matcheddnp = LDAP_STRDUP( ld->ld_matched ); + } } if( errmsgp != NULL ) { - *errmsgp = LDAP_STRDUP( ld->ld_error ); + if ( ld->ld_error ) + { + *errmsgp = LDAP_STRDUP( ld->ld_error ); + } } if( referralsp != NULL) { *referralsp = ldap_value_dup( ld->ld_referrals ); } - - /* Find the next result... */ - lm = lm->lm_chain; - if ( lm ) { - if ( lm->lm_chain == NULL ) { - if ((lm->lm_msgtype != LDAP_RES_SEARCH_ENTRY) && - (lm->lm_msgtype != LDAP_RES_SEARCH_REFERENCE) && - (lm->lm_msgtype != LDAP_RES_INTERMEDIATE)) { - /* more results to return */ - errcode = LDAP_MORE_RESULTS_TO_RETURN; - } - } else { - if ((lm->lm_chain_tail->lm_chain->lm_msgtype - != LDAP_RES_SEARCH_ENTRY) && - (lm->lm_chain_tail->lm_chain->lm_msgtype - != LDAP_RES_SEARCH_REFERENCE) && - (lm->lm_chain_tail->lm_chain->lm_msgtype - != LDAP_RES_INTERMEDIATE)) { - errcode = LDAP_MORE_RESULTS_TO_RETURN; - } - } - } } if ( freeit ) {