summaryrefslogtreecommitdiffstats
path: root/libsm/ldap.c
diff options
context:
space:
mode:
authorgshapiro <gshapiro@FreeBSD.org>2010-01-26 04:17:18 +0000
committergshapiro <gshapiro@FreeBSD.org>2010-01-26 04:17:18 +0000
commita8454492fdd0eb5a005ff8ef52fad69f43baffe2 (patch)
tree25902a53d874255d42002dd157e36601e71e2df5 /libsm/ldap.c
parent3fcf33f21197c2c6b7eb494f7b6d5737cb7a492c (diff)
downloadFreeBSD-src-a8454492fdd0eb5a005ff8ef52fad69f43baffe2.zip
FreeBSD-src-a8454492fdd0eb5a005ff8ef52fad69f43baffe2.tar.gz
Import sendmail 8.14.4
Diffstat (limited to 'libsm/ldap.c')
-rw-r--r--libsm/ldap.c33
1 files changed, 27 insertions, 6 deletions
diff --git a/libsm/ldap.c b/libsm/ldap.c
index 252e547..7ee57fc 100644
--- a/libsm/ldap.c
+++ b/libsm/ldap.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001-2007 Sendmail, Inc. and its suppliers.
+ * Copyright (c) 2001-2009 Sendmail, Inc. and its suppliers.
* All rights reserved.
*
* By using this file, you agree to the terms and conditions set
@@ -11,7 +11,7 @@
#define LDAP_DEPRECATED 1
#include <sm/gen.h>
-SM_RCSID("@(#)$Id: ldap.c,v 1.80 2007/10/12 00:19:44 ca Exp $")
+SM_RCSID("@(#)$Id: ldap.c,v 1.83 2009/06/19 22:02:26 guenther Exp $")
#if LDAPMAP
# include <sys/types.h>
@@ -1099,7 +1099,21 @@ sm_ldap_results(lmap, msgid, flags, delim, rpool, result,
if (ret == 0)
save_errno = ETIMEDOUT;
else
- save_errno = sm_ldap_geterrno(lmap->ldap_ld);
+ {
+ int rc;
+
+ /*
+ ** We may have gotten an LDAP_RES_SEARCH_RESULT response
+ ** with an error inside it, so we have to extract that
+ ** with ldap_parse_result(). This can happen when talking
+ ** to an LDAP proxy whose backend has gone down.
+ */
+
+ save_errno = ldap_parse_result(lmap->ldap_ld, lmap->ldap_res,
+ &rc, NULL, NULL, NULL, NULL, 0);
+ if (save_errno == LDAP_SUCCESS)
+ save_errno = rc;
+ }
if (save_errno != LDAP_SUCCESS)
{
statp = EX_TEMPFAIL;
@@ -1370,9 +1384,16 @@ sm_ldap_setopts(ld, lmap)
ldap_set_option(ld, LDAP_OPT_REFERRALS, LDAP_OPT_OFF);
ldap_set_option(ld, LDAP_OPT_SIZELIMIT, &lmap->ldap_sizelimit);
ldap_set_option(ld, LDAP_OPT_TIMELIMIT, &lmap->ldap_timelimit);
-# if _FFR_LDAP_NETWORK_TIMEOUT && defined(LDAP_OPT_NETWORK_TIMEOUT)
- ldap_set_option(ld, LDAP_OPT_NETWORK_TIMEOUT, &lmap->ldap_networktmo);
-# endif /* _FFR_LDAP_NETWORK_TIMEOUT && defined(LDAP_OPT_NETWORK_TIMEOUT) */
+# if _FFR_LDAP_NETWORK_TIMEOUT && defined(LDAP_OPT_NETWORK_TIMEOUT)
+ if (lmap->ldap_networktmo > 0)
+ {
+ struct timeval tmo;
+
+ tmo.tv_sec = lmap->ldap_networktmo;
+ tmo.tv_usec = 0;
+ ldap_set_option(ld, LDAP_OPT_NETWORK_TIMEOUT, &tmo);
+ }
+# endif /* _FFR_LDAP_NETWORK_TIMEOUT && defined(LDAP_OPT_NETWORK_TIMEOUT) */
# ifdef LDAP_OPT_RESTART
ldap_set_option(ld, LDAP_OPT_RESTART, LDAP_OPT_ON);
# endif /* LDAP_OPT_RESTART */
OpenPOWER on IntegriCloud