On Fri, Oct 28, 2011 at 02:27:32AM +0000, Viktor Dukhovni wrote:
> A better solution is required, I'll post an updated proposal
> tomorrow.
Please try the below. It inlines the two-line (possibly deprecated)
ldap_result2error() function, which just calls ldap_parse_result().
I don't believe we actually need to call ldap_parse_sasl_bind_result(),
as ldap_parse_result should be enough, we don't need (or in any
case have never asked for or used) the additional information from
its server_creds result argument.
Index: src/global/dict_ldap.c
--- src/global/dict_ldap.c 1 Mar 2011 04:44:42 -0000 1.1.1.2
+++ src/global/dict_ldap.c 28 Oct 2011 15:58:37 -0000
@@ -498,6 +498,7 @@
static int dict_ldap_result(LDAP *ld, int msgid, int timeout, LDAPMessage
**res)
{
struct timeval mytimeval;
+ int err;
mytimeval.tv_sec = timeout;
mytimeval.tv_usec = 0;
@@ -506,10 +507,14 @@
if (ldap_result(ld, msgid, GET_ALL, &mytimeval, res) == -1)
return (dict_ldap_get_errno(ld));
- if (dict_ldap_get_errno(ld) == LDAP_TIMEOUT) {
- (void) dict_ldap_abandon(ld, msgid);
- return (dict_ldap_set_errno(ld, LDAP_TIMEOUT));
+ if ((err = dict_ldap_get_errno(ld)) != LDAP_SUCCESS) {
+ if (err == LDAP_TIMEOUT) {
+ (void) dict_ldap_abandon(ld, msgid);
+ return (dict_ldap_set_errno(ld, LDAP_TIMEOUT));
+ }
+ return err;
}
+
return LDAP_SUCCESS;
}
@@ -552,6 +557,7 @@
static int dict_ldap_bind_st(DICT_LDAP *dict_ldap)
{
int rc;
+ int err = LDAP_SUCCESS;
int msgid;
LDAPMessage *res;
struct berval cred;
@@ -567,7 +573,8 @@
return (rc);
#define FREE_RESULT 1
- return (ldap_parse_sasl_bind_result(dict_ldap->ld, res, 0, FREE_RESULT));
+ rc = ldap_parse_result(ld, res, &err, 0, 0, 0, 0, FREE_RESULT);
+ return (rc == LDAP_SUCCESS ? err : rc);
}
/* search_st - Synchronous search with timeout */
--
Viktor.