httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wr...@locus.apache.org
Subject cvs commit: apache-2.0/src/main util.c
Date Tue, 20 Jun 2000 19:30:41 GMT
wrowe       00/06/20 12:30:40

  Modified:    src      CHANGES
               src/main util.c
  Log:
      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.162     +6 -0      apache-2.0/src/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/CHANGES,v
  retrieving revision 1.161
  retrieving revision 1.162
  diff -u -r1.161 -r1.162
  --- CHANGES	2000/06/20 10:09:32	1.161
  +++ CHANGES	2000/06/20 19:30:26	1.162
  @@ -1,4 +1,10 @@
   Changes with Apache 2.0a5
  +  *) 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. A warning is always provided if the
  +     ServerName not specified, but assumed.  Solves PR6215 [William Rowe]
  +
     *) Repair problems with config file processing which caused segfault
        at init when virtual hosts were defined and which caused ServerName to
        be ignored when there was no valid DNS setup.  [Jeff Trawick]
  
  
  
  1.58      +25 -11    apache-2.0/src/main/util.c
  
  Index: util.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/main/util.c,v
  retrieving revision 1.57
  retrieving revision 1.58
  diff -u -r1.57 -r1.58
  --- util.c	2000/06/17 16:29:48	1.57
  +++ util.c	2000/06/20 19:30:32	1.58
  @@ -1879,7 +1879,7 @@
   #define MAXHOSTNAMELEN 256
   #endif
       char str[MAXHOSTNAMELEN + 1];
  -    char *server_hostname;
  +    char *server_hostname = NULL;
       struct hostent *p;
   
   #ifdef BEOS
  @@ -1888,19 +1888,33 @@
       if (gethostname(str, sizeof(str) - 1) != 0)
   #endif
       {
  -	perror("Unable to gethostname");
  -	exit(1);
  +        ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_WARNING, 0, NULL,
  +                     "%s: gethostname() failed to detemine ServerName\n",
  +                     ap_server_argv0);
       }
  -    str[MAXHOSTNAMELEN] = '\0';
  -    if ((!(p = gethostbyname(str))) || (!(server_hostname = find_fqdn(a, p)))) {
  -	ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, 
  -                     "%s: cannot determine local host name.",
  -		ap_server_argv0);
  -	ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, 
  -                     "Use the ServerName directive to set it manually.");
  -	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, 0,
  +                 NULL, "%s: Missing ServerName directive in httpd.conf.",
  +                 ap_server_argv0);
  +    ap_log_error(APLOG_MARK, APLOG_ALERT | APLOG_NOERRNO, 0,
  +                 NULL, "%s: assumed ServerName of %s",
  +                 ap_server_argv0, server_hostname);
  +             
       return server_hostname;
   }
   
  
  
  

Mime
View raw message