You are viewing a plain text version of this content. The canonical link for it is here.
Posted to apache-bugdb@apache.org by James R Grinter <jr...@demon.net> on 1997/02/28 17:10:01 UTC

other/212: Apache attempts to resolve ip addresses in virtualhost declarations

>Number:         212
>Category:       other
>Synopsis:       Apache attempts to resolve ip addresses in virtualhost declarations
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    apache (Apache HTTP Project)
>State:          open
>Class:          sw-bug
>Submitter-Id:   apache
>Arrival-Date:   Fri Feb 28 08:10:01 1997
>Originator:     jrg@demon.net
>Organization:
apache
>Release:        1.2b7
>Environment:
(irix 6.2/cc or gcc - probably irrlevent though...)
>Description:
http_main.c:1501 default_server_hostnames():

This bit of code results in Apache attempting to resolve a declaration
of the form <VirtualHost 10.0.0.1> into a hostname.

                h = gethostbyaddr ((char *)&(s->addrs->host_addr),
                                   sizeof (struct in_addr), AF_INET);
                if (h != NULL)
                    s->server_hostname = pstrdup (pconf, (char *)h->h_name);
                else
                    {
                    fprintf(stderr,"Failed to resolve server name for %s (check
DNS)\n",inet_ntoa(s->addrs->host_addr));
                    exit(0);
                    }

This is a problem - firstly because the whole point of using an ip address
is to workaround possible unavailability or removal of dns outside one's
control. Also, it prevents another section of code (namely being able
to use <VirtualHost 255.255.255.255> as a default section) from working
because that doesn't typically have any dns- one can work around in /etc/hosts
but that's not good for performance reasons.

There's an additional issue with logging - %v in mod_log_config uses
r->server->server_hostname rather than, say, r->hostname if there
was no Host header. Possibly this should be dealt with by an alternative 
value in LogFormat, as someone might want to choose which form they want.
>How-To-Repeat:
Define a virtualhost section with an IP address that has no reverse dns.
Try and restart Apache (or reconfigure with a SIGHUP):

<VirtualHost 127.0.0.2>
DocumentRoot /docs
</VirtualHost>

gives "Failed to resolve server name for 127.0.0.2 (check DNS)"

>Fix:
Remove the lookup altogether. It's bogus. Get s->server_hostname from the
ServerName declaration, if required.

%0
>Audit-Trail:
>Unformatted: