From suresh@frodo.hserus.net  Sat Feb  7 04:00:39 2004
Return-Path: <suresh@frodo.hserus.net>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id CFB3B16A4CE
	for <FreeBSD-gnats-submit@freebsd.org>; Sat,  7 Feb 2004 04:00:39 -0800 (PST)
Received: from frodo.hserus.net (frodo.hserus.net [204.74.68.40])
	by mx1.FreeBSD.org (Postfix) with ESMTP id C502543D1D
	for <FreeBSD-gnats-submit@freebsd.org>; Sat,  7 Feb 2004 04:00:39 -0800 (PST)
	(envelope-from suresh@frodo.hserus.net)
Received: from suresh by frodo.hserus.net with local (Exim 4.30 #0)
	id 1ApR8Y-0009UH-I1 by authid <suresh>
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 07 Feb 2004 17:30:38 +0530
Message-Id: <E1ApR8Y-0009UH-I1@frodo.hserus.net>
Date: Sat, 07 Feb 2004 17:30:38 +0530
From: Suresh Ramasubramanian <suresh@frodo.hserus.net>
To: FreeBSD-gnats-submit@freebsd.org
Subject: mod_perl port does not build with ipv6 enabled apache13-mod_ssl

>Number:         62473
>Category:       ports
>Synopsis:       If apache6 is installed ap-perl compilation fails
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-ports-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Feb 07 04:10:22 PST 2004
>Closed-Date:    Sun Feb 08 14:02:50 PST 2004
>Last-Modified:  Sun Feb 08 14:02:50 PST 2004
>Originator:     Tero Kivinen
>Release:        NetBSD 1.5.1
>Organization:
SSH Communications Security
>Environment:
System: NetBSD fireball.acr.fi 1.5.2 NetBSD 1.5.2 (FIREBALL) #2: Fri Sep 14 19:23:39 EEST 2001 root@fireball.acr.fi:/usr/src/sys/arch/i386/compile/FIREBALL i386

>Description:

If you have www/apache6 installed when you try to compile
ap-perl, the complation fails:
------------------------------------------------------------
cc -DPIC -fPIC -O2 -I/usr/pkg/lib/perl5/5.6.1/i386-netbsd/CORE -fno-strict-aliasing -I/usr/pkg/include  -DMOD_PERL_VERSION=\"1.25\" -DMOD_PERL_STRING_VERSION=\"mod_perl/1.25\" -I/usr/pkg/include/httpd -DMOD_PERL -DNETBSD -DINET6 -Dss_family=__ss_family -Dss_len=__ss_len -DHAVE_SOCKADDR_LEN -I/usr/obj/pkgsrc/www/apache6/work.i386/.buildlink/include -O2 -c Connection.c && mv Connection.o Connection.lo
Connection.c: In function `XS_Apache__Connection_remote_addr':
Connection.c:119: incompatible types in assignment
Connection.c: In function `XS_Apache__Connection_remote_ip':
Connection.c:154: structure has no member named `sin_addr'
*** Error code 1

Stop.
------------------------------------------------------------

>How-To-Repeat:

cd /usr/pkgsrc/www/apache6 && make && make install
cd /usr/pkgsrc/www/ap-perl && make && make install

>Fix:

The first patch is for httpd.h in the apache6 to define
APACHE6 which can then use in the ap-perl module to see if
apache is IPv6 enabled version.

The second patch is for the mod_perl-1.25/apaci/Connection.xs
and it fixes the remote_addr and remote_ip functions.

----------------------------------------------------------------------
--- httpd.h.origFri Nov 23 06:18:50 2001
+++ httpd.hFri Nov 23 10:32:35 2001
@@ -63,6 +63,8 @@
 extern "C" {
 #endif
 
+#define APACHE6 1
+
 /*
  * httpd.h: header for simple (ha! not anymore) http daemon
  */
----------------------------------------------------------------------
--- mod_perl-1.25/apaci/Connection.xs.origFri Nov 23 06:19:44 2001
+++ mod_perl-1.25/apaci/Connection.xsFri Nov 23 10:29:44 2001
@@ -78,7 +78,11 @@
     RETVAL = newSVpv((char *)&conn->remote_addr,
                       sizeof conn->remote_addr);
     if(sv_addr) {
+#ifdef APACHE6
+        struct sockaddr_storage addr;
+#else
         struct sockaddr_in addr; 
+#endif
         STRLEN sockaddrlen; 
         char * new_addr = SvPV(sv_addr,sockaddrlen); 
         if (sockaddrlen != sizeof(addr)) { 
@@ -106,7 +110,26 @@
 #else
         conn->remote_ip = pstrdup(conn->pool, (char *)SvPV(ST(1),na));
 #endif
+#ifdef APACHE6
+{
+  struct addrinfo hints, *res0;
+  int error;
+
+  memset(&hints, 0, sizeof(hints));
+  hints.ai_family = PF_UNSPEC;
+  hints.ai_flags = AI_NUMERICHOST;
+  error = getaddrinfo(conn->remote_ip, NULL, &hints, &res0);
+  if (!error) {
+    memcpy(&conn->remote_addr, res0->ai_addr, res0->ai_addrlen);
+    freeaddrinfo(res0);
+  } else {
+            croak("Bad ip address in remote_ip getaddrinfo failed %s",
		   +  gai_strerror(error)); 
+  }
+}
+#else
         conn->remote_addr.sin_addr.s_addr = inet_addr(conn->remote_ip);
+#endif
     }
 
     OUTPUT:
----------------------------------------------------------------------

After those changes the ap-perl package compiles and seems to
work. 
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: pkg-manager->freebsd-ports-bugs 
Responsible-Changed-By: johan 
Responsible-Changed-When: Sat Feb 7 15:06:16 PST 2004 
Responsible-Changed-Why:  
Apache is in ports. 

NOTE to ports folks, this PR is for NetBSD. 
I'm leaving it open for you to check if the same 
problem exists for FreeBSD ports. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=62473 

From: suresh@frodo.hsreus.net (Suresh Ramasubramanian)
To: freebsd-gnats-submit@FreeBSD.org, suresh@frodo.hserus.net
Cc:  
Subject: Re: ports/62473: If apache6 is installed ap-perl compi
Date: Sun, 08 Feb 2004 09:12:48 +0530

 Note:
 
 I sent in a bug report yesterday about mod_perl on the freebsd ports tree
 failing to compile if apache13-modssl was installed with the ipv6 patch.
 
 I googled around and saw an old netbsd PR dating back to 2001, where ap-perl
 would not compile if apache + ipv6 was installed.
 
 The same error message as I got ... and a suggested patch was included.  So, I
 basically went and pasted the netbsd pr into the "suggested workaround" part.
 That PR is available at
 http://mail-index.netbsd.org/netbsd-bugs/2001/11/23/0007.html
 
 Looks like send-pr seems to have misparsed my report and sent in the old
 netbsd PR (I forgot to quote the netbsd pr fully with >, so that might have
 led to this error)
 
 This is the error I got ...  structure has no member named `sin_addr' -
 because of the lack of v6 support in the mod_perl port.
 
 > >Connection.c
 > cc -DPIC -fPIC -O -pipe -I/usr/local/lib/perl5/5.8.2/mach/CORE
 > -DAPPLLIB_EXP="/usr/local/lib/perl5/5.8.2/BSDPAN" -DHAS_FPSETMASK
 > -DHAS_FLOATINGPOINT_H -fno-strict-aliasing -I/usr/local/include
 > -DMOD_PERL_VERSION=\"1.28\" -DMOD_PERL_STRING_VERSION=\"mod_perl/1.28\"
 > -DMOD_PERL_PREFIX=\"/usr/local/lib/perl5/site_perl/5.8.2/i386-freebsd\"
 > -I/usr/local/include/apache -DMOD_PERL -DHARD_SERVER_LIMIT=512
 > -DDOCUMENT_LOCATION=\"/usr/local/www/data/\"
 > -DDEFAULT_PATH=\"/usr/local/bin:/bin:/usr/bin\"
 > -DACCEPT_FILTER_NAME=\"httpready\" -DFD_SETSIZE=1024 -funsigned-char -DINET6
 > -Dss_family=__ss_family -Dss_len=__ss_len -DHAVE_SOCKADDR_LEN -DMOD_SSL=208116
 > -DEAPI -DEAPI_MM -DUSE_EXPAT -I../lib/expat-lite -O -pipe -O -pipe   -c
 > Connection.c && mv Connection.o Connection.lo
 > Connection.c: In function `XS_Apache__Connection_remote_addr':
 > Connection.c:123: incompatible types in assignment
 > Connection.c: In function `XS_Apache__Connection_remote_ip':
 > Connection.c:159: structure has no member named `sin_addr'
 > *** Error code 1
 >
 >
 > Stop in /usr/ports/www/mod_perl/work/mod_perl-1.28/apaci.
 > *** Error code 1
 >
 > Stop in /usr/ports/www/mod_perl/work/mod_perl-1.28.
 > *** Error code 1
 >
 > Stop in /usr/ports/www/mod_perl.
 >

From: Suresh Ramasubramanian <suresh@hserus.net>
To: freebsd-gnats-submit@FreeBSD.org
Cc:  
Subject: Re: ports/62473: If apache6 is installed ap-perl compi
Date: Sun, 08 Feb 2004 09:33:04 +0530

 resubmitted as ports/62510
State-Changed-From-To: open->closed 
State-Changed-By: linimon 
State-Changed-When: Sun Feb 8 14:02:22 PST 2004 
State-Changed-Why:  
Superceded by ports/62510. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=62473 
>Unformatted:
 If apache6 is installed ap-perl compilation fails
 From: Suresh Ramasubramanian <suresh@frodo.hserus.net>
 Reply-To: Suresh Ramasubramanian <suresh@frodo.hserus.net>
 Cc: 
 X-send-pr-version: 3.113
 X-GNATS-Notify: 
 
 
 >Connection.c
 cc -DPIC -fPIC -O -pipe -I/usr/local/lib/perl5/5.8.2/mach/CORE
 -DAPPLLIB_EXP="/usr/local/lib/perl5/5.8.2/BSDPAN" -DHAS_FPSETMASK
 -DHAS_FLOATINGPOINT_H -fno-strict-aliasing -I/usr/local/include
 -DMOD_PERL_VERSION=\"1.28\" -DMOD_PERL_STRING_VERSION=\"mod_perl/1.28\"
 -DMOD_PERL_PREFIX=\"/usr/local/lib/perl5/site_perl/5.8.2/i386-freebsd\"
 -I/usr/local/include/apache -DMOD_PERL -DHARD_SERVER_LIMIT=512
 -DDOCUMENT_LOCATION=\"/usr/local/www/data/\"
 -DDEFAULT_PATH=\"/usr/local/bin:/bin:/usr/bin\"
 -DACCEPT_FILTER_NAME=\"httpready\" -DFD_SETSIZE=1024 -funsigned-char -DINET6
 -Dss_family=__ss_family -Dss_len=__ss_len -DHAVE_SOCKADDR_LEN -DMOD_SSL=208116
 -DEAPI -DEAPI_MM -DUSE_EXPAT -I../lib/expat-lite -O -pipe -O -pipe   -c
 Connection.c && mv Connection.o Connection.lo
 Connection.c: In function `XS_Apache__Connection_remote_addr':
 Connection.c:123: incompatible types in assignment
 Connection.c: In function `XS_Apache__Connection_remote_ip':
 Connection.c:159: structure has no member named `sin_addr'
 *** Error code 1
 
 
 Stop in /usr/ports/www/mod_perl/work/mod_perl-1.28/apaci.
 *** Error code 1
 
 Stop in /usr/ports/www/mod_perl/work/mod_perl-1.28.
 *** Error code 1
 
 Stop in /usr/ports/www/mod_perl.
 

