From cf15f67ca3d5a74f6205643ba7f165e05a3e95b3 Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Fri, 10 Mar 2000 23:37:21 +0000 Subject: [PATCH] Apply Wes's kbind fix (ITS#426). Needs to be reconciled with devel's kbind fix. --- CHANGES | 1 + libraries/libldap/kbind.c | 4 ++++ libraries/libldap/open.c | 24 +----------------------- libraries/libldap/request.c | 26 ++++++++++++++++++-------- 4 files changed, 24 insertions(+), 31 deletions(-) diff --git a/CHANGES b/CHANGES index 03570b95fd..80f40d00bd 100644 --- a/CHANGES +++ b/CHANGES @@ -5,6 +5,7 @@ Changes included in OpenLDAP 1.2.10 Release Engineering Add slapd -DSLAPD_UNDEFINED_OC_IS_NOT_EXTENSIBLE macro disable undefined object classes implies extensible object behavior. Add GNU Pth support (ITS#453) + Fixed -lldap Kerberos bind to work ldap_init() (ITS#426) Changed -lldap to ignore space in filter: ( !(foo=bar)) (ITS#459) Fixed multiple password support (ITS#464) Fixed back-ldbm/bind invalid credentials vs no such object bug diff --git a/libraries/libldap/kbind.c b/libraries/libldap/kbind.c index 4417a129b4..c399d31c81 100644 --- a/libraries/libldap/kbind.c +++ b/libraries/libldap/kbind.c @@ -261,6 +261,10 @@ ldap_get_kerberosv4_credentials( LDAP *ld, char *who, char *service, int *len ) return( NULL ); } + if ( ldap_delayed_open( ld ) < 0 ) { + return( NULL ); + } + #ifdef LDAP_REFERRALS krbinstance = ld->ld_defconn->lconn_krbinstance; #else /* LDAP_REFERRALS */ diff --git a/libraries/libldap/open.c b/libraries/libldap/open.c index 190d4028b9..b5cf355a0f 100644 --- a/libraries/libldap/open.c +++ b/libraries/libldap/open.c @@ -53,31 +53,9 @@ ldap_open( char *host, int port ) return( NULL ); } -#ifdef LDAP_REFERRALS - if (( srv = (LDAPServer *)calloc( 1, sizeof( LDAPServer ))) == - NULL || ( ld->ld_defhost != NULL && ( srv->lsrv_host = - ldap_strdup( ld->ld_defhost )) == NULL )) { - if(srv != NULL) free( (char*) srv ); - ldap_ld_free( ld, 0 ); - return( NULL ); - } - srv->lsrv_port = ld->ld_defport; - - if (( ld->ld_defconn = ldap_new_connection( ld, &srv, 1,1,0 )) == NULL ) { - if ( ld->ld_defhost != NULL ) free( srv->lsrv_host ); - free( (char *)srv ); - ldap_ld_free( ld, 0 ); + if ( ldap_delayed_open( ld ) < 0 ) { return( NULL ); } - ++ld->ld_defconn->lconn_refcnt; /* so it never gets closed/freed */ - -#else /* LDAP_REFERRALS */ - if ( open_ldap_connection( ld, &ld->ld_sb, ld->ld_defhost, - ld->ld_defport, &ld->ld_host, 0 ) < 0 ) { - ldap_ld_free( ld, 0 ); - return( NULL ); - } -#endif /* LDAP_REFERRALS */ Debug( LDAP_DEBUG_TRACE, "ldap_open successful, ld_host is %s\n", ( ld->ld_host == NULL ) ? "(null)" : ld->ld_host, 0, 0 ); diff --git a/libraries/libldap/request.c b/libraries/libldap/request.c index 71c62d035b..33d7d67dc6 100644 --- a/libraries/libldap/request.c +++ b/libraries/libldap/request.c @@ -71,16 +71,14 @@ ldap_set_ber_options( LDAP *ld, BerElement *ber ) #endif /* STR_TRANSLATION */ } - int -ldap_send_initial_request( LDAP *ld, unsigned long msgtype, char *dn, - BerElement *ber ) +ldap_delayed_open( LDAP *ld ) { #if defined( LDAP_REFERRALS ) || defined( LDAP_DNS ) LDAPServer *servers, *srv; #endif /* LDAP_REFERRALS || LDAP_DNS */ - Debug( LDAP_DEBUG_TRACE, "ldap_send_initial_request\n", 0, 0, 0 ); + Debug( LDAP_DEBUG_TRACE, "ldap_delayed_open\n", 0, 0, 0 ); if ( ld->ld_sb.sb_sd == -1 ) { /* not connected yet */ @@ -116,12 +114,24 @@ ldap_send_initial_request( LDAP *ld, unsigned long msgtype, char *dn, return( -1 ); } #endif /* LDAP_REFERRALS */ - - Debug( LDAP_DEBUG_TRACE, - "ldap_delayed_open successful, ld_host is %s\n", - ( ld->ld_host == NULL ) ? "(null)" : ld->ld_host, 0, 0 ); } + return( 0 ); +} + +int +ldap_send_initial_request( LDAP *ld, unsigned long msgtype, char *dn, + BerElement *ber ) +{ +#if defined( LDAP_REFERRALS ) || defined( LDAP_DNS ) + LDAPServer *servers, *srv; +#endif /* LDAP_REFERRALS || LDAP_DNS */ + + Debug( LDAP_DEBUG_TRACE, "ldap_send_initial_request\n", 0, 0, 0 ); + + if ( ldap_delayed_open( ld ) < 0 ) { + return( -1 ); + } #if !defined( LDAP_REFERRALS ) && !defined( LDAP_DNS ) -- 2.47.2