]> git.sur5r.net Git - openldap/commitdiff
Always initialize global_host
authorHoward Chu <hyc@openldap.org>
Sat, 3 Feb 2007 02:53:10 +0000 (02:53 +0000)
committerHoward Chu <hyc@openldap.org>
Sat, 3 Feb 2007 02:53:10 +0000 (02:53 +0000)
servers/slapd/daemon.c
servers/slapd/main.c

index e215347f4c15156c13dbe842a365470f34ac5752..9f86d3d13035d64fe8cf4aec1f7afd065ed3627e 100644 (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 );
                }
        }
 
index 1b653c6d51caf6d465ec458cd3769186e15d7ee5..b18b8e0e07fd1c11cfff66556160bab076c48ea5 100644 (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 );