Always initialize global_host

This commit is contained in:
Howard Chu 2007-02-03 02:53:10 +00:00
parent 4b1bb81452
commit 0787d0c434
2 changed files with 12 additions and 27 deletions

View file

@ -583,28 +583,17 @@ slapd_slp_init( const char* urls )
/* find and expand INADDR_ANY URLs */
for ( i = 0; slapd_srvurls[i] != NULL; i++ ) {
if ( strcmp( slapd_srvurls[i], "ldap:///" ) == 0 ) {
char *host = ldap_pvt_get_fqdn( NULL );
if ( host != NULL ) {
slapd_srvurls[i] = (char *) ch_realloc( slapd_srvurls[i],
strlen( host ) +
sizeof( LDAP_SRVTYPE_PREFIX ) );
strcpy( lutil_strcopy(slapd_srvurls[i],
LDAP_SRVTYPE_PREFIX ), host );
ch_free( host );
}
slapd_srvurls[i] = (char *) ch_realloc( slapd_srvurls[i],
strlen( global_host ) +
sizeof( LDAP_SRVTYPE_PREFIX ) );
strcpy( lutil_strcopy(slapd_srvurls[i],
LDAP_SRVTYPE_PREFIX ), global_host );
} else if ( strcmp( slapd_srvurls[i], "ldaps:///" ) == 0 ) {
char *host = ldap_pvt_get_fqdn( NULL );
if ( host != NULL ) {
slapd_srvurls[i] = (char *) ch_realloc( slapd_srvurls[i],
strlen( host ) +
sizeof( LDAPS_SRVTYPE_PREFIX ) );
strcpy( lutil_strcopy(slapd_srvurls[i],
LDAPS_SRVTYPE_PREFIX ), host );
ch_free( host );
}
slapd_srvurls[i] = (char *) ch_realloc( slapd_srvurls[i],
strlen( global_host ) +
sizeof( LDAPS_SRVTYPE_PREFIX ) );
strcpy( lutil_strcopy(slapd_srvurls[i],
LDAPS_SRVTYPE_PREFIX ), global_host );
}
}

View file

@ -697,6 +697,8 @@ unhandled_option:;
Debug( LDAP_DEBUG_ANY, "%s", Versionstr, 0, 0 );
global_host = ldap_pvt_get_fqdn( NULL );
if( check == CHECK_NONE && slapd_daemon_init( urls ) != 0 ) {
rc = 1;
SERVICE_EXIT( ERROR_SERVICE_SPECIFIC_ERROR, 16 );
@ -830,12 +832,6 @@ unhandled_option:;
}
#endif
#ifdef HAVE_CYRUS_SASL
if( global_host == NULL ) {
global_host = ldap_pvt_get_fqdn( NULL );
}
#endif
(void) SIGNAL( LDAP_SIGUSR1, slap_sig_wake );
(void) SIGNAL( LDAP_SIGUSR2, slap_sig_shutdown );