Subject: pkg/14693: apache6 and ap-perl does not compile together
To: None <gnats-bugs@gnats.netbsd.org>
From: None <kivinen@ssh.fi>
List: netbsd-bugs
Date: 11/23/2001 12:08:26
>Number:         14693
>Category:       pkg
>Synopsis:       If apache6 is installed ap-perl compilation fails
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Nov 23 02:09:00 PST 2001
>Closed-Date:
>Last-Modified:
>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.orig	Fri Nov 23 06:18:50 2001
+++ httpd.h	Fri 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.orig	Fri Nov 23 06:19:44 2001
+++ mod_perl-1.25/apaci/Connection.xs	Fri 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:
>Unformatted: