From bz@zabbadoz.net  Sun Feb  8 21:30:36 2009
Return-Path: <bz@zabbadoz.net>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 4A6641065675
	for <freebsd-gnats-submit@freebsd.org>; Sun,  8 Feb 2009 21:30:26 +0000 (UTC)
	(envelope-from bz@zabbadoz.net)
Received: from mail.cksoft.de (mail.cksoft.de [62.111.66.27])
	by mx1.freebsd.org (Postfix) with ESMTP id 9D2318FC1B
	for <freebsd-gnats-submit@freebsd.org>; Sun,  8 Feb 2009 21:30:25 +0000 (UTC)
	(envelope-from bz@zabbadoz.net)
Received: from localhost (amavis.str.cksoft.de [192.168.74.71])
	by mail.cksoft.de (Postfix) with ESMTP id 3E3CA41C710
	for <freebsd-gnats-submit@freebsd.org>; Sun,  8 Feb 2009 22:15:06 +0100 (CET)
Received: from mail.cksoft.de ([62.111.66.27])
	by localhost (amavis.str.cksoft.de [192.168.74.71]) (amavisd-new, port 10024)
	with ESMTP id 6WB4DSjjjP-i for <freebsd-gnats-submit@freebsd.org>;
	Sun,  8 Feb 2009 22:15:05 +0100 (CET)
Received: by mail.cksoft.de (Postfix, from userid 66)
	id 62A0041C70C; Sun,  8 Feb 2009 22:15:05 +0100 (CET)
Received: from storage.int.zabbadoz.net (storage.int.zabbadoz.net [10.111.66.189])
	by mail.int.zabbadoz.net (Postfix) with ESMTP id 21A394448EC;
	Sun,  8 Feb 2009 21:13:49 +0000 (UTC)
Received: by storage.int.zabbadoz.net (Postfix, from userid 1060)
	id 056874899B6; Sun,  8 Feb 2009 21:13:49 +0000 (UTC)
Message-Id: <20090208211349.056874899B6@storage.int.zabbadoz.net>
Date: Sun,  8 Feb 2009 21:13:49 +0000 (UTC)
From: "Bjoern A. Zeeb" <bzeeb+freebsdports@zabbadoz.net>
Reply-To: "Bjoern A. Zeeb" <bzeeb+freebsdports@zabbadoz.net>
To: FreeBSD-gnats-submit@freebsd.org
Cc: "Bjoern A. Zeeb" <bzeeb+freebsdports@zabbadoz.net>
Subject: [patch] unbreak sysutils/p5-BSD-Jail-Object after jail MFC
X-Send-Pr-Version: 3.113
X-GNATS-Notify: mahlon@martini.nu

>Number:         131513
>Category:       ports
>Synopsis:       [patch] unbreak sysutils/p5-BSD-Jail-Object after jail MFC
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    rafan
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          update
>Submitter-Id:   current-users
>Arrival-Date:   Sun Feb 08 21:40:04 UTC 2009
>Closed-Date:    Sun Mar 22 06:42:56 UTC 2009
>Last-Modified:  Sun Mar 22 06:50:01 UTC 2009
>Originator:     Bjoern A. Zeeb
>Release:        FreeBSD 7-STABLE amd64
>Organization:
Zabbadoz.NeT
>Environment:

>Description:
	The MFC of multi-IPv4/v6/no-IP jails broke the API as it had
	for the commit to HEAD end of last year.

>How-To-Repeat:
	Build the port on an up-to-date stable or head and it will fail.

>Fix:
	I had sent this patch out after the commit to HEAD but it seems
	it hasn't made it into ports. This is an updated version.
	It still is what the comment in the patch says.

	Note: new file in not yet existent directory files/:
	files/patch-Object.pm

Index: Makefile
===================================================================
RCS file: /shared/mirror/FreeBSD/r/pcvs/ports/sysutils/p5-BSD-Jail-Object/Makefile,v
retrieving revision 1.5
diff -u -p -r1.5 Makefile
--- Makefile	8 Jan 2009 18:08:08 -0000	1.5
+++ Makefile	8 Feb 2009 17:00:45 -0000
@@ -7,6 +7,7 @@
 
 PORTNAME=	BSD-Jail-Object
 PORTVERSION=	0.02
+PORTREVISION=	1
 CATEGORIES=	sysutils perl5
 MASTER_SITES=	CPAN
 PKGNAMEPREFIX=	p5-
@@ -21,10 +22,4 @@ PERL_CONFIGURE=	5.8.6+
 
 MAN3=		BSD::Jail::Object.3
 
-.include <bsd.port.pre.mk>
-
-.if ${OSVERSION} >= 800056
-BROKEN=		does not build
-.endif
-
-.include <bsd.port.post.mk>
+.include <bsd.port.mk>
Index: files/patch-Object.pm
===================================================================
RCS file: files/patch-Object.pm
diff -N files/patch-Object.pm
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ files/patch-Object.pm	8 Feb 2009 17:00:45 -0000
@@ -0,0 +1,149 @@
+! 
+! - Plug a memory used after free.
+! - Try to make things work basically with modern jails
+!   (read "make work" as "compile").
+!   Ideally one would change the internal API and return arrayrefs
+!   of IPs per address family as well as jailname, ... for the new
+!   version and keep compat. Most likely one would need to keep the
+!   version information along with the cached data.
+!   Look at usr.sbin/{jail,jls,jexec} sources for the right ideas.
+! 
+--- ./Object.pm.orig	2006-08-08 04:54:29.000000000 +0000
++++ ./Object.pm	2008-12-28 14:06:27.000000000 +0000
+@@ -317,21 +317,69 @@
+         return NULL;
+     }
+ 
+-    free( sxp );
+     return xp;
+ }
+ 
++static int
++_is_jail_ip4(char *string, struct xprison *xp)
++{
++	struct in_addr in;
++#if ((__FreeBSD_version >= 800056) || (__FreeBSD_version < 800000) && (__FreeBSD_version >= 701103))
++	struct in_addr *iap;
++	char *q;
++	int i;
++#endif
++
++	if (inet_pton(AF_INET, string, &in) != 1)
++		return (0);
++	
++#if ((__FreeBSD_version >= 800000 && __FreeBSD_version < 800056) || __FreeBSD_version < 701103)
++	if (in.s_addr == xp->pr_ip) {
++		return (1);
++#else
++	if (xp->pr_ip4s == 0)
++		return (0);
++	q = (char *)(xp + 1);
++	iap = (struct in_addr *)(void *)q;
++	for (i=0; i < xp->pr_ip4s; i++)
++		if (in.s_addr == iap[i].s_addr)
++			return (1);
++#endif
++	return (0);
++}
++
++static void
++_get_jail_ip4(struct xprison *xp, struct in_addr *ia)
++{
++#if ((__FreeBSD_version >= 800056) || (__FreeBSD_version < 800000) && (__FreeBSD_version >= 701103))
++	struct in_addr *iap;
++	char *q;
++#endif
++
++#if ((__FreeBSD_version >= 800000 && __FreeBSD_version < 800056) || __FreeBSD_version < 701103)
++	ia->s_addr = xp->pr_ip;
++#else
++	if (xp->pr_ip4s == 0)
++		ia->s_addr = 0;
++	else {
++		q = (char *)(xp + 1);
++		iap = (struct in_addr *)(void *)q;
++		ia->s_addr = iap[0].s_addr;
++	}
++#endif
++}
++
+ // fetch a specific jail's information
+ void
+ _find_jail( int compare, char *string )
+ { 
+-    struct xprison *xp;
++    struct xprison *sxp, *xp;
+     struct in_addr in;
+     size_t i, len;
+     Inline_Stack_Vars;
+ 
+     Inline_Stack_Reset;
+-    xp  = get_xp();
++    sxp = xp  = get_xp();
+     len = sysctl_len();
+ 
+     /*
+@@ -341,15 +389,15 @@
+     */
+ 
+     for (i = 0; i < len / sizeof(*xp); i++) {
+-        in.s_addr = ntohl(xp->pr_ip);
+         if (
+                 ( compare == 0 && xp->pr_id == atoi(string) )
+                 ||
+-                ( compare == 1 && strcmp( string, inet_ntoa(in) ) == 0 )
++                ( compare == 1 && _is_jail_ip4(string, xp) )
+                 ||
+                 ( compare == 2 && strcmp( string, xp->pr_host ) == 0 )
+            ) {
+             Inline_Stack_Push( sv_2mortal( newSViv( xp->pr_id ) ));
++	    _get_jail_ip4(xp, &in);
+             Inline_Stack_Push( sv_2mortal( newSVpvf( inet_ntoa(in) ) ));
+             Inline_Stack_Push( sv_2mortal( newSVpvf( xp->pr_host ) ));
+             Inline_Stack_Push( sv_2mortal( newSVpvf( xp->pr_path ) ));
+@@ -360,6 +408,7 @@
+         }
+     }
+ 
++    free ( sxp );
+     Inline_Stack_Done;
+ }
+ 
+@@ -367,12 +416,12 @@
+ void
+ _find_jids()
+ { 
+-    struct xprison *xp;
++    struct xprison *sxp, *xp;
+     size_t i, len;
+     Inline_Stack_Vars;
+ 
+     Inline_Stack_Reset;
+-    xp  = get_xp();
++    sxp = xp  = get_xp();
+     len = sysctl_len();
+ 
+     for (i = 0; i < len / sizeof(*xp); i++) {
+@@ -380,6 +429,7 @@
+         xp++;
+     }
+ 
++    free ( sxp );
+     Inline_Stack_Done;
+ }
+ 
+@@ -402,8 +452,14 @@
+     
+     j.path      = path;
+     j.hostname  = hostname;
++#if ((__FreeBSD_version >= 800000 && __FreeBSD_version < 800056) || __FreeBSD_version < 701103)
+     j.ip_number = ntohl( ip.s_addr );
+     j.version   = 0;
++#else
++    j.version   = JAIL_API_VERSION;
++    j.ip4s	= 1;
++    j.ip4	= &ip;
++#endif
+ 
+     if ( (jid = jail( &j )) == -1 ) return 0;
+ 
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->feedback 
State-Changed-By: edwin 
State-Changed-When: Sun Feb 8 21:40:29 UTC 2009 
State-Changed-Why:  
Awaiting maintainers feedback (via the GNATS Auto Assign Tool) 

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

From: Edwin Groothuis <edwin@FreeBSD.org>
To: mahlon@martini.nu
Cc: bug-followup@FreeBSD.org
Subject: Re: ports/131513: [patch] unbreak sysutils/p5-BSD-Jail-Object after jail MFC
Date: Sun, 8 Feb 2009 21:40:27 UT

 Maintainer of sysutils/p5-BSD-Jail-Object,
 
 Please note that PR ports/131513 has just been submitted.
 
 If it contains a patch for an upgrade, an enhancement or a bug fix
 you agree on, reply to this email stating that you approve the patch
 and a committer will take care of it.
 
 The full text of the PR can be found at:
     http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/131513
 
 -- 
 Edwin Groothuis via the GNATS Auto Assign Tool
 edwin@FreeBSD.org

From: "Mahlon E. Smith" <mahlon@martini.nu>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: ports/131513: [patch] unbreak sysutils/p5-BSD-Jail-Object
	after jail MFC
Date: Mon, 9 Feb 2009 08:37:25 -0800

 --UugvWAfsgieZRqgk
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 Content-Transfer-Encoding: quoted-printable
 
 On Sun, Feb 08, 2009, Edwin Groothuis wrote:
 > Maintainer of sysutils/p5-BSD-Jail-Object,
 >=20
 > Please note that PR ports/131513 has just been submitted.
 >=20
 > If it contains a patch for an upgrade, an enhancement or a bug fix
 > you agree on, reply to this email stating that you approve the patch
 > and a committer will take care of it.
 >=20
 > The full text of the PR can be found at:
 >     http://www.freebsd.org/cgi/query-pr.cgi?pr=3Dports/131513
 
 
 Yo!
 
 I have -not- had the opportunity to test this personally yet (need to
 set up a -stable environment), but at a cursory glance the code looks
 solid.  If Bjoern has been able to use it successfully, I'm fine with
 it.
 
 I should be able to dedicate some time to it in the coming couple of
 weeks, and can make any changed (if required) then.
 
 Thanks Edwin (and Bjoern as well)!
 
 -Mahlon
 
 --
 Mahlon E. Smith =20
 http://www.martini.nu/contact.html
 
 --UugvWAfsgieZRqgk
 Content-Type: application/pgp-signature
 Content-Disposition: inline
 
 -----BEGIN PGP SIGNATURE-----
 
 iD8DBQFJkFvE1bsjBDapbeMRArZQAKCnZBSt2vt9FvJ/2uU83fgugqMp8QCfVh8N
 t6bu40JJEwLO5WwkEIQt4aE=
 =k5NZ
 -----END PGP SIGNATURE-----
 
 --UugvWAfsgieZRqgk--
Responsible-Changed-From-To: freebsd-ports-bugs->miwi 
Responsible-Changed-By: miwi 
Responsible-Changed-When: Wed Feb 11 22:09:44 UTC 2009 
Responsible-Changed-Why:  
I'll take it. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=131513 
Responsible-Changed-From-To: miwi->rafan 
Responsible-Changed-By: rafan 
Responsible-Changed-When: Sun Mar 22 06:40:35 UTC 2009 
Responsible-Changed-Why:  
I'll take it. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=131513 
State-Changed-From-To: feedback->closed 
State-Changed-By: rafan 
State-Changed-When: Sun Mar 22 06:42:55 UTC 2009 
State-Changed-Why:  
Committed. Thanks! 

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

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: ports/131513: commit references a PR
Date: Sun, 22 Mar 2009 06:43:02 +0000 (UTC)

 rafan       2009-03-22 06:42:48 UTC
 
   FreeBSD ports repository
 
   Modified files:
     sysutils/p5-BSD-Jail-Object Makefile 
   Added files:
     sysutils/p5-BSD-Jail-Object/files patch-Object.pm 
   Log:
   - Fix build after multi-IPv4/v6/no-IP jail MFC
   
   PR:             ports/131513
   Submitted by:   bz@
   Approved by:    maintainer timeout (1 month)
   
   Revision  Changes    Path
   1.6       +2 -7      ports/sysutils/p5-BSD-Jail-Object/Makefile
   1.1       +149 -0    ports/sysutils/p5-BSD-Jail-Object/files/patch-Object.pm (new)
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 
>Unformatted:
