Bug 1366173

Summary: /root/.esmtp_queue has bad context when created from a cron job
Product: [Fedora] Fedora Reporter: Ondřej Lysoněk <olysonek>
Component: selinux-policyAssignee: Lukas Vrabec <lvrabec>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 23CC: ariscop, dominick.grift, dwalsh, jwakely, lvrabec, marco.guazzone, mgrepl, plautrba
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: selinux-policy-3.13.1-158.24.fc23 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-09-29 22:52:16 UTC Type: Bug
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: 1303305    

Description Ondřej Lysoněk 2016-08-11 08:45:22 UTC
Description of problem:
When a process with context
'unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023'
creates the '/root/.esmtp_queue/' directory, then the directory is assigned the correct context
'unconfined_u:object_r:mail_home_rw_t:s0'

However, if the process that creates the directory has context
'system_u:system_r:crond_t:s0-s0:c0.c1023'
(context of the 'atd' daemon - note that this context is only preserved, when 'atd' is sending mail internally. The context is set to unconfined when running the jobs.)
or
'system_u:system_r:system_cronjob_t:s0-s0:c0.c1023'
(context of a regular cron job)
then the created directory has incorrect context
'system_u:object_r:admin_home_t:s0'

Version-Release number of selected component (if applicable):
selinux-policy-3.13.1-158.21.fc23

Comment 1 Ondřej Lysoněk 2016-08-11 08:49:34 UTC
This might be the cause of [1] and [2], but there may be other process contexts, under which the directory is created with bad context.

[1] https://bugzilla.redhat.com/show_bug.cgi?id=1282043
[2] https://bugzilla.redhat.com/show_bug.cgi?id=1319370

Comment 2 Lukas Vrabec 2016-08-11 09:54:08 UTC
*** Bug 1282043 has been marked as a duplicate of this bug. ***

Comment 3 Lukas Vrabec 2016-08-11 09:54:31 UTC
*** Bug 1319370 has been marked as a duplicate of this bug. ***

Comment 4 Jonathan Wakely 2016-08-15 09:25:22 UTC
(In reply to Ondřej Lysoněk from comment #0)
> When a process with context
> 'unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023'
> creates the '/root/.esmtp_queue/' directory, then the directory is assigned
> the correct context

N.B. I'm seeing atd use /.esmtp_queue/ **not** /root/.esmtp_queue/

Comment 5 Ondřej Lysoněk 2016-08-15 12:12:06 UTC
(In reply to Jonathan Wakely from comment #4)
> (In reply to Ondřej Lysoněk from comment #0)
> > When a process with context
> > 'unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023'
> > creates the '/root/.esmtp_queue/' directory, then the directory is assigned
> > the correct context
> 
> N.B. I'm seeing atd use /.esmtp_queue/ **not** /root/.esmtp_queue/

Yes, this is a bug, which is being resolved in [1]. The correct directory should be /root/.esmtp_queue/.

If you want to test this bug, I can send you a patch for esmtp, which fixes [1]. I did not build it yet, as I'm waiting for the resolution of this selinux-policy bug.

[1] https://bugzilla.redhat.com/show_bug.cgi?id=1303305

Comment 6 Ondřej Lysoněk 2016-08-22 11:20:46 UTC
This seems to be fixed now in f24-rawhide. Are you planning to backport the fix to f23 too?

Comment 7 Lukas Vrabec 2016-08-25 12:10:45 UTC
It's backported. I just need to create new build.

Comment 8 Fedora Update System 2016-09-16 08:37:12 UTC
selinux-policy-3.13.1-158.24.fc23 has been submitted as an update to Fedora 23. https://bodhi.fedoraproject.org/updates/FEDORA-2016-f739cc7524

Comment 9 Fedora Update System 2016-09-17 00:52:52 UTC
selinux-policy-3.13.1-158.24.fc23 has been pushed to the Fedora 23 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-2016-f739cc7524

Comment 10 Fedora Update System 2016-09-29 22:52:16 UTC
selinux-policy-3.13.1-158.24.fc23 has been pushed to the Fedora 23 stable repository. If problems still persist, please make note of it in this bug report.