Fix port defaulting

This commit is contained in:
Kurt Zeilenga 2000-09-01 23:03:17 +00:00
parent 5ed98aed27
commit 57ed8f6458
4 changed files with 21 additions and 13 deletions

View file

@ -496,7 +496,8 @@ LDAP_F (int) ldap_url_parselist LDAP_P((
LDAP_F (int) ldap_url_parsehosts LDAP_P((
LDAPURLDesc **ludlist,
const char *hosts ));
const char *hosts,
int port ));
LDAP_F (char *) ldap_url_list2hosts LDAP_P((
LDAPURLDesc *ludlist ));

View file

@ -257,19 +257,17 @@ ldap_int_open_connection(
Debug( LDAP_DEBUG_TRACE, "ldap_int_open_connection\n", 0, 0, 0 );
port = srv->lud_port;
if (port == 0)
port = ld->ld_options.ldo_defport;
port = htons( (short) port );
addr = 0;
if ( srv->lud_host == NULL || *srv->lud_host == 0 )
addr = htonl( INADDR_LOOPBACK );
switch ( ldap_pvt_url_scheme2proto( srv->lud_scheme ) ) {
case LDAP_PROTO_TCP:
port = htons( (short) srv->lud_port );
addr = 0;
if ( srv->lud_host == NULL || *srv->lud_host == 0 )
addr = htonl( INADDR_LOOPBACK );
rc = ldap_connect_to_host( ld, conn->lconn_sb, 0,
srv->lud_host, addr, port, async );
if ( rc == -1 ) return rc;
ber_sockbuf_add_io( conn->lconn_sb, &ber_sockbuf_io_tcp,
LBER_SBIOD_LEVEL_PROVIDER, NULL );

View file

@ -465,7 +465,8 @@ ldap_set_option(
int rc = LDAP_OPT_SUCCESS;
if(host != NULL) {
rc = ldap_url_parsehosts(&ludlist, host);
rc = ldap_url_parsehosts( &ludlist, host,
lo->ldo_defport ? lo->ldo_defport : LDAP_PORT );
} else if(ld == NULL) {
/*

View file

@ -272,7 +272,7 @@ ldap_url_parse( LDAP_CONST char *url_in, LDAPURLDesc **ludpp )
ludp->lud_next = NULL;
ludp->lud_host = NULL;
ludp->lud_port = 0;
ludp->lud_port = LDAP_PORT;
ludp->lud_dn = NULL;
ludp->lud_attrs = NULL;
ludp->lud_filter = NULL;
@ -287,6 +287,10 @@ ldap_url_parse( LDAP_CONST char *url_in, LDAPURLDesc **ludpp )
return LDAP_URL_ERR_MEM;
}
if( strcasecmp( ludp->lud_scheme, "ldaps" ) == 0 ) {
ludp->lud_port = LDAPS_PORT;
}
/* scan forward for '/' that marks end of hostport and begin. of dn */
p = strchr( url, '/' );
@ -659,7 +663,10 @@ ldap_url_parselist (LDAPURLDesc **ludlist, const char *url )
}
int
ldap_url_parsehosts (LDAPURLDesc **ludlist, const char *hosts )
ldap_url_parsehosts(
LDAPURLDesc **ludlist,
const char *hosts,
int port )
{
int i;
LDAPURLDesc *ludp;
@ -686,6 +693,7 @@ ldap_url_parsehosts (LDAPURLDesc **ludlist, const char *hosts )
*ludlist = NULL;
return LDAP_NO_MEMORY;
}
ludp->lud_port = port;
ludp->lud_host = specs[i];
specs[i] = NULL;
p = strchr(ludp->lud_host, ':');