You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Brad Nicholes <BN...@novell.com> on 2003/08/13 23:14:40 UTC

Re: cvs commit: httpd-2.0/server listen.c

This change causes a problem on NetWare.  In the function
alloc_listener() before the change,  the code did not allow the variable
addr to be NULL.  In the changed code addr is allowed to be NULL which
means that the call to strcmp() after the call to
apr_sockaddr_port_get() causes NetWare to fault.

Brad

Brad Nicholes
Senior Software Engineer
Novell, Inc., the leading provider of Net business solutions
http://www.novell.com 

>>> jerenkrantz@apache.org Wednesday, August 13, 2003 1:17:45 PM >>>
jerenkrantz    2003/08/13 12:17:45

  Modified:    .        CHANGES
               server   listen.c
  Log:
  Correct failure with Listen directives on machines with IPv6 enabled
by
  removing find_default_family() and letting APR determine what should
be done
  without a hostname.
  
  This patch requires the corollary APR patch to properly call
getaddrinfo().
  
  (Justin modified Colm's patch to always walk the old listeners even
when
  we have an address.  That part of the patch wasn't really relevant.)
  
  Submitted by:	Colm MacC�rthaigh <co...@stdlib.net>
  Reviewed by:	Justin Erenkrantz
  
  Revision  Changes    Path
  1.1251    +3 -0      httpd-2.0/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/CHANGES,v
  retrieving revision 1.1250
  retrieving revision 1.1251
  diff -u -u -r1.1250 -r1.1251
  --- CHANGES	12 Aug 2003 21:02:00 -0000	1.1250
  +++ CHANGES	13 Aug 2003 19:17:45 -0000	1.1251
  @@ -2,6 +2,9 @@
   
     [Remove entries to the current 2.0 section below, when
backported]
   
  +  *) Correct failure with Listen directives on machines with IPv6
enabled.
  +     [Colm MacC�rthaigh <co...@stdlib.net>, Justin Erenkrantz]
  +  
     *) Fix a link failure in mod_ssl when the OpenSSL libraries
contain
        the ENGINE functions but the engine header files are missing.
        [Cliff Woolley]
  
  
  
  1.87      +0 -50     httpd-2.0/server/listen.c
  
  Index: listen.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/listen.c,v
  retrieving revision 1.86
  retrieving revision 1.87
  diff -u -u -r1.86 -r1.87
  --- listen.c	31 Mar 2003 04:30:38 -0000	1.86
  +++ listen.c	13 Aug 2003 19:17:45 -0000	1.87
  @@ -235,38 +235,6 @@
   }
   
   
  -static void find_default_family(apr_pool_t *p)
  -{
  -#if APR_HAVE_IPV6
  -    /* We know the platform supports IPv6, but this particular
  -     * system may not have IPv6 enabled.  See if we can get an
  -     * AF_INET6 socket and bind to an ephemeral port.  (On most
  -     * systems, getting an AF_INET6 socket is a sufficient test.
  -     * On certain levels of OpenUNIX, getting the socket is
  -     * successful but bind always returns ENETUNREACH.)
  -     */
  -    if (default_family == APR_UNSPEC) {
  -        apr_status_t sock_rv;
  -        apr_socket_t *tmp_sock;
  -        apr_sockaddr_t *sa;
  -
  -        if ((sock_rv = apr_socket_create(&tmp_sock, APR_INET6,
SOCK_STREAM, p)) 
  -            == APR_SUCCESS &&
  -            apr_sockaddr_info_get(&sa, NULL, APR_INET6, 0, 0, p) ==
APR_SUCCESS &&
  -            apr_bind(tmp_sock, sa) == APR_SUCCESS) { 
  -            default_family = APR_INET6;
  -        }
  -        else {
  -            default_family = APR_INET;
  -        }
  -        if (sock_rv == APR_SUCCESS) {
  -            apr_socket_close(tmp_sock);
  -        }
  -    }
  -#endif
  -}
  -
  -
   static const char *alloc_listener(process_rec *process, char *addr,
apr_port_t port)
   {
       ap_listen_rec **walk;
  @@ -274,24 +242,6 @@
       apr_status_t status;
       apr_port_t oldport;
       apr_sockaddr_t *sa;
  -
  -    if (!addr) { /* don't bind to specific interface */
  -        find_default_family(process->pool);
  -        switch(default_family) {
  -        case APR_INET:
  -            addr = "0.0.0.0";
  -            break;
  -
  -#if APR_HAVE_IPV6
  -        case APR_INET6:
  -            addr = "::";
  -            break;
  -#endif
  -
  -        default:
  -            ap_assert(1 != 1); /* should not occur */
  -        }
  -    }
   
       /* see if we've got an old listener for this address:port */
       for (walk = &old_listeners; *walk; walk = &(*walk)->next) {
  
  
  

Re: cvs commit: httpd-2.0/server listen.c

Posted by Justin Erenkrantz <ju...@erenkrantz.com>.
--On Wednesday, August 13, 2003 15:14:40 -0600 Brad Nicholes 
<BN...@novell.com> wrote:

> This change causes a problem on NetWare.  In the function
> alloc_listener() before the change,  the code did not allow the variable
> addr to be NULL.  In the changed code addr is allowed to be NULL which
> means that the call to strcmp() after the call to
> apr_sockaddr_port_get() causes NetWare to fault.

Hmm.  Now, I wonder how reliant we are upon the sockaddr_t having a 
non-NULL hostname field.  Are we going to be allowed to leave it NULL? 
apr_sockaddr_info_get's documentation explicitly says it allows NULL 
inputs, but it doesn't say what the 'hostname' field will turn into.

The IPv4 apr_sockaddr_info_get impl. just hardcodes sa->hostname to be 
"0.0.0.0", while the IPv6 branch (getaddrinfo impl) will leave it NULL. 
So, we may not reuse listeners on IPv4 right now (NULL gets translated into 
"0.0.0.0" and stored as that string in the sockaddr_t).  I guess I'll 
prefer to have the hostname be what we passed into apr_sockaddr_info_get - 
that is the sa->hostname should be NULL even with IPv4 implementations.

Then, we'll have to fix up the references to sa->hostname to allow for NULL 
values.

Thoughts?  Make sense?  -- justin