Bug 502088

Summary: logging files do not get closed on exec
Product: [Fedora] Fedora Reporter: Eric Paris <eparis>
Component: python-virtinstAssignee: Cole Robinson <crobinso>
Status: CLOSED CURRENTRELEASE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: medium    
Version: rawhideCC: berrange, crobinso, dmalcolm, ivazqueznet, james.antill, jforbes, jonathansteffan, markmc, robinlee.sysu, virt-maint
Target Milestone: ---Keywords: Reopened
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-03-28 18:35:10 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: 480594    

Description Eric Paris 2009-05-21 19:32:52 UTC
as root but in running in the selinux context sysadm_t run virt-clone and you will get a couple denials.  The problem is that virt-clone calls out to other programs (like ifconfig) but has not set the virt-clone.log file to be close on exec.  Since ifconfig doesn't (when confined by selinux) has permissions to append to this log file we get the denials.  Mostly likely you need something like below right after you open the log file:

fcntl.fcntl(fd,  fcntl.F_SETFD, fcntl.FD_CLOEXEC)
(or make sure you pass the O_CLOEXEC flag when you open it...)

Comment 1 Daniel Berrangé 2009-05-22 09:48:51 UTC
While I agree that we should be setting FD_CLOEXEC, more important is that we should not be spawning external programs like 'ifconfig' at all. This is a historical hack to workaround lack of suitable APIs in libvirt, but we addressed this problem several releases ago now. The call to ifconfig can be replaced by libvirt API calls to node device APIs to enumerate host network interfaces & their mac addresses.

Comment 2 Bug Zapper 2009-06-09 16:17:13 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 11 development cycle.
Changing version to '11'.

More information and reason for this action is here:
http://fedoraproject.org/wiki/BugZappers/HouseKeeping

Comment 3 Bug Zapper 2010-04-27 14:26:57 UTC
This message is a reminder that Fedora 11 is nearing its end of life.
Approximately 30 (thirty) days from now Fedora will stop maintaining
and issuing updates for Fedora 11.  It is Fedora's policy to close all
bug reports from releases that are no longer maintained.  At that time
this bug will be closed as WONTFIX if it remains open with a Fedora 
'version' of '11'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version prior to Fedora 11's end of life.

Bug Reporter: Thank you for reporting this issue and we are sorry that 
we may not be able to fix it before Fedora 11 is end of life.  If you 
would still like to see this bug fixed and are able to reproduce it 
against a later version of Fedora please change the 'version' of this 
bug to the applicable version.  If you are unable to change the version, 
please add a comment here and someone will do it for you.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events.  Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

The process we are following is described here: 
http://fedoraproject.org/wiki/BugZappers/HouseKeeping

Comment 4 Bug Zapper 2010-06-28 12:38:47 UTC
Fedora 11 changed to end-of-life (EOL) status on 2010-06-25. Fedora 11 is 
no longer maintained, which means that it will not receive any further 
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of 
Fedora please feel free to reopen this bug against that version.

Thank you for reporting this bug and we are sorry it could not be fixed.

Comment 5 Cole Robinson 2010-10-14 16:21:14 UTC
Since we just use the standard python 'logging' module, I think we would need support there to enable close-on-exec. Reassigning to python

Comment 6 Dave Malcolm 2010-10-14 19:38:07 UTC
Can you provide a link to the code that you're using?  In particular, how have you configured "logging" - which handlers are you using.

I notice that "man fopen" has this non-standard mode character:
 "e"(since glibc 2.7)
  Open the file with the O_CLOEXEC flag.  See open(2) for more information.

logging.FileHandler passes on the given mode string to the "open" builtin function when opening the file; _PyFile_SanitizeMode does some checking of this

So could this be solved by adding "e" to the end of the mode string in your logging configuration?

Comment 7 Dave Malcolm 2010-10-14 19:42:46 UTC
Note to self: see also this patch from danpb
  http://lists.xensource.com/archives/html/xen-devel/2006-08/msg00867.html

Comment 8 Cole Robinson 2010-10-14 19:51:23 UTC
Ah, I did not know that mode was passed through to fopen. Thanks for the quick response, I'll assign this back to virtinst and whip up a patch soon.

Comment 9 Bug Zapper 2010-11-04 11:13:14 UTC
This message is a reminder that Fedora 12 is nearing its end of life.
Approximately 30 (thirty) days from now Fedora will stop maintaining
and issuing updates for Fedora 12.  It is Fedora's policy to close all
bug reports from releases that are no longer maintained.  At that time
this bug will be closed as WONTFIX if it remains open with a Fedora 
'version' of '12'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version prior to Fedora 12's end of life.

Bug Reporter: Thank you for reporting this issue and we are sorry that 
we may not be able to fix it before Fedora 12 is end of life.  If you 
would still like to see this bug fixed and are able to reproduce it 
against a later version of Fedora please change the 'version' of this 
bug to the applicable version.  If you are unable to change the version, 
please add a comment here and someone will do it for you.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events.  Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

The process we are following is described here: 
http://fedoraproject.org/wiki/BugZappers/HouseKeeping

Comment 10 Cole Robinson 2010-11-17 18:57:34 UTC
Still present, reassigning to rawhide.

Comment 11 Cole Robinson 2010-11-17 21:05:55 UTC
Fixed upstream:

http://hg.fedorahosted.org/hg/python-virtinst/rev/e07b707b1d94

Comment 12 Cole Robinson 2011-03-28 18:35:10 UTC
This should be in latest rawhide.