Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
For bugs related to Red Hat Enterprise Linux 3 product line. The current stable release is 3.9. For Red Hat Enterprise Linux 6 and above, please visit Red Hat JIRA https://issues.redhat.com/secure/CreateIssue!default.jspa?pid=12332745 to report new issues.

Bug 147717

Summary: rpm opens terminal on fd 7/17 for scriptlets
Product: Red Hat Enterprise Linux 3 Reporter: Hal Wine <hal>
Component: rpmAssignee: Paul Nasrat <nobody+pnasrat>
Status: CLOSED ERRATA QA Contact: Mike McLean <mikem>
Severity: medium Docs Contact:
Priority: medium    
Version: 3.0CC: jknaggs, jmoyer, nobody+pnasrat
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: RHBA-2006-0314 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2006-07-20 15:19:24 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:
Bug Depends On:    
Bug Blocks: 181405    
Attachments:
Description Flags
spec file to produce example output
none
rpm-4.2.3-close-script-fd.patch none

Description Hal Wine 2005-02-10 19:40:14 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3)
Gecko/20040913

Description of problem:
after installing a locally built RPM, which started a daemon (that
isn't perfect, but that's a different bug with a different vendor) I
could not cleanly log out of the system.

Investigation showed that the daemon had fd 17 open on the controlling
terminal still.

Further investigation showed that fd 17 had been explicitly opened by RPM.

Version-Release number of selected component (if applicable):
rpm-4.2.3-10

How reproducible:
Always

Steps to Reproduce:
1. make rpm from spec file (attached)
2. show open fd's on terminal before rpm with 
    /usr/bin/lsof -p $$ | grep -w CHR
3. install thenremove rpm & note output
    

Actual Results:  [root@rb482-vmware root]# /usr/sbin/lsof -p $$ | grep
-w CHR
bash    1060 root    0u   CHR  136,0               2 /dev/pts/0
bash    1060 root    1u   CHR  136,0               2 /dev/pts/0
bash    1060 root    2u   CHR  136,0               2 /dev/pts/0
[root@rb482-vmware root]# rpm -Uvh /tmp/fd17-1.0Beta1-0.i386.rpm
Preparing...                ###########################################
[100%]
in pre    for 1.0Beta1: '1'
sh      1164 root    1u   CHR  136,0               2 /dev/pts/0
sh      1164 root    2u   CHR  136,0               2 /dev/pts/0
sh      1164 root    7u   CHR  136,0               2 /dev/pts/0
   1:fd17                   warning: user hwine does not exist - using
root
warning: group hwine does not exist - using root
########################################### [100%]
in post   for 1.0Beta1: '1'
sh      1168 root    1u   CHR  136,0               2 /dev/pts/0
sh      1168 root    2u   CHR  136,0               2 /dev/pts/0
sh      1168 root   17u   CHR  136,0               2 /dev/pts/0
[root@rb482-vmware root]# rpm -e fd17
in preun  for 1.0Beta1: '0'
sh      1175 root    1u   CHR  136,0               2 /dev/pts/0
sh      1175 root    2u   CHR  136,0               2 /dev/pts/0
sh      1175 root    7u   CHR  136,0               2 /dev/pts/0
in postun for 1.0Beta1: '0'
sh      1179 root    1u   CHR  136,0               2 /dev/pts/0
sh      1179 root    2u   CHR  136,0               2 /dev/pts/0
sh      1179 root    7u   CHR  136,0               2 /dev/pts/0
[root@rb482-vmware root]#


Expected Results:  fd 7/17 should not have been explicitly opened by
RPM, _or_ this should be documented somewhere.

Additional info:

Comment 1 Hal Wine 2005-02-10 19:43:31 UTC
Created attachment 110933 [details]
spec file to produce example output

This spec file built the rpm used to produce the output cited above.

Comment 2 Jeff Johnson 2005-02-10 19:59:32 UTC
rpm-4.3.x undertakes closing all file descriptors and above,
as yum and other applications were leaking fdno's through to scriptlets
that restarted daemons.

All those applications need to control for their open descriptors,
it's not rpmlib's job to close open file decriptors that
rpmlib did not open.

And you *really* need to fix your daemon, as any invocation,
not just an invocation from an rpm scriptlet, will pass
descriptors to the dameon. Other file descriptrs may be
much more sensitive than the one that rpm had open when
the scriptlet was invoked (RDONLY on package payload
positioned at EOF iirc).

Comment 3 Hal Wine 2005-02-10 20:31:51 UTC
Please clarify closing. Current release of RHEL is RHEL 3, Update 4,
which has rpm-4.2.3-13.

Are you saying this bug will NOT be fixed for RHEL 3? End of life on
RHEL 3 is still a ways out....

And, this _is_ a file descriptor that rpmlib is explcitly opening
somewhere. (or rpm -- strace shows a 'dup(1)' call in the rpm process
right before the clone call)


Comment 4 Jeff Johnson 2005-02-10 20:42:36 UTC
Nope, sorry. I also maintain 3 other branches of rpm.

Thank you for reopening.



Comment 5 Bastien Nocera 2006-03-02 11:30:00 UTC
Created attachment 125522 [details]
rpm-4.2.3-close-script-fd.patch

Backported from RHEL4's rpm 4.3.3

Comment 6 Bastien Nocera 2006-03-02 11:34:52 UTC
I've tested the patch locally and it seems to do the job.

Comment 8 Jeff Johnson 2006-03-05 12:56:06 UTC
NEEDINFO_ENG so I don't have to stare at ancient history.

Comment 15 Bob Johnson 2006-04-11 16:25:10 UTC
This issue is on Red Hat Engineering's list of planned work items 
for the upcoming Red Hat Enterprise Linux 3.8 release.  Engineering 
resources have been assigned and barring unforeseen circumstances, Red 
Hat intends to include this item in the 3.8 release.

Comment 16 Jeff Moyer 2006-05-09 19:24:31 UTC
*** Bug 191196 has been marked as a duplicate of this bug. ***

Comment 19 Red Hat Bugzilla 2006-07-20 15:19:24 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on the solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2006-0314.html