#if defined(HAVE_TLS) || defined(HAVE_CYRUS_SASL)
char * ldap_int_hostname = NULL;
+
+void
+ldap_int_resolve_hostname(void)
+{
+ static int resolved = 0;
+
+ LDAP_MUTEX_LOCK( &ldap_int_hostname_mutex );
+ if ( !resolved ) {
+ char *name = ldap_int_hostname;
+
+ ldap_int_hostname = ldap_pvt_get_fqdn( name );
+
+ if ( name != NULL && name != ldap_int_hostname ) {
+ LDAP_FREE( name );
+ }
+ resolved = 1;
+ }
+ LDAP_MUTEX_UNLOCK( &ldap_int_hostname_mutex );
+}
#endif
#ifdef LDAP_R_COMPILE
}
#endif
-#if defined(HAVE_TLS) || defined(HAVE_CYRUS_SASL)
- LDAP_MUTEX_LOCK( &ldap_int_hostname_mutex );
- {
- char *name = ldap_int_hostname;
-
- ldap_int_hostname = ldap_pvt_get_fqdn( name );
-
- if ( name != NULL && name != ldap_int_hostname ) {
- LDAP_FREE( name );
- }
- }
- LDAP_MUTEX_UNLOCK( &ldap_int_hostname_mutex );
-#endif
-
#ifndef HAVE_POLL
if ( ldap_int_tblsize == 0 ) ldap_int_ip_init();
#endif
#if defined(HAVE_TLS) || defined(HAVE_CYRUS_SASL)
LDAP_V (char *) ldap_int_hostname;
+LDAP_F (void) ldap_int_resolve_hostname(void);
LDAP_F (char *) ldap_host_connected_to( Sockbuf *sb,
const char *host );
#endif
* this is necessary for kerberos to work right, since the official
* hostname is used as the kerberos instance.
*/
+ if ( !ldap_int_hostname )
+ ldap_int_resolve_hostname();
switch (sa->sa_family) {
#ifdef LDAP_PF_LOCAL
int len1 = 0, len2 = 0;
int ntype = IS_DNS;
+ if ( !ldap_int_hostname )
+ ldap_int_resolve_hostname();
+
if( ldap_int_hostname &&
( !name_in || !strcasecmp( name_in, "localhost" ) ) )
{
struct in_addr addr;
#endif
+ if ( !ldap_int_hostname )
+ ldap_int_resolve_hostname();
+
if( ldap_int_hostname &&
( !name_in || !strcasecmp( name_in, "localhost" ) ) )
{
struct in_addr addr;
#endif
+ if ( !ldap_int_hostname )
+ ldap_int_resolve_hostname();
+
if( ldap_int_hostname &&
( !name_in || !strcasecmp( name_in, "localhost" ) ) )
{