From nobody@FreeBSD.org  Tue May 29 18:49:47 2001
Return-Path: <nobody@FreeBSD.org>
Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21])
	by hub.freebsd.org (Postfix) with ESMTP id 99BB737B423
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 29 May 2001 18:49:43 -0700 (PDT)
	(envelope-from nobody@FreeBSD.org)
Received: (from nobody@localhost)
	by freefall.freebsd.org (8.11.1/8.11.1) id f4U1nh048834;
	Tue, 29 May 2001 18:49:43 -0700 (PDT)
	(envelope-from nobody)
Message-Id: <200105300149.f4U1nh048834@freefall.freebsd.org>
Date: Tue, 29 May 2001 18:49:43 -0700 (PDT)
From: seb@strollo.org
To: freebsd-gnats-submit@FreeBSD.org
Subject: pkg_add -r hangs when fetching via ftp
X-Send-Pr-Version: www-1.0

>Number:         27760
>Category:       bin
>Synopsis:       pkg_add -r hangs when fetching via ftp
>Confidential:   no
>Severity:       critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue May 29 18:50:00 PDT 2001
>Closed-Date:    Mon Jun 18 12:06:04 PDT 2001
>Last-Modified:  Mon Jun 18 12:06:43 PDT 2001
>Originator:     Sebastian Strollo
>Release:        4.2-RELEASE
>Organization:
>Environment:
FreeBSD locke 4.2-RELEASE FreeBSD 4.2-RELEASE #0: Fri May  4 10:42:24 PDT 2001  
   seb@locke:/usr/src/sys/compile/IBM_T20  i386

>Description:
When using pkg_add -r to install a package pkg_add just hangs.
>How-To-Repeat:
Run for example this:

  % env FTP_PASSIVE_MODE=1 PACKAGESITE=ftp://ftp5.freebsd.org/pub/FreeBSD/ports/i386/packages-4-stable/All/ pkg_add -v -r xbatt-1.2.1
>Fix:
After a bit of debugging it turns out the fork() that is done to set up
the pipeline for tar doesn't close the file descriptor that is used for
the ftp data channel (I guess there is a bit of a timing issue there,
although for me it occurs every time).

Here is a one line fix to version 1.40.2.5 of the file
/usr/src/usr.sbin/pkg_install/lib/file.c that takes care of the
problem. Feel free to beautify my fix. (The fix is relevant to both
HEAD and RELENG_4). Thanks!

*** file.c.ORIG Tue May 29 17:58:05 2001
--- file.c      Tue May 29 17:58:56 2001
***************
*** 219,224 ****
--- 219,225 ----
        close(pfd[1]);
        dup2(pfd[0], 0);
        close(pfd[0]);
+       { int i; for(i=3; i<NOFILE; i++) close(i); }
        execl("/usr/bin/tar", "tar", Verbose ? "-xzvf" : "-xzf", "-", 0);
        _exit(2);
      }

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->feedback 
State-Changed-By: des 
State-Changed-When: Mon Jun 11 07:18:33 PDT 2001 
State-Changed-Why:  
Similar fix committed to -CURRENT, awaiting MFC. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=27760 
State-Changed-From-To: feedback->closed 
State-Changed-By: des 
State-Changed-When: Mon Jun 18 12:06:04 PDT 2001 
State-Changed-Why:  
MFCed. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=27760 
>Unformatted:
