httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "William A. Rowe, Jr." <wr...@lnd.com>
Subject RE: confused about new ServerName logic
Date Thu, 22 Jun 2000 02:29:06 GMT
I don't disagree, but let's tear apart the code in 1.3.13...

#ifdef BEOS /* BeOS returns zero as an error for gethostname */
    if (gethostname(str, sizeof(str) - 1) == 0) {
#else
    if (gethostname(str, sizeof(str) - 1) != 0) {
#endif /* BeOS */
	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");
    }
    else
    {
        str[sizeof(str) - 1] = '\0';
        if ((!(p = gethostbyname(str)))
            || (!(server_hostname = find_fqdn(a, p)))) {
            /* Recovery - return the default servername by IP: */

// Right here we gracefully recover if there isn't a single 'undotted'
// name to be found.  I would be equally happy accepting an 'undotted'
// name if we have one, but failing that... here's our 'real' IP string:

            if (!str && p->h_addr_list[0]) {
                ap_snprintf(str, sizeof(str), "%pA", p->h_addr_list[0]);
	        server_hostname = ap_pstrdup(a, str);
            }
        }
    }

// Massive bummer... gethostname+gethostbyname got us nowhere at all.
// But this way we don't fail to start the server...

    if (!server_hostname)
        server_hostname = ap_pstrdup(a, "127.0.0.1");

// Here's the error... now we need the server_rec as an argument if anything
// is going to land in the log:

    ap_log_error(APLOG_MARK, APLOG_ALERT|APLOG_NOERRNO, NULL,
	         "%s: Missing ServerName directive, assumed host name %s\n",
                 ap_server_argv0, server_hostname);

Somehow, some way they get a ServerName.  Best if it's fully qualified.
Somewhat acceptable if we have an ip string.  I suppose even a local,
undotted name would be preferable to a private ip address.  But failing
all that, they get 127.0.0.1 - so...

On the logic level, what do you want to change?  Add the server_rec and log
it in the right place?  Forewarned... this happens pretty early, and there
may be no logs yet.  There will be logs once (at least under Win32) the conf
is reparsed ín the child.  Since it died before, rather than continuing, Win32
showed no log entries and the service wouldn't start.

Bill

> -----Original Message-----
> From: Jeff Trawick [mailto:trawick@ibm.net]
> Sent: Wednesday, June 21, 2000 9:17 PM
> To: new-httpd@apache.org
> Subject: Re: confused about new ServerName logic
>
>
> > From: "William A. Rowe, Jr." <wrowe@lnd.com>
> > Date: Wed, 21 Jun 2000 14:50:54 -0500
> >
> > Accepted...
>
> Actually, I'm not happy with the original patch I posted.  I don't
> like the way the code is in CVS now, but you convinced me to shift
> some towards your view.
>
> What I really don't like:
>
>   error message on terminal for what I would consider a reasonable
>   configuration (no ServerName, but gethostname(), gethostbyname(),
>   and find_fqdn() all succeed)
>
> My current thought...
>
>   I think it is fine to write a log message whenever we determine the
>   server name.  It should be informational (and only to the log) if
>   for all we know it is a reasonable configuration; it should be an
>   alert or error message (and to the terminal) if we use 127.0.0.1.
>
> > Recognize that the patch does not report the assumption of any
> > other numeric IP as the ServerName, which was the the original
> > reason my original patch was voted down.
>
> In what case do we assume a numeric IP other than 127.0.0.1?
>
> Thanks,
>
> Jeff
>
> --
> Jeff Trawick | trawick@ibm.net | PGP public key at web site:
>      http://www.geocities.com/SiliconValley/Park/9289/
>           Born in Roswell... married an alien...
>


Mime
View raw message