From gonter@pcgg.cc.univie.ac.at  Mon Nov 17 17:13:16 2008
Return-Path: <gonter@pcgg.cc.univie.ac.at>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 32E1D106568C
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 17 Nov 2008 17:13:16 +0000 (UTC)
	(envelope-from gonter@pcgg.cc.univie.ac.at)
Received: from pcgg.cc.univie.ac.at (pcgg.cc.univie.ac.at [131.130.2.194])
	by mx1.freebsd.org (Postfix) with ESMTP id A6AAB8FC2B
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 17 Nov 2008 17:13:15 +0000 (UTC)
	(envelope-from gonter@pcgg.cc.univie.ac.at)
Received: from pcgg.cc.univie.ac.at (localhost.cc.univie.ac.at [127.0.0.1])
	by pcgg.cc.univie.ac.at (8.14.3/8.13.4) with ESMTP id mAHGbYvi013533;
	Mon, 17 Nov 2008 17:37:34 +0100 (CET)
	(envelope-from gonter@pcgg.cc.univie.ac.at)
Received: (from root@localhost)
	by pcgg.cc.univie.ac.at (8.14.3/8.13.4/Submit) id mAHGbYVf013532;
	Mon, 17 Nov 2008 17:37:34 +0100 (CET)
	(envelope-from gonter)
Message-Id: <200811171637.mAHGbYVf013532@pcgg.cc.univie.ac.at>
Date: Mon, 17 Nov 2008 17:37:34 +0100 (CET)
From: Gerhard Gonter <g.gonter@ieee.org>
Reply-To: Gerhard Gonter <g.gonter@ieee.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc: Gerhard Gonter <g.gonter@ieee.org>
Subject: Perl module IO::Pty no longer working after upgrading to FreeBSD 6.4-PRERELEASE
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         128941
>Category:       ports
>Synopsis:       devel/p5-IO-Tty: IO::Pty no longer working after upgrading to FreeBSD 6.4-PRERELEASE
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    perl
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Nov 17 17:20:01 UTC 2008
>Closed-Date:    Mon Feb 02 19:25:38 UTC 2009
>Last-Modified:  Mon Feb  2 19:30:09 UTC 2009
>Originator:     Gerhard Gonter
>Release:        FreeBSD 6.4-PRERELEASE i386
>Organization:
me
>Environment:
System: FreeBSD pcgg.cc.univie.ac.at 6.4-PRERELEASE FreeBSD 6.4-PRERELEASE #14: Sun Nov 16 12:24:58 CET 2008 gonter@pcgg.cc.univie.ac.at:/usr/obj/usr/src/sys/GENERIC i386

>Description:
	The Perl module IO::Pty no longer works after upgrading to
	6.4-PRERELEASE.  The machine is following RELENG6 using
	cvsup and was running 6.3 before.  IO::Pty (or rather the
	Perl module Expect) was running fine until the recent
	upgrade.  IO::Pty is included in the distribution of IO::Tty
	and is used by the Perl module Expect.

	Re-installing IO::Tty from ports or from CPAN did not help.

	This also happened on another machine which I upgraded to
	6.4-PRERELEASE today in order to verify the problem.

>How-To-Repeat:
	install from ports devel/p5-IO-Tty and perform this script

	$ perl -e 'use IO::Pty; $x= new IO::Pty;'
	Cannot create a new IO::Tty from fd 4: Bad file descriptor at -e line 1

>Fix:
	No workaround found yet.

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->erwin 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Mon Nov 17 19:04:36 UTC 2008 
Responsible-Changed-Why:  
Make this a ports PR and assign. 

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

From: Gerhard Gonter <g.gonter@ieee.org>
To: bug-followup@FreeBSD.org
Cc: g.gonter@ieee.org
Subject: Re: ports/128941: devel/p5-IO-Tty: IO::Pty no longer working after
 upgrading to FreeBSD 6.4-PRERELEASE
Date: Tue, 18 Nov 2008 05:57:13 +0100

 This is a multi-part message in MIME format.
 --------------040901010501090606030606
 Content-Type: text/plain; charset=ISO-8859-1; format=flowed
 Content-Transfer-Encoding: 7bit
 
 In the meantime, I found a workaround to avoid the current version of 
 unlockpt() which now calls revoke() which in turn may be the reason
 for the misbehaving IO::Tty module.
 
 See [1] for the commit message describing the modification
 of unlockpt() and an excerpt of the typescript which shows how to
 install a modified version of this package.  In order to obtain a
 working lang/p5-Except it is also necessary to install IO::Stty via
 CPAN.
 
 My broken application is now working again, so this problem is no
 longer serious.
 
 Links
 [1] http://docs.freebsd.org/cgi/mid.cgi?200808200943.m7K9hscU044994
 
 GG
 
 --------------040901010501090606030606
 Content-Type: text/plain;
  name="typescript"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: inline;
  filename="typescript"
 
 Script started on Tue Nov 18 05:17:13 2008
 pcgg# make configure
 ===>  Vulnerability check disabled, database not found
 ===>  Extracting for p5-IO-Tty-1.07
 [...]
 Writing IO::Tty::Constant.pm...
 DEFINE = -DHAVE_GRANTPT -DHAVE_LIBUTIL_H -DHAVE_OPENPTY -DHAVE_PTSNAME -DHAVE_SIGACTION -DHAVE_STRLCPY -DHAVE_TERMIOS_H -DHAVE_TTYNAME -DHAVE_UNLOCKPT
 Checking if your kit is complete...
 Looks good
 Writing Makefile for IO::Tty
 pcgg# ex work/IO-Tty-1.07/Makefile
 :g/UNLOCKPT/#
     15  #     DEFINE => q[-DHAVE_GRANTPT -DHAVE_LIBUTIL_H -DHAVE_OPENPTY -DHAVE_PTSNAME -DHAVE_SIGACTION -
 DHAVE_STRLCPY -DHAVE_TERMIOS_H -DHAVE_TTYNAME -DHAVE_UNLOCKPT]
    152  DEFINE = -DHAVE_GRANTPT -DHAVE_LIBUTIL_H -DHAVE_OPENPTY -DHAVE_PTSNAME -DHAVE_SIGACTION -DHAVE_STR
 LCPY -DHAVE_TERMIOS_H -DHAVE_TTYNAME -DHAVE_UNLOCKPT
 :152s/ -DHAVE_UNLOCKPT//
 DEFINE = -DHAVE_GRANTPT -DHAVE_LIBUTIL_H -DHAVE_OPENPTY -DHAVE_PTSNAME -DHAVE_SIGACTION -DHAVE_STRLCPY -DH
 AVE_TERMIOS_H -DHAVE_TTYNAME
 :w
 work/IO-Tty-1.07/Makefile: 984 lines, 28542 characters
 :q
 pcgg# make install
 ===>  Building for p5-IO-Tty-1.07
 [...]
 ===>  Installing for p5-IO-Tty-1.07
 [...]
 ===>   Registering installation for p5-IO-Tty-1.07
 pcgg# perl -e 'use IO::Pty; $x= new IO::Pty;'
 pcgg# 
 Script done on Tue Nov 18 05:19:50 2008
 
 --------------040901010501090606030606--

From: Gerhard Gonter <g.gonter@ieee.org>
To: bug-followup@FreeBSD.org
Cc: g.gonter@ieee.org
Subject: Re: ports/128941: devel/p5-IO-Tty: IO::Pty no longer working after
 upgrading to FreeBSD 6.4-PRERELEASE
Date: Tue, 18 Nov 2008 07:36:54 +0100

 Sorry, I supplied a link for the wrong commit message.  However,
 the change to grantpt.c that I suspect to have broken IO::Pty
 is documented here:
 
 http://www.freebsd.org/cgi/cvsweb.cgi/src/lib/libc/stdlib/Attic/grantpt.c.diff?r1=1.4.2.3;r2=1.4.2.4
 
 GG

From: Ed Schouten <ed@80386.nl>
To: bug-followup@FreeBSD.org, g.gonter@ieee.org
Cc:  
Subject: Re: ports/128941: devel/p5-IO-Tty: IO::Pty no longer working after
	upgrading to FreeBSD 6.4-PRERELEASE
Date: Wed, 21 Jan 2009 09:07:40 +0100

 Hello all,
 
 Mike Silbersack just asked me to take a look at this problem and I just
 figured out what it is. The code is obviously wrong, because it calls
 openpty() to allocate a PTY and open the slave TTY, but it calls
 unlockpt() afterwards, which is bad.
 
 Simple fix: disable HAVE_UNLOCKPT and HAVE_GRANTPT. They should not be
 called when you use openpty().
 
 Best fix: teach p5-IO-Tty to use posix_openpt(). Which is what I did.
 
 What about this patch? Make sure to contact the author of this perl
 module to get it integrated!
 
 %%%
 --- Makefile.PL
 +++ Makefile.PL
 @@ -95,16 +95,17 @@
  
  # checking for various functions
  
 -my %funcs = (ttyname   => "",
 -	     openpty   => "-lutil",
 -	     _getpty   => "",
 -	     strlcpy   => "",
 -	     sigaction => "",
 -	     grantpt   => "",
 -	     unlockpt  => "",
 -	     getpt     => "",
 -	     ptsname   => "",
 -	     ptsname_r => "",
 +my %funcs = (ttyname      => "",
 +	     openpty      => "-lutil",
 +	     _getpty      => "",
 +	     strlcpy      => "",
 +	     sigaction    => "",
 +	     grantpt      => "",
 +	     unlockpt     => "",
 +	     getpt        => "",
 +	     posix_openpt => "",
 +	     ptsname      => "",
 +	     ptsname_r    => "",
  	    );
  
  foreach my $f (sort keys %funcs) {
 @@ -290,7 +291,7 @@
      msg => "WARNING!  Neither ptsname() nor ptsname_r() could be found,\n so we cannot use a high-level interface like openpty().\n",
     },
     {
 -    defines => [qw"-DHAVE_DEV_PTMX -DHAVE_DEV_PTYM_CLONE -DHAVE_DEV_PTC -DHAVE_DEV_PTMX_BSD -DHAVE__GETPTY -DHAVE_OPENPTY -DHAVE_GETPT"],
 +    defines => [qw"-DHAVE_DEV_PTMX -DHAVE_DEV_PTYM_CLONE -DHAVE_DEV_PTC -DHAVE_DEV_PTMX_BSD -DHAVE__GETPTY -DHAVE_OPENPTY -DHAVE_GETPT -DHAVE_POSIX_OPENPT"],
      msg => "No high-level lib or clone device has been found, we will use BSD-style ptys.\n",
     },
    ) {
 --- Tty.xs
 +++ Tty.xs
 @@ -453,6 +453,18 @@
  #if defined(HAVE_PTSNAME) || defined(HAVE_PTSNAME_R)
  /* we don't need to try these if we don't have a way to get the pty names */
  
 +#if defined(HAVE_POSIX_OPENPT)
 +#if PTY_DEBUG
 +	if (print_debug)
 +	  fprintf(stderr, "trying getpt()...\n");
 +#endif
 +	*ptyfd = posix_openpt(O_RDWR|O_NOCTTY);
 +	if (*ptyfd >= 0 && open_slave(ptyfd, ttyfd, namebuf, namebuflen))
 +	    break;		/* got one */
 +	if (PL_dowarn)
 +	    warn("pty_allocate(nonfatal): posix_openpt(): %.100s", strerror(errno));
 +#endif /* defined(HAVE_POSIX_OPENPT) */
 +
  #if defined(HAVE_GETPT)
  	/* glibc defines this */
  #if PTY_DEBUG
 %%%
 
 -- 
  Ed Schouten <ed@80386.nl>
  WWW: http://80386.nl/

From: Ed Schouten <ed@80386.nl>
To: bug-followup@FreeBSD.org, g.gonter@ieee.org
Cc:  
Subject: Re: ports/128941: devel/p5-IO-Tty: IO::Pty no longer working after
	upgrading to FreeBSD 6.4-PRERELEASE
Date: Wed, 21 Jan 2009 09:10:18 +0100

 Small cosmetic bug in the patch:
 
 * Ed Schouten <ed@80386.nl> wrote:
 > +	  fprintf(stderr, "trying getpt()...\n");
 
 This should read:
 
 > +	  fprintf(stderr, "trying posix_openpt()...\n");
 
 -- 
  Ed Schouten <ed@80386.nl>
  WWW: http://80386.nl/

From: Ed Schouten <ed@80386.nl>
To: bug-followup@FreeBSD.org, g.gonter@ieee.org
Cc:  
Subject: Re: ports/128941: devel/p5-IO-Tty: IO::Pty no longer working after
	upgrading to FreeBSD 6.4-PRERELEASE
Date: Wed, 21 Jan 2009 13:01:01 +0100

 --TeJTyD9hb8KJN2Jy
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 Content-Transfer-Encoding: quoted-printable
 
 * Ed Schouten <ed@80386.nl> wrote:
 > What about this patch? Make sure to contact the author of this perl
 > module to get it integrated!
 
 Never mind. I took care of it. The patch has been integrated and the
 maintainer will release a new version.
 
 --=20
  Ed Schouten <ed@80386.nl>
  WWW: http://80386.nl/
 
 --TeJTyD9hb8KJN2Jy
 Content-Type: application/pgp-signature
 Content-Disposition: inline
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.9 (FreeBSD)
 
 iEYEARECAAYFAkl3Dn0ACgkQ52SDGA2eCwV3LwCdHw9XwmSyKBWvmK+YEg09Tpsr
 IPAAn2jODHjWyVmJ983OKXGOR8Uq3Prt
 =gj4B
 -----END PGP SIGNATURE-----
 
 --TeJTyD9hb8KJN2Jy--
Responsible-Changed-From-To: erwin->perl 
Responsible-Changed-By: erwin 
Responsible-Changed-When: Thu Jan 29 17:42:12 UTC 2009 
Responsible-Changed-Why:  
Reassign. 

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

From: Ed Schouten <ed@80386.nl>
To: bug-followup@FreeBSD.org, g.gonter@ieee.org
Cc:  
Subject: Re: ports/128941: devel/p5-IO-Tty: IO::Pty no longer working after
	upgrading to FreeBSD 6.4-PRERELEASE
Date: Mon, 2 Feb 2009 19:20:43 +0100

 * Ed Schouten <ed@80386.nl> wrote:
 > * Ed Schouten <ed@80386.nl> wrote:
 > > What about this patch? Make sure to contact the author of this perl
 > > module to get it integrated!
 > 
 > Never mind. I took care of it. The patch has been integrated and the
 > maintainer will release a new version.
 
 Seems the maintainer is taking a longer time than I had expected. Shall
 I just commit the patch? Still better than leaving the package broken.
 
 -- 
  Ed Schouten <ed@80386.nl>
  WWW: http://80386.nl/
State-Changed-From-To: open->closed 
State-Changed-By: erwin 
State-Changed-When: Mon Feb 2 19:24:57 UTC 2009 
State-Changed-Why:  
I've committed the patch in the port.  It can be removed 
once a new version is released. 

Thanks Gerhard for the report and Ed for creating the fix. 

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

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: ports/128941: commit references a PR
Date: Mon,  2 Feb 2009 19:25:07 +0000 (UTC)

 erwin       2009-02-02 19:24:49 UTC
 
   FreeBSD ports repository
 
   Modified files:
     devel/p5-IO-Tty      Makefile 
   Added files:
     devel/p5-IO-Tty/files patch-Makefile.PL patch-Tty.xs 
   Log:
   Use posix_openpt() instead of calling openpty() to allocate a PTY
   and open the slave TTY, and calling unlockpt() afterwards.
   
   PR:             128941
   Submitted by:   ed
   Reported by:    Gerhard Gonter <g.gonter@ieee.org>
   
   Revision  Changes    Path
   1.20      +1 -0      ports/devel/p5-IO-Tty/Makefile
   1.1       +39 -0     ports/devel/p5-IO-Tty/files/patch-Makefile.PL (new)
   1.1       +21 -0     ports/devel/p5-IO-Tty/files/patch-Tty.xs (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:
