Bug 138862

Summary: %post scripts inherit dup'd stdout (FD_CLOEXEC needed)
Product: Red Hat Enterprise Linux 3 Reporter: Michael J. Pomraning <mjp-rhbug>
Component: rpmAssignee: Panu Matilainen <pmatilai>
Status: CLOSED WONTFIX QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 3.0CC: nobody+pnasrat
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2007-10-19 19:14:20 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Michael J. Pomraning 2004-11-11 17:35:30 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.5)
Gecko/20041107 Firefox/1.0

Description of problem:
Capturing the output of an rpm installation (backticking `rpm ...` in
shell or perl, for example) may hang indefinitely if rpm's %post
script launches a long-running process -- even if that process closes
it's stdout.

%post scripts (and perhaps others, too) inherit a dup'd copy of their
stdout.

Version-Release number of selected component (if applicable):
rpm-4.2.2-0.14

How reproducible:
Always

Steps to Reproduce:
1.  Make a dummy RPM (no source, no files) with the following:
    %post
    sleep 10 >/dev/null &
    ls -l /proc/$$/fd > /tmp/fdtest-post.$$

2.  Build the rpm, and install it under backticks
    # FOO=`rpm -Uhv dummyrpm...`

3.  Inspect the resultant /tmp/fdtest-post.$$ file

Actual Results:  /tmp/fdtest-post.$$ contained:

total 0
lr-x------    1 root     root           64 Nov 11 11:13 0 -> pipe:[181105]
l-wx------    1 root     root           64 Nov 11 11:13 1 -> pipe:[181081]
l-wx------    1 root     root           64 Nov 11 11:13 14 ->
pipe:[181081]
lrwx------    1 root     root           64 Nov 11 11:13 2 -> /dev/pts/3
lr-x------    1 root     root           64 Nov 11 11:13 255 ->
/var/tmp/rpm-tmp.57281

also, $FOO assignment took about 10 seconds.

Expected Results:  /tmp/fdtest-post.$$ should not have had shown a
line for a dup of fd 1 (fd 14, in the "Actual Results").  $FOO
assignment should have taken no longer than it takes for the rpm
command to exit.

Additional info:

Comment 1 Jeff Johnson 2006-01-20 03:23:43 UTC
This is fixed in rpm-4.3.x, all open file desciptors 3->100 are closed.

Comment 2 David Lawrence 2006-04-18 20:15:25 UTC
NEEDINFO_ENG has been deprecated in favor of NEEDINFO or ASSIGNED. Changing
status to ASSIGNED for ENG review.

Comment 3 RHEL Program Management 2007-10-19 19:14:20 UTC
This bug is filed against RHEL 3, which is in maintenance phase.
During the maintenance phase, only security errata and select mission
critical bug fixes will be released for enterprise products. Since
this bug does not meet that criteria, it is now being closed.
 
For more information of the RHEL errata support policy, please visit:
http://www.redhat.com/security/updates/errata/
 
If you feel this bug is indeed mission critical, please contact your
support representative. You may be asked to provide detailed
information on how this bug is affecting you.