Bug 1657448 - upsmon and upssched leak file descriptors to spawned processes
Summary: upsmon and upssched leak file descriptors to spawned processes
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: nut
Version: 29
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Michal Hlavinka
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-12-08 09:03 UTC by Scott Shambarger
Modified: 2019-04-06 20:18 UTC (History)
1 user (show)

Fixed In Version: nut-2.7.4-23.fc28 nut-2.7.4-23.fc29 nut-2.7.4-23.fc30
Clone Of:
Environment:
Last Closed: 2019-04-06 19:21:34 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
Patch to set cloexec flags on upsmon and upssched file descriptors (1.88 KB, patch)
2018-12-08 09:03 UTC, Scott Shambarger
no flags Details | Diff

Description Scott Shambarger 2018-12-08 09:03:38 UTC
Created attachment 1512763 [details]
Patch to set cloexec flags on upsmon and upssched file descriptors

Description of problem:
I have upssched (spawned from upsmon) setup to call a script that sends
mail when an interesting even occurs.  I was getting SELinux violations with sendmail being denied read access to /etc/ups/upssched.conf... tracked down the problem to the configuration file descriptor being leaked to my script on fd4, and then read by sendmail.

I found that upsmon was leaking descriptors to upssched (which could be a user script instead), and upssched was leaking even more to it's spawned processes.

I've created a patch to add FD_CLOEXEC flags to all the files, pipes and sockets opened by upsmon and upssched so that the spawned processes only receive the normal stdio fds.

I've also submitted the patch upstream, so hopefully will be fixed in the next release.  But it does create very difficult to track down SELinux messages, so I figure it's worth submitting a bug here to fix those.

Version-Release number of selected component (if applicable):
nut-2.7.4-19

How reproducible:
Whenever upsmon spawns a NOTIFYCMD or upssched spawns a CMDSCRIPT

Steps to Reproduce:
1. Create a script, and set NOTIFYCMD or CMDSCRIPT to run it
2. Create an event that triggers the script.

Actual results:
Examine the output of ls -l /proc/$$/fd in the script and
see the leaked file descriptors - you could also run:
 echo test | mail -s test myemail@domain
 and sendmail (postfix version at least) will generate SELinux violations.

Expected results:
No leaked descriptors, no SELinux violations.

Additional info:
I've attached the patch I submitted upstream...I've tested it and it correctly eliminates the leaks.

Comment 1 Fedora Update System 2019-03-26 07:38:07 UTC
nut-2.7.4-23.fc28 has been submitted as an update to Fedora 28. https://bodhi.fedoraproject.org/updates/FEDORA-2019-e6bdcc9a22

Comment 2 Fedora Update System 2019-03-26 07:38:17 UTC
nut-2.7.4-23.fc29 has been submitted as an update to Fedora 29. https://bodhi.fedoraproject.org/updates/FEDORA-2019-4c732996bd

Comment 3 Fedora Update System 2019-03-26 07:38:29 UTC
nut-2.7.4-23.fc30 has been submitted as an update to Fedora 30. https://bodhi.fedoraproject.org/updates/FEDORA-2019-26c0784641

Comment 4 Fedora Update System 2019-03-27 00:45:16 UTC
nut-2.7.4-23.fc30 has been pushed to the Fedora 30 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2019-26c0784641

Comment 5 Fedora Update System 2019-03-27 04:11:45 UTC
nut-2.7.4-23.fc28 has been pushed to the Fedora 28 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2019-e6bdcc9a22

Comment 6 Fedora Update System 2019-03-27 04:34:33 UTC
nut-2.7.4-23.fc29 has been pushed to the Fedora 29 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2019-4c732996bd

Comment 7 Fedora Update System 2019-04-06 19:21:34 UTC
nut-2.7.4-23.fc28 has been pushed to the Fedora 28 stable repository. If problems still persist, please make note of it in this bug report.

Comment 8 Fedora Update System 2019-04-06 19:43:04 UTC
nut-2.7.4-23.fc29 has been pushed to the Fedora 29 stable repository. If problems still persist, please make note of it in this bug report.

Comment 9 Fedora Update System 2019-04-06 20:18:44 UTC
nut-2.7.4-23.fc30 has been pushed to the Fedora 30 stable repository. If problems still persist, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.