char *sasl_host = NULL;
int sasl_ssf = 0;
#endif
+ char *host;
int port;
long addr;
port = htons( (short) srv->lud_port );
addr = 0;
- if ( srv->lud_host == NULL || *srv->lud_host == 0 )
+ if ( srv->lud_host == NULL || *srv->lud_host == 0 ) {
+ host = NULL;
addr = htonl( INADDR_LOOPBACK );
+ } else {
+ host = srv->lud_host;
+ }
rc = ldap_connect_to_host( ld, conn->lconn_sb, 0,
- srv->lud_host, addr, port, async );
+ host, addr, port, async );
if ( rc == -1 ) return rc;
+
+#ifdef LDAP_DEBUG
+ ber_sockbuf_add_io( conn->lconn_sb, &ber_sockbuf_io_debug,
+ LBER_SBIOD_LEVEL_PROVIDER, (void *)"tcp_" );
+#endif
ber_sockbuf_add_io( conn->lconn_sb, &ber_sockbuf_io_tcp,
LBER_SBIOD_LEVEL_PROVIDER, NULL );
rc = ldap_connect_to_path( ld, conn->lconn_sb,
srv->lud_host, async );
if ( rc == -1 ) return rc;
+
+#ifdef LDAP_DEBUG
+ ber_sockbuf_add_io( conn->lconn_sb, &ber_sockbuf_io_debug,
+ LBER_SBIOD_LEVEL_PROVIDER, (void *)"ipc_" );
+#endif
ber_sockbuf_add_io( conn->lconn_sb, &ber_sockbuf_io_fd,
LBER_SBIOD_LEVEL_PROVIDER, NULL );
ber_sockbuf_add_io( conn->lconn_sb, &ber_sockbuf_io_readahead,
LBER_SBIOD_LEVEL_PROVIDER, NULL );
+
#ifdef LDAP_DEBUG
ber_sockbuf_add_io( conn->lconn_sb, &ber_sockbuf_io_debug,
- INT_MAX, NULL );
+ INT_MAX, (void *)"ldap_" );
#endif
#ifdef HAVE_TLS
if (ld->ld_options.ldo_tls_mode == LDAP_OPT_X_TLS_HARD ||
strcmp( srv->lud_scheme, "ldaps" ) == 0 )
{
+ LDAPConn *savedefconn = ld->ld_defconn;
+ ++conn->lconn_refcnt; /* avoid premature free */
+ ld->ld_defconn = conn;
+
rc = ldap_pvt_tls_start( ld, conn->lconn_sb,
ld->ld_options.ldo_tls_ctx );
+ ld->ld_defconn = savedefconn;
+ --conn->lconn_refcnt;
+
if (rc != LDAP_SUCCESS) {
return -1;
}
return( LDAP_NO_MEMORY );
}
ber_sockbuf_ctrl( c->lconn_sb, LBER_SB_OPT_SET_FD, fdp );
+#ifdef LDAP_DEBUG
+ ber_sockbuf_add_io( c->lconn_sb, &ber_sockbuf_io_debug,
+ LBER_SBIOD_LEVEL_PROVIDER, (void *)"int_" );
+#endif
ber_sockbuf_add_io( c->lconn_sb, &ber_sockbuf_io_tcp,
LBER_SBIOD_LEVEL_PROVIDER, NULL );
(*ldp)->ld_defconn = c;