You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by wr...@locus.apache.org on 2000/06/15 15:44:56 UTC

cvs commit: apache-1.3/src/main util.c

wrowe       00/06/15 06:44:54

  Modified:    conf     httpd.conf-dist-win
               src/main util.c
  Log:
    Restore httpd.conf-dist-win ServerName to the same state as the
    stock .conf-dist version.
  
    Correct the problem where the only local host name that the IP stack
    can discover are 'undotted' private names.  If no fully qualified
    domain name can be identified, the default ServerName will be set to
    the machine's IP address string.
  
  Revision  Changes    Path
  1.41      +2 -1      apache-1.3/conf/httpd.conf-dist-win
  
  Index: httpd.conf-dist-win
  ===================================================================
  RCS file: /home/cvs/apache-1.3/conf/httpd.conf-dist-win,v
  retrieving revision 1.40
  retrieving revision 1.41
  diff -u -r1.40 -r1.41
  --- httpd.conf-dist-win	2000/06/08 14:25:16	1.40
  +++ httpd.conf-dist-win	2000/06/15 13:44:46	1.41
  @@ -248,7 +248,8 @@
   # You will have to access it by its address (e.g., http://123.45.67.89/)
   # anyway, and this will make redirections work in a sensible way.
   #
  -ServerName 127.0.0.1
  +#ServerName new.host.name
  +
   
   #
   # DocumentRoot: The directory out of which you will serve your
  
  
  
  1.183     +23 -9     apache-1.3/src/main/util.c
  
  Index: util.c
  ===================================================================
  RCS file: /home/cvs/apache-1.3/src/main/util.c,v
  retrieving revision 1.182
  retrieving revision 1.183
  diff -u -r1.182 -r1.183
  --- util.c	2000/03/13 21:00:40	1.182
  +++ util.c	2000/06/15 13:44:49	1.183
  @@ -1976,7 +1976,7 @@
   #define MAXHOSTNAMELEN 256
   #endif
       char str[MAXHOSTNAMELEN];
  -    char *server_hostname;
  +    char *server_hostname = NULL;
       struct hostent *p;
   
   #ifdef BEOS /* BeOS returns zero as an error for gethostname */
  @@ -1984,17 +1984,31 @@
   #else    
       if (gethostname(str, sizeof(str) - 1) != 0) {
   #endif /* BeOS */
  -	perror("Unable to gethostname");
  -	exit(1);
  +	ap_log_error(APLOG_MARK, APLOG_WARNING, NULL,
  +	             "%s: gethostname() failed to detemine ServerName\n",
  +                     ap_server_argv0);
  +	server_hostname = ap_pstrdup(a, "127.0.0.1");
       }
  -    str[sizeof(str) - 1] = '\0';
  -    if ((!(p = gethostbyname(str))) || (!(server_hostname = find_fqdn(a, p)))) {
  -	fprintf(stderr, "%s: cannot determine local host name.\n",
  -		ap_server_argv0);
  -	fprintf(stderr, "Use the ServerName directive to set it manually.\n");
  -	exit(1);
  +    else 
  +    {
  +        str[sizeof(str) - 1] = '\0';
  +        if ((!(p = gethostbyname(str))) 
  +            || (!(server_hostname = find_fqdn(a, p)))) {
  +            /* Recovery - return the default servername by IP: */
  +            if (!str && p->h_addr_list[0]) {
  +                ap_snprintf(str, sizeof(str), "%pA", p->h_addr_list[0]);
  +	        server_hostname = ap_pstrdup(a, str);
  +            }
  +        }
       }
   
  +    if (!server_hostname) 
  +        server_hostname = ap_pstrdup(a, "127.0.0.1");
  +    
  +    ap_log_error(APLOG_MARK, APLOG_ALERT|APLOG_NOERRNO, NULL,
  +	         "%s: Missing ServerName directive, assumed host name %s\n",
  +                 ap_server_argv0, server_hostname);
  +    
       return server_hostname;
   }