Bug 830909

Summary: selinux is blocking mail delivery
Product: [Fedora] Fedora Reporter: Nicolas Mailhot <nicolas.mailhot>
Component: selinux-policy-targetedAssignee: Miroslav Grepl <mgrepl>
Status: CLOSED EOL QA Contact: Ben Levenson <benl>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 19CC: dwalsh, mhlavink
Target Milestone: ---Keywords: Reopened
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-02-18 11:20:26 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:
Attachments:
Description Flags
New avcs
none
anothet avc run none

Description Nicolas Mailhot 2012-06-11 15:52:08 UTC
Description of problem:

Selinux is blocking mail delivery (and not showing it in sealert)

Jun 11 17:45:37 arekh postfix/smtpd[19156]: connect from localhost.localdomain[127.0.0.1]
Jun 11 17:45:37 arekh postfix/smtpd[19156]: NOQUEUE: client=localhost.localdomain[127.0.0.1]
Jun 11 17:45:41 arekh postfix/smtpd[19166]: connect from localhost.localdomain[127.0.0.1]
Jun 11 17:45:41 arekh postfix/smtpd[19166]: 835578999: client=localhost.localdomain[127.0.0.1], orig_client=localhost.localdomain[127.0.0.1]
Jun 11 17:45:41 arekh postfix/cleanup[19167]: 835578999: message-id=<8649.1339429486>
Jun 11 17:45:41 arekh postfix/qmgr[1047]: 835578999: from=<devel-bounces.org>, size=4875, nrcpt=1 (queue active)
Jun 11 17:45:41 arekh postfix/smtpd[19166]: disconnect from localhost.localdomain[127.0.0.1]
Jun 11 17:45:41 arekh amavis[17706]: (17706-08) Passed CLEAN, [127.0.0.1] [209.132.183.28] <devel-bounces.org> -> <nim>, Message-ID: <8649.1339429486>, mail_id: RSghK4YXbZus, Hits: -3.407, size: 4417, queued_as: 835578999, 4564 ms
Jun 11 17:45:41 arekh postfix/smtpd[19156]: proxy-accept: END-OF-MESSAGE: 250 2.0.0 from MTA([127.0.0.1]:10025): 250 2.0.0 Ok: queued as 835578999; from=<devel-bounces.org> to=<nim> proto=ESMTP helo=<arekh.okg>
Jun 11 17:45:41 arekh postfix/local[19134]: 835578999: to=<nim>, relay=local, delay=0.37, delays=0.21/0/0/0.16, dsn=4.3.0, status=deferred (temporary failure. Command output: lda: Error: user nim: Error reading configuration: stat(/etc/dovecot/dovecot.conf) failed: Permission denied (euid=500(nim) egid=500(nim) missing +w perm: /etc/dovecot/dovecot.conf stat(/etc/dovecot/dovecot.conf) failed: Permission denied, dir owned by 0:0 mode=0755) lda: Fatal: Internal error occurred. Refer to server log for more information. )
Jun 11 17:45:41 arekh postfix/smtpd[19156]: disconnect from localhost.localdomain[127.0.0.1]


----
time->Mon Jun 11 06:35:22 2012
type=SYSCALL msg=audit(1339389322.220:40987): arch=c000003e syscall=4 success=no exit=-13 a0=74b900 a1=7fff7a450f70 a2=7fff7a450f70 a3=ffffffe7 items=0 ppid=14394 pid=14427 auid=4294967295 uid=500 gid=500 euid=500 suid=500 fsuid=500 egid=500 sgid=500 fsgid=500 tty=(none) ses=4294967295 comm="deliver" exe="/usr/libexec/dovecot/dovecot-lda" subj=system_u:system_r:postfix_local_t:s0 key=(null)
type=AVC msg=audit(1339389322.220:40987): avc:  denied  { search } for  pid=14427 comm="deliver" name="dovecot" dev="dm-1" ino=2113317 scontext=system_u:system_r:postfix_local_t:s0 tcontext=system_u:object_r:dovecot_etc_t:s0 tclass=dir
----
time->Mon Jun 11 06:35:22 2012
type=SYSCALL msg=audit(1339389322.224:40988): arch=c000003e syscall=42 success=no exit=-13 a0=6 a1=7fff75aebcb0 a2=6e a3=11dcaf8 items=0 ppid=14403 pid=14428 auid=4294967295 uid=500 gid=500 euid=500 suid=500 fsuid=500 egid=500 sgid=500 fsgid=500 tty=(none) ses=4294967295 comm="deliver" exe="/usr/libexec/dovecot/dovecot-lda" subj=system_u:system_r:postfix_local_t:s0 key=(null)
type=AVC msg=audit(1339389322.224:40988): avc:  denied  { search } for  pid=14428 comm="deliver" name="dovecot" dev="tmpfs" ino=12505 scontext=system_u:system_r:postfix_local_t:s0 tcontext=system_u:object_r:dovecot_var_run_t:s0 tclass=dir
----
time->Mon Jun 11 06:35:22 2012
type=SYSCALL msg=audit(1339389322.224:40989): arch=c000003e syscall=4 success=no exit=-13 a0=11d8900 a1=7fff75aebdb0 a2=7fff75aebdb0 a3=11dcaf8 items=0 ppid=14403 pid=14428 auid=4294967295 uid=500 gid=500 euid=500 suid=500 fsuid=500 egid=500 sgid=500 fsgid=500 tty=(none) ses=4294967295 comm="deliver" exe="/usr/libexec/dovecot/dovecot-lda" subj=system_u:system_r:postfix_local_t:s0 key=(null)
type=AVC msg=audit(1339389322.224:40989): avc:  denied  { search } for  pid=14428 comm="deliver" name="dovecot" dev="dm-1" ino=2113317 scontext=system_u:system_r:postfix_local_t:s0 tcontext=system_u:object_r:dovecot_etc_t:s0 tclass=dir
----

Now possibly dovecot should not be doing whatever it wants to do, but the direct effect is all mail gets stuck

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

selinux-policy-doc-3.11.0-2.fc18.noarch
postfix-2.9.3-1.fc18.x86_64
selinux-policy-3.11.0-2.fc18.noarch
selinux-policy-devel-3.11.0-2.fc18.noarch
selinux-policy-targeted-3.11.0-2.fc18.noarch
postfix-perl-scripts-2.9.3-1.fc18.x86_64
dovecot-pigeonhole-2.1.7-2.fc18.x86_64
dovecot-2.1.7-2.fc18.x86_64

Comment 1 Daniel Walsh 2012-06-13 21:31:30 UTC
THe only postfix app that we allow to transition to dovecot_deliver is postfix_pipe, I take it postfix_local should also?

Comment 2 Daniel Walsh 2012-06-13 21:32:35 UTC
Fixed in selinux-policy-3.11.0-4.fc18

Comment 3 Nicolas Mailhot 2012-06-14 09:50:57 UTC
(In reply to comment #1)
> THe only postfix app that we allow to transition to dovecot_deliver is
> postfix_pipe, I take it postfix_local should also?

dovecot-lda means dovecot local delivery agent so if selinux labels are meaningful it's normal for postfix_local to be able to talk with dovecot-lda

Comment 4 Nicolas Mailhot 2012-06-15 18:14:39 UTC
Created attachment 592198 [details]
New avcs

Does not work

dovecot-2.1.7-2.fc18.x86_64
dovecot-pigeonhole-2.1.7-2.fc18.x86_64
postfix-2.9.3-1.fc18.x86_64
postfix-perl-scripts-2.9.3-1.fc18.x86_64
selinux-policy-3.11.0-4.fc18.noarch
selinux-policy-devel-3.11.0-4.fc18.noarch
selinux-policy-doc-3.11.0-4.fc18.noarch
selinux-policy-targeted-3.11.0-4.fc18.noarch
systemd-185-6.gite7aee75.fc18.x86_64
systemd-analyze-185-6.gite7aee75.fc18.x86_64
systemd-libs-185-6.gite7aee75.fc18.x86_64
systemd-sysv-185-6.gite7aee75.fc18.x86_64
systemd-ui-1-2.fc18.x86_64

Comment 5 Daniel Walsh 2012-06-15 20:09:46 UTC
Comment on attachment 592198 [details]
New avcs

sesearch -T -t postfix_local_t -t dovecot_deliver_exec_t
Found 7 semantic te rules:
...

  type_transition postfix_local_t dovecot_deliver_exec_t : process dovecot_deliver_t; 


It looks like the transition is there on my system
rpm -q selinux-policy
selinux-policy-3.11.0-4.fc18.noarch

razor-agent.log should not be labeled etc_runtime_t, it should be labeled as a log file.  Probably need to run restorecon on it.

You have a file named clamd that is labeled as root_t, this is definitely wrong

Comment 6 Nicolas Mailhot 2012-06-16 07:11:13 UTC
(In reply to comment #5)
> Comment on attachment 592198 [details]
> New avcs
> 
> sesearch -T -t postfix_local_t -t dovecot_deliver_exec_t
> Found 7 semantic te rules:
> ...
> 
>   type_transition postfix_local_t dovecot_deliver_exec_t : process
> dovecot_deliver_t; 
> 
> 
> It looks like the transition is there on my system
> rpm -q selinux-policy
> selinux-policy-3.11.0-4.fc18.noarch

Same here. Nevertheless it is not sufficient and mail delivery does not work despite two fixfile restore + reboot

> razor-agent.log should not be labeled etc_runtime_t, it should be labeled as
> a log file.  Probably need to run restorecon on it.

IIRC razor is stupid enough to try to write its log in /

> You have a file named clamd that is labeled as root_t, this is definitely
> wrong

Again, this was after a fixfiles restore and reboot

Comment 7 Nicolas Mailhot 2012-06-16 07:12:32 UTC
Created attachment 592279 [details]
anothet avc run

after fixfiles restore and reboot

Comment 8 Nicolas Mailhot 2012-06-16 07:15:19 UTC
Jun 16 09:00:06 arekh amavis[1093]: (01093-01) Passed CLEAN, [127.0.0.1] [209.132.183.26] <bugzilla> -> <nim>, Message-ID: <bug-830909-121966-3LcgV4fN5S.com>, mail_id: VdHlmkgW6utg, Hits: -6.108, size: 3813, queued_as: 57A78346D, 3905 ms
Jun 16 09:00:06 arekh postfix/smtpd[2835]: proxy-accept: END-OF-MESSAGE: 250 2.0.0 from MTA([127.0.0.1]:10025): 250 2.0.0 Ok: queued as 57A78346D; from=<bugzilla> to=<nim> proto=ESMTP helo=<arekh.okg>
Jun 16 09:00:06 arekh postfix/smtpd[2835]: disconnect from localhost.localdomain[127.0.0.1]
Jun 16 09:00:06 arekh postfix/local[2863]: 57A78346D: to=<nim>, relay=local, delay=0.5, delays=0.25/0.05/0/0.2, dsn=4.3.0, status=deferred (temporary failure. Command output: lda: Error: user nim: Error reading configuration: stat(/etc/dovecot/dovecot.conf) failed: Permission denied (euid=500(nim) egid=500(nim) missing +w perm: /etc/dovecot/dovecot.conf stat(/etc/dovecot/dovecot.conf) failed: Permission denied, dir owned by 0:0 mode=0755) lda: Fatal: Internal error occurred. Refer to server log for more information. )

Comment 9 Daniel Walsh 2012-06-18 20:44:52 UTC
No need to fixfiles/reboot.  

Which program deliver is postfix executing?

ls -lZ deliver

Comment 10 Nicolas Mailhot 2012-06-19 15:31:05 UTC
(In reply to comment #9)
> No need to fixfiles/reboot.  
> 
> Which program deliver is postfix executing?
> 
> ls -lZ deliver

ls -lZ /usr/libexec/dovecot/deliver
lrwxrwxrwx. root root system_u:object_r:bin_t:s0       /usr/libexec/dovecot/deliver -> dovecot-lda

ls -lZ /usr/libexec/dovecot/dovecot-lda 
-rwxr-xr-x. root root system_u:object_r:bin_t:s0       /usr/libexec/dovecot/dovecot-lda

Comment 11 Daniel Walsh 2012-06-19 18:26:29 UTC
That is the problem.

Fixed in selinux-policy-3.11.0-6.fc18

chcon -t dovecot_deliver_exec_t /usr/libexec/dovecot/dovecot-lda

Comment 12 Nicolas Mailhot 2012-06-26 11:06:04 UTC
(In reply to comment #11)
> That is the problem.

Fixed in selinux-policy-3.11.0-6.fc18

That works thanks a lot!

Comment 13 Fedora End Of Life 2013-04-03 20:41:26 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 19 development cycle.
Changing version to '19'.

(As we did not run this process for some time, it could affect also pre-Fedora 19 development
cycle bugs. We are very sorry. It will help us with cleanup during Fedora 19 End Of Life. Thank you.)

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

Comment 14 Fedora End Of Life 2015-01-09 22:41:34 UTC
This message is a notice that Fedora 19 is now at end of life. Fedora 
has stopped maintaining and issuing updates for Fedora 19. It is 
Fedora's policy to close all bug reports from releases that are no 
longer maintained. Approximately 4 (four) weeks from now this bug will
be closed as EOL if it remains open with a Fedora 'version' of '19'.

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.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 19 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, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

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.

Comment 15 Fedora End Of Life 2015-02-18 11:20:26 UTC
Fedora 19 changed to end-of-life (EOL) status on 2015-01-06. Fedora 19 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. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

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