From 0ab67e48396fde41ad3b032d910440bddac84fd3 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Thu, 28 Jun 2012 14:58:34 -0400 Subject: [PATCH] Treat LDAP_OPT_CONNECT_TIMEOUT (Tivoli Directory Server 6.3) the same as LDAP_OPT_CONNECT_TIMEOUT (OpenSSH). Don't make failure to a set an ldap option fatal. --HG-- branch : 1.7 --- ldap.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/ldap.c b/ldap.c index 90ccf713b..03ba3809d 100644 --- a/ldap.c +++ b/ldap.c @@ -85,6 +85,10 @@ extern int ldapssl_set_strength(LDAP *ldap, int strength); #endif +#if !defined(LDAP_OPT_NETWORK_TIMEOUT) && defined(LDAP_OPT_CONNECT_TIMEOUT) +# define LDAP_OPT_NETWORK_TIMEOUT LDAP_OPT_CONNECT_TIMEOUT +#endif + #ifndef LDAP_OPT_SUCCESS # define LDAP_OPT_SUCCESS LDAP_SUCCESS #endif @@ -1923,7 +1927,7 @@ sudo_ldap_set_options_table(ld, table) struct ldap_config_table *table; { struct ldap_config_table *cur; - int ival, rc; + int ival, rc, errors = 0; char *sval; for (cur = table; cur->conf_str != NULL; cur++) { @@ -1935,30 +1939,30 @@ sudo_ldap_set_options_table(ld, table) case CONF_INT: ival = *(int *)(cur->valp); if (ival >= 0) { + DPRINTF(("ldap_set_option: %s -> %d", cur->conf_str, ival), 1); rc = ldap_set_option(ld, cur->opt_val, &ival); if (rc != LDAP_OPT_SUCCESS) { warningx("ldap_set_option: %s -> %d: %s", cur->conf_str, ival, ldap_err2string(rc)); - return -1; + errors++; } - DPRINTF(("ldap_set_option: %s -> %d", cur->conf_str, ival), 1); } break; case CONF_STR: sval = *(char **)(cur->valp); if (sval != NULL) { + DPRINTF(("ldap_set_option: %s -> %s", cur->conf_str, sval), 1); rc = ldap_set_option(ld, cur->opt_val, sval); if (rc != LDAP_OPT_SUCCESS) { warningx("ldap_set_option: %s -> %s: %s", cur->conf_str, sval, ldap_err2string(rc)); - return -1; + errors++; } - DPRINTF(("ldap_set_option: %s -> %s", cur->conf_str, sval), 1); } break; } } - return 0; + return errors ? -1 : 0; } /* -- 2.40.0