summaryrefslogtreecommitdiff
path: root/pith/ldap.c
diff options
context:
space:
mode:
authorEduardo Chappa <chappa@washington.edu>2019-12-14 00:14:41 -0700
committerEduardo Chappa <chappa@washington.edu>2019-12-14 00:14:41 -0700
commitac38a766b176bfc926377d9cc5185ab4d2722857 (patch)
treed1ed7a75fd58904fc93aed8c76161d943d9abf73 /pith/ldap.c
parent46e208ffa9fffc3057df7a698f2124b3998a24ac (diff)
downloadalpine-ac38a766b176bfc926377d9cc5185ab4d2722857.tar.xz
* When more than one server was given in the server-name configuration
option of rldap servers, none of them worked. Reported by Robert Wolf.
Diffstat (limited to 'pith/ldap.c')
-rw-r--r--pith/ldap.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/pith/ldap.c b/pith/ldap.c
index 3c1db403..6826b13c 100644
--- a/pith/ldap.c
+++ b/pith/ldap.c
@@ -398,7 +398,7 @@ ldap_lookup(LDAP_SERV_S *info, char *string, CUSTOM_FILT_S *cust,
{
char ebuf[900];
char buf[900];
- char *serv, *base, *serv_errstr;
+ char *serv, *base, *serv_errstr, *s, *t;
char *mailattr, *snattr, *gnattr, *cnattr;
int we_cancel = 0, we_turned_on = 0;
LDAP_SERV_RES_S *serv_res = NULL;
@@ -526,9 +526,28 @@ ldap_lookup(LDAP_SERV_S *info, char *string, CUSTOM_FILT_S *cust,
}
#endif /* SMIME_SSLCERTS */
- snprintf(tmp_20k_buf, SIZEOF_20KBUF, "%s://%s:%d",
- info->ldaps ? "ldaps" : "ldap", serv, info->port);
- tmp_20k_buf[SIZEOF_20KBUF-1] = '\0';
+ tmp_20k_buf[0] = '\0';
+ s = serv;
+ do {
+ if ((t = strchr(s, ' ')) != NULL) *t = '\0';
+ snprintf(tmp_20k_buf + strlen(tmp_20k_buf),
+ SIZEOF_20KBUF - strlen(tmp_20k_buf), "%s://%s",
+ info->ldaps ? "ldaps" : "ldap", s);
+ if (strchr(s, ':') == NULL){
+ snprintf(tmp_20k_buf + strlen(tmp_20k_buf),
+ SIZEOF_20KBUF - strlen(tmp_20k_buf),
+ "%s%d", ":", info->port);
+ }
+ if(t != NULL){
+ *t = ' ';
+ for( ; *t == ' '; t++);
+ snprintf(tmp_20k_buf + strlen(tmp_20k_buf),
+ SIZEOF_20KBUF - strlen(tmp_20k_buf), "%s", " ");
+ }
+ s = t;
+ } while (s != NULL);
+
+ tmp_20k_buf[SIZEOF_20KBUF - 1] = '\0';
if(ldap_initialize(&ld, tmp_20k_buf) != LDAP_SUCCESS)
#endif