Bug 769718

Summary: SELinux is preventing /usr/libexec/postfix/smtp from read, write access on the files in directory /var/spool/postfix/deferred.
Product: [Fedora] Fedora Reporter: John Griffiths <fedora.jrg01>
Component: selinux-policyAssignee: Miroslav Grepl <mgrepl>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 16CC: dominick.grift, dwalsh, mgrepl
Target Milestone: ---   
Target Release: ---   
Hardware: i686   
OS: Unspecified   
Whiteboard: abrt_hash:5a0ab9c83f7c67f320dfb7ecae911e45cfbca575e573892cc0a8bc23abc86c21
Fixed In Version: selinux-policy-3.10.0-74.fc16 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-01-31 22:02:54 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description John Griffiths 2011-12-21 21:20:23 UTC
libreport version: 2.0.8
executable:     /usr/bin/python
hashmarkername: setroubleshoot
kernel:         3.1.5-6.fc16.i686.PAE
reason:         SELinux is preventing /usr/libexec/postfix/smtp from read, write access on the file /var/spool/postfix/deferred/5/530EB3C03EE.
time:           Wed 21 Dec 2011 04:18:53 PM EST

description:
:SELinux is preventing /usr/libexec/postfix/smtp from read, write access on the file /var/spool/postfix/deferred/5/530EB3C03EE.
:
:*****  Plugin catchall (100. confidence) suggests  ***************************
:
:If you believe that smtp should be allowed read write access on the 530EB3C03EE file by default.
:Then you should report this as a bug.
:You can generate a local policy module to allow this access.
:Do
:allow this access for now by executing:
:# grep smtp /var/log/audit/audit.log | audit2allow -M mypol
:# semodule -i mypol.pp
:
:Additional Information:
:Source Context                system_u:system_r:postfix_smtp_t:s0
:Target Context                system_u:object_r:postfix_spool_maildrop_t:s0
:Target Objects                /var/spool/postfix/deferred/5/530EB3C03EE [ file ]
:Source                        smtp
:Source Path                   /usr/libexec/postfix/smtp
:Port                          <Unknown>
:Host                          (removed)
:Source RPM Packages           postfix-2.8.7-1.fc16
:Target RPM Packages           
:Policy RPM                    selinux-policy-3.10.0-64.fc16
:Selinux Enabled               True
:Policy Type                   targeted
:Enforcing Mode                Enforcing
:Host Name                     (removed)
:Platform                      Linux daniel.internal.grifent.com
:                              3.1.5-6.fc16.i686.PAE #1 SMP Thu Dec 15 16:19:31
:                              UTC 2011 i686 i686
:Alert Count                   2
:First Seen                    Wed 21 Dec 2011 03:55:28 PM EST
:Last Seen                     Wed 21 Dec 2011 03:55:28 PM EST
:Local ID                      7906161e-3893-4fee-8aa8-bfb432eaad88
:
:Raw Audit Messages
:type=AVC msg=audit(1324500928.914:31364): avc:  denied  { read write } for  pid=19056 comm="smtp" name="530EB3C03EE" dev=dm-3 ino=3933166 scontext=system_u:system_r:postfix_smtp_t:s0 tcontext=system_u:object_r:postfix_spool_maildrop_t:s0 tclass=file
:
:
:type=SYSCALL msg=audit(1324500928.914:31364): arch=i386 syscall=open success=no exit=EACCES a0=2219d508 a1=8002 a2=0 a3=2219cc38 items=0 ppid=2033 pid=19056 auid=4294967295 uid=89 gid=89 euid=89 suid=89 fsuid=89 egid=89 sgid=89 fsgid=89 tty=(none) ses=4294967295 comm=smtp exe=/usr/libexec/postfix/smtp subj=system_u:system_r:postfix_smtp_t:s0 key=(null)
:
:Hash: smtp,postfix_smtp_t,postfix_spool_maildrop_t,file,read,write
:
:audit2allow
:
:#============= postfix_smtp_t ==============
:allow postfix_smtp_t postfix_spool_maildrop_t:file { read write };
:
:audit2allow -R
:
:#============= postfix_smtp_t ==============
:allow postfix_smtp_t postfix_spool_maildrop_t:file { read write };
:

Comment 1 John Griffiths 2011-12-22 02:08:45 UTC
As a workaround and possible solution, rather than creating a local policy, I changed the context on the directories defer and deferred in /var/spool/postfix from 

system_u:object_r:postfix_spool_maildrop_t:s0

to

system_u:object_r:postfix_spool_t:s0

and the mail was properly delivered.

Comment 2 Miroslav Grepl 2011-12-22 10:43:47 UTC
The "postfix_spool_maildrop_t" is the correct label. If you disable your local policy

# semodule -d name_your_module

and execute

# semanage permissive -a postfix_smtp_t

what avc are you getting then?

Comment 3 John Griffiths 2011-12-22 17:02:32 UTC
I had not made a local policy. I changed the context as stated in comment 1.

After executing 

# semanage permissive -a postfix_smtp_t

and then 

# grep AVC ./audit/audit.log | grep smtp > ~/avc.1
# cp /var/log/maillog ~/maillog.1
# mail me
...
# grep AVC ./audit/audit.log | grep smtp > ~/avc.2
# cp /var/log/maillog ~/maillog.2
# diff ~/avc.1 ~/avc.2

There were no differences, so I assume no AVCs.

# diff ~/maillog.1 ~/maillog.2
62322a62323,62335
> Dec 22 11:51:28 redacted postfix/pickup[5142]: 38C453C0198: uid=0 from=<root>
> Dec 22 11:51:28 redacted postfix/cleanup[6710]: 38C453C0198: message-id=<20111222165128.38C453C0198.redacted2>
> Dec 22 11:51:28 redacted postfix/qmgr[2036]: 38C453C0198: from=<root@redacted2>, size=458, nrcpt=1 (queue active)
> Dec 22 11:51:28 redacted postfix/smtpd[6715]: connect from localhost[127.0.0.1]
> Dec 22 11:51:28 redacted postfix/smtpd[6715]: D4D223C0144: client=localhost[127.0.0.1]
> Dec 22 11:51:28 redacted postfix/cleanup[6710]: D4D223C0144: message-id=<20111222165128.38C453C0198.redacted2>
> Dec 22 11:51:29 redacted postfix/qmgr[2036]: D4D223C0144: from=<root@redacted2>, size=957, nrcpt=1 (queue active)
> Dec 22 11:51:29 redacted postfix/smtpd[6715]: disconnect from localhost[127.0.0.1]
> Dec 22 11:51:29 redacted amavis[5771]: (05771-04) Passed CLEAN, <root@redacted2> -> <me>, Message-ID: <20111222165128.38C453C0198.redacted2>, mail_id: 4HibBy5AI0pv, Hits: -10.001, size: 458, queued_as: D4D223C0144, 704 ms
> Dec 22 11:51:29 redacted postfix/smtp[6712]: 38C453C0198: to=<me>, relay=127.0.0.1[127.0.0.1]:10024, delay=0.87, delays=0.14/0.01/0.01/0.71, dsn=2.0.0, status=sent (250 2.0.0 from MTA([127.0.0.1]:10025): 250 2.0.0 Ok: queued as D4D223C0144)
> Dec 22 11:51:29 redacted postfix/qmgr[2036]: 38C453C0198: removed
> Dec 22 11:51:29 redacted postfix/smtp[6717]: D4D223C0144: to=<me>, relay=outbound.mailhop.org[204.13.248.71]:2525, delay=0.58, delays=0.13/0.03/0.21/0.2, dsn=2.0.0, status=sent (250 OK id=1Rdlrd-00047F-DA)
> Dec 22 11:51:29 redacted postfix/qmgr[2036]: D4D223C0144: removed


So with postfix_smtp_t in permissive mode, there are no AVCs and mail is sent.

The question is: Is it safe to have postfix_smtp_t in permissive mode?

Comment 4 Fedora Update System 2012-01-26 18:16:22 UTC
selinux-policy-3.10.0-74.fc16 has been submitted as an update for Fedora 16.
https://admin.fedoraproject.org/updates/selinux-policy-3.10.0-74.fc16

Comment 5 Fedora Update System 2012-01-28 03:29:26 UTC
Package selinux-policy-3.10.0-74.fc16:
* should fix your issue,
* was pushed to the Fedora 16 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing selinux-policy-3.10.0-74.fc16'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2012-0983/selinux-policy-3.10.0-74.fc16
then log in and leave karma (feedback).

Comment 6 Fedora Update System 2012-01-31 22:02:54 UTC
selinux-policy-3.10.0-74.fc16 has been pushed to the Fedora 16 stable repository.  If problems still persist, please make note of it in this bug report.