Sophie

Sophie

distrib > Fedora > 13 > i386 > media > updates-src > by-pkgid > 95e2d750b941652dad4c688ffc319be3 > files > 16

curl-7.20.1-5.fc13.src.rpm

 lib/ldap.c |   37 +++++++++++++++++++++++++++++++++++--
 1 files changed, 35 insertions(+), 2 deletions(-)

diff --git a/lib/ldap.c b/lib/ldap.c
index 07ec5b0..054b2b4 100644
--- a/lib/ldap.c
+++ b/lib/ldap.c
@@ -55,7 +55,15 @@
 #if (defined(HAVE_LDAP_SSL) && defined(HAVE_LDAP_SSL_H))
 # include <ldap_ssl.h>
 #endif /* HAVE_LDAP_SSL && HAVE_LDAP_SSL_H */
-#endif
+
+/* <RHBZ#655134>
+ * ldap_pvt.h is not included in the openldap-devel RPM */
+#ifndef _LDAP_PVT_H
+extern int ldap_init_fd(ber_socket_t fd, int proto, char *uri, LDAP **ldp);
+#endif /* _LDAP_PVT_H */
+#define LDAP_PROTO_TCP 1
+/* </RHBZ#655134> */
+#endif                          /* CURL_LDAP_WIN */
 
 #ifdef HAVE_UNISTD_H
 # include <unistd.h>
@@ -209,6 +217,19 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
 #endif
   ldap_set_option(NULL, LDAP_OPT_PROTOCOL_VERSION, &ldap_proto);
 
+/* <RHBZ#655134> */
+  if(conn->bits.tunnel_proxy && conn->bits.httpproxy) {
+    /* for LDAP over HTTP proxy */
+    CURLcode result;
+    result = Curl_proxyCONNECT(conn, FIRSTSOCKET,
+                               conn->host.name, conn->remote_port);
+    if(CURLE_OK != result) {
+      status = CURLE_COULDNT_CONNECT;
+      goto quit;
+    }
+  }
+/* </RHBZ#655134> */
+
   if(ldap_ssl) {
 #ifdef HAVE_LDAP_SSL
 #ifdef CURL_LDAP_WIN
@@ -299,7 +320,13 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
       status = CURLE_SSL_CERTPROBLEM;
       goto quit;
     }
-    server = ldap_init(conn->host.name, (int)conn->port);
+/* <RHBZ#655134> */
+    if(conn->bits.tunnel_proxy && conn->bits.httpproxy) {
+      ldap_init_fd(conn->sock[FIRSTSOCKET], LDAP_PROTO_TCP, NULL, &server);
+    } else {
+      server = ldap_init(conn->host.name, (int)conn->port);
+    }
+/* </RHBZ#655134> */
     if(server == NULL) {
       failf(data, "LDAP local: Cannot connect to %s:%hu",
               conn->host.name, conn->port);
@@ -334,7 +361,13 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
 #endif
 #endif /* CURL_LDAP_USE_SSL */
   } else {
+/* <RHBZ#655134> */
+  if(conn->bits.tunnel_proxy && conn->bits.httpproxy) {
+    ldap_init_fd(conn->sock[FIRSTSOCKET], LDAP_PROTO_TCP, NULL, &server);
+  } else {
     server = ldap_init(conn->host.name, (int)conn->port);
+  }
+/* </RHBZ#655134> */
     if(server == NULL) {
       failf(data, "LDAP local: Cannot connect to %s:%hu",
               conn->host.name, conn->port);