Bug 647587 - /usr/bin/mimedefang selinux context wrong
Summary: /usr/bin/mimedefang selinux context wrong
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Fedora
Classification: Fedora
Component: selinux-policy-targeted
Version: 13
Hardware: Unspecified
OS: Unspecified
low
medium
Target Milestone: ---
Assignee: Miroslav Grepl
QA Contact: Ben Levenson
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2010-10-28 20:31 UTC by Matthew McGillis
Modified: 2011-06-28 11:06 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2011-06-28 11:06:14 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)
mimedefang patch (5.56 KB, patch)
2010-11-01 15:21 UTC, Miroslav Grepl
no flags Details | Diff


Links
System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 698398 0 unspecified CLOSED mimedefang.pl's invocation of send_mail() causes an exception 2021-02-22 00:41:40 UTC

Internal Links: 698398

Description Matthew McGillis 2010-10-28 20:31:21 UTC
Description of problem:
Sendmail can not open mimedefang socket file.

Oct 28 12:47:28 orange sendmail[2009]: o9SJlSt2002009: Milter: initialization failed, temp failing commands
Oct 28 12:48:01 orange sendmail[2012]: o9SJm1uj002012: Milter (mimedefang): error connecting to filter: Permission denied
Oct 28 12:48:01 orange sendmail[2012]: o9SJm1uj002012: Milter (mimedefang): to error state

Version-Release number of selected component (if applicable):
mimedefang-2.71-1.fc13.x86_64

How reproducible:
Always

Steps to Reproduce:
1. Configure sendmail to use mimedefang
2. Start up sendmail and mimedefang
3. Get above errors from sendmail when messages are sent
  
Actual results:
No messages get delivered

Expected results:
Messages should get processed and either delivered or rejected

Solution:
chcon -t spamd_exec_t /usr/bin/mimedefang

Additional info:
In the audit logs selinux is blocking sendmail form connecting to the mimedefang socket.
This is because /usr/bin/mimedefang on install is configured with wrong selinux context type

Comment 1 Robert Scheck 2010-10-29 23:36:39 UTC
Daniel, may you please take care of this? Thank you.

Comment 2 Daniel Walsh 2010-11-01 12:54:13 UTC
If this works, then it is fine with me.

Comment 3 Robert Scheck 2010-11-01 13:05:31 UTC
I'm not sure, whether only "spamd_exec_t" is the real solution. Hasn't
MIMEDefang an own policy? Because the MIMEDefang socket might be used by
Postfix as well and it might be used be others, too. MIMEDefang is more
than just a SpamAssassin connector...

Comment 4 Miroslav Grepl 2010-11-01 13:53:59 UTC
After a quick look I am thinking about adding mimedefang to the milters. I am going to do some tests.

Comment 5 Miroslav Grepl 2010-11-01 15:21:18 UTC
Created attachment 456903 [details]
mimedefang patch

Dan,
mimedefang is treated as spamd policy, but I believe the attached patch is better solution for mimedefang. I am planning to do a scratch build for F13 first and people can test it.

Comment 6 Miroslav Grepl 2010-11-01 15:47:31 UTC
The selinux-policy and selinux-policy-targeted packages are available from koji

http://koji.fedoraproject.org/koji/taskinfo?taskID=2569109

Matthew,
could you test it?

Comment 7 Matthew McGillis 2010-11-01 20:09:03 UTC
Installed

rpm -Fvh selinux-policy-3.7.19-70.fc13.noarch.rpm selinux-policy-targeted-3.7.19-70.fc13.noarch.rpm

Now getting the following error:

Nov  1 13:00:40 orange mimedefang[27377]: oA1K0eEf027417: Could not create directory /var/spool/MIMEDefang/mdefang-oA1K0eEf027417: Permission denied

Messages all get rejected.

## ls -alZd
drwxr-x---. defang defang system_u:object_r:sendmail_milter_data_t:s0 /var/spool/MIMEDefang
drwxr-x---. defang defang system_u:object_r:sendmail_milter_data_t:s0 /var/spool/MIMEDefang/mdefang-o9BHo6HB006623

## ps -auxZ mimedefang
unconfined_u:system_r:sendmail_milter_t:s0 defang 27377 0.0  0.1 82220 588 ?   Sl   12:59   0:00 /usr/bin/mimedefang -P /var/spool/MIMEDefang/mimedefang.pid -m /var/spool/MIMEDefang/mimedefang-multiplexor.sock -R -1 -U defang -q -p /var/spool/MIMEDefang/mimedefang.sock


## cat audit.log
type=AVC msg=audit(1288641974.681:21000): avc:  denied  { create } for  pid=27481 comm="mimedefang" name="mdefang-oA1K6DPG027480" scontext=unconfined_u:system_r:sendmail_milter_t:s0 tcontext=unconfined_u:object_r:sendmail_milter_data_t:s0 tclass=dir

Comment 8 Miroslav Grepl 2010-11-01 22:23:50 UTC
Ok,

execute

# semanage permissive -a sendmail_milter_t

Then try to re-test it. Thanks.

Comment 9 Matthew McGillis 2010-11-02 00:07:01 UTC
Well that certainly makes it so the errors go away. Not sure what the intent exactly with that is. But if your interested this is the denied audit history for a few tests.

type=AVC msg=audit(1288655766.573:21160): avc:  denied  { create } for  pid=28587 comm="mimedefang" name="mdefang-oA1Nu6cZ028586" scontext=unconfined_u:system_r:sendmail_milter_t:s0 tcontext=unconfined_u:object_r:sendmail_milter_data_t:s0 tclass=dir
type=AVC msg=audit(1288655766.658:21161): avc:  denied  { write } for  pid=28531 comm="mimedefang.pl" name="tmp" dev=dm-0 ino=130310 scontext=unconfined_u:system_r:sendmail_milter_t:s0 tcontext=system_u:object_r:tmp_t:s0 tclass=dir
type=AVC msg=audit(1288655766.658:21161): avc:  denied  { add_name } for  pid=28531 comm="mimedefang.pl" name="XKnIqRNSCk" scontext=unconfined_u:system_r:sendmail_milter_t:s0 tcontext=system_u:object_r:tmp_t:s0 tclass=dir
type=AVC msg=audit(1288655766.658:21161): avc:  denied  { create } for  pid=28531 comm="mimedefang.pl" name="XKnIqRNSCk" scontext=unconfined_u:system_r:sendmail_milter_t:s0 tcontext=unconfined_u:object_r:tmp_t:s0 tclass=file
type=AVC msg=audit(1288655766.658:21161): avc:  denied  { read write open } for  pid=28531 comm="mimedefang.pl" name="XKnIqRNSCk" dev=dm-0 ino=184775 scontext=unconfined_u:system_r:sendmail_milter_t:s0 tcontext=unconfined_u:object_r:tmp_t:s0 tclass=file
type=AVC msg=audit(1288655766.659:21162): avc:  denied  { ioctl } for  pid=28531 comm="mimedefang.pl" path="/tmp/XKnIqRNSCk" dev=dm-0 ino=184775 scontext=unconfined_u:system_r:sendmail_milter_t:s0 tcontext=unconfined_u:object_r:tmp_t:s0 tclass=file
type=AVC msg=audit(1288655766.659:21163): avc:  denied  { getattr } for  pid=28531 comm="mimedefang.pl" path="/tmp/XKnIqRNSCk" dev=dm-0 ino=184775 scontext=unconfined_u:system_r:sendmail_milter_t:s0 tcontext=unconfined_u:object_r:tmp_t:s0 tclass=file
type=AVC msg=audit(1288655766.660:21164): avc:  denied  { setattr } for  pid=28531 comm="mimedefang.pl" name="XKnIqRNSCk" dev=dm-0 ino=184775 scontext=unconfined_u:system_r:sendmail_milter_t:s0 tcontext=unconfined_u:object_r:tmp_t:s0 tclass=file
type=AVC msg=audit(1288655766.665:21165): avc:  denied  { remove_name } for  pid=28531 comm="mimedefang.pl" name="XKnIqRNSCk" dev=dm-0 ino=184775 scontext=unconfined_u:system_r:sendmail_milter_t:s0 tcontext=system_u:object_r:tmp_t:s0 tclass=dir
type=AVC msg=audit(1288655766.665:21165): avc:  denied  { unlink } for  pid=28531 comm="mimedefang.pl" name="XKnIqRNSCk" dev=dm-0 ino=184775 scontext=unconfined_u:system_r:sendmail_milter_t:s0 tcontext=unconfined_u:object_r:tmp_t:s0 tclass=file
type=AVC msg=audit(1288655766.736:21166): avc:  denied  { node_bind } for  pid=28531 comm="mimedefang.pl" scontext=unconfined_u:system_r:sendmail_milter_t:s0 tcontext=system_u:object_r:node_t:s0 tclass=udp_socket
type=AVC msg=audit(1288655766.739:21167): avc:  denied  { search } for  pid=28531 comm="mimedefang.pl" name="spamassassin" dev=dm-0 ino=394034 scontext=unconfined_u:system_r:sendmail_milter_t:s0 tcontext=system_u:object_r:spamd_var_lib_t:s0 tclass=dir
type=AVC msg=audit(1288655766.739:21167): avc:  denied  { getattr } for  pid=28531 comm="mimedefang.pl" path="/var/lib/spamassassin/3.003001" dev=dm-0 ino=394192 scontext=unconfined_u:system_r:sendmail_milter_t:s0 tcontext=system_u:object_r:spamd_var_lib_t:s0 tclass=dir
type=AVC msg=audit(1288655766.744:21168): avc:  denied  { read } for  pid=28531 comm="mimedefang.pl" name="3.003001" dev=dm-0 ino=394192 scontext=unconfined_u:system_r:sendmail_milter_t:s0 tcontext=system_u:object_r:spamd_var_lib_t:s0 tclass=dir
type=AVC msg=audit(1288655766.744:21168): avc:  denied  { open } for  pid=28531 comm="mimedefang.pl" name="3.003001" dev=dm-0 ino=394192 scontext=unconfined_u:system_r:sendmail_milter_t:s0 tcontext=system_u:object_r:spamd_var_lib_t:s0 tclass=dir
type=AVC msg=audit(1288655766.744:21169): avc:  denied  { getattr } for  pid=28531 comm="mimedefang.pl" path="/var/lib/spamassassin/3.003001/updates_spamassassin_org.cf" dev=dm-0 ino=394141 scontext=unconfined_u:system_r:sendmail_milter_t:s0 tcontext=system_u:object_r:spamd_var_lib_t:s0 tclass=file
type=AVC msg=audit(1288655766.745:21170): avc:  denied  { read } for  pid=28531 comm="mimedefang.pl" name="sought_rules_yerp_org.cf" dev=dm-0 ino=392906 scontext=unconfined_u:system_r:sendmail_milter_t:s0 tcontext=system_u:object_r:spamd_var_lib_t:s0 tclass=file
type=AVC msg=audit(1288655766.745:21170): avc:  denied  { open } for  pid=28531 comm="mimedefang.pl" name="sought_rules_yerp_org.cf" dev=dm-0 ino=392906 scontext=unconfined_u:system_r:sendmail_milter_t:s0 tcontext=system_u:object_r:spamd_var_lib_t:s0 tclass=file
type=AVC msg=audit(1288655766.745:21171): avc:  denied  { ioctl } for  pid=28531 comm="mimedefang.pl" path="/var/lib/spamassassin/3.003001/sought_rules_yerp_org.cf" dev=dm-0 ino=392906 scontext=unconfined_u:system_r:sendmail_milter_t:s0 tcontext=system_u:object_r:spamd_var_lib_t:s0 tclass=file
type=AVC msg=audit(1288655769.462:21172): avc:  denied  { getattr } for  pid=28587 comm="mimedefang" name="/" dev=dm-0 ino=2 scontext=unconfined_u:system_r:sendmail_milter_t:s0 tcontext=system_u:object_r:fs_t:s0 tclass=filesystem
type=AVC msg=audit(1288655769.462:21173): avc:  denied  { rmdir } for  pid=28587 comm="mimedefang" name="Work" dev=dm-0 ino=393386 scontext=unconfined_u:system_r:sendmail_milter_t:s0 tcontext=unconfined_u:object_r:sendmail_milter_data_t:s0 tclass=dir
type=AVC msg=audit(1288656101.932:21183): avc:  denied  { create } for  pid=28531 comm="mimedefang.pl" name="CiiPpA6vVX" scontext=unconfined_u:system_r:sendmail_milter_t:s0 tcontext=unconfined_u:object_r:tmp_t:s0 tclass=file
type=AVC msg=audit(1288656101.932:21183): avc:  denied  { read write open } for  pid=28531 comm="mimedefang.pl" name="CiiPpA6vVX" dev=dm-0 ino=184870 scontext=unconfined_u:system_r:sendmail_milter_t:s0 tcontext=unconfined_u:object_r:tmp_t:s0 tclass=file
type=AVC msg=audit(1288656101.933:21184): avc:  denied  { ioctl } for  pid=28531 comm="mimedefang.pl" path="/tmp/CiiPpA6vVX" dev=dm-0 ino=184870 scontext=unconfined_u:system_r:sendmail_milter_t:s0 tcontext=unconfined_u:object_r:tmp_t:s0 tclass=file
type=AVC msg=audit(1288656101.933:21185): avc:  denied  { getattr } for  pid=28531 comm="mimedefang.pl" path="/tmp/CiiPpA6vVX" dev=dm-0 ino=184870 scontext=unconfined_u:system_r:sendmail_milter_t:s0 tcontext=unconfined_u:object_r:tmp_t:s0 tclass=file
type=AVC msg=audit(1288656101.933:21186): avc:  denied  { setattr } for  pid=28531 comm="mimedefang.pl" name="CiiPpA6vVX" dev=dm-0 ino=184870 scontext=unconfined_u:system_r:sendmail_milter_t:s0 tcontext=unconfined_u:object_r:tmp_t:s0 tclass=file
type=AVC msg=audit(1288656101.935:21187): avc:  denied  { unlink } for  pid=28531 comm="mimedefang.pl" name="CiiPpA6vVX" dev=dm-0 ino=184870 scontext=unconfined_u:system_r:sendmail_milter_t:s0 tcontext=unconfined_u:object_r:tmp_t:s0 tclass=file

Comment 10 Miroslav Grepl 2010-11-02 09:13:22 UTC
(In reply to comment #9)
> Well that certainly makes it so the errors go away. Not sure what the intent
> exactly with that is. But if your interested this is the denied audit history
> for a few tests.

The command makes the sendmail_milter_t domain as permissive domain. This means while SELinux access ckecks are performed for this domain, they are not enforced. We can push out a new policy as permissive domain and simply collect AVC messages. Users don’t have to switch to permissive mode globally and they can stay in the enforcing mode.

Comment 11 Miroslav Grepl 2010-11-02 13:17:50 UTC
I have just done another scratch build which should fix all your issues.

http://koji.fedoraproject.org/koji/taskinfo?taskID=2571279

Comment 12 Philip Prindeville 2010-11-11 18:17:28 UTC
Sorry, the build has been aged (removed).  Can you do another?

Thanks.

Comment 13 Miroslav Grepl 2010-11-16 14:15:16 UTC
Yes, there are:

http://koji.fedoraproject.org/koji/taskinfo?taskID=2604131

Comment 14 Philip Prindeville 2010-11-26 21:34:27 UTC
Sorry, didn't grab it in time.  Can you put the .srpm in your directory on fedorapeople.org and I'll build it myself?

Thanks.

BTW:  What's the progress of this fix?  What's it waiting on?

Comment 15 Miroslav Grepl 2010-12-20 18:07:14 UTC
Fixed in selinux-policy-3.7.19-77.fc13

Comment 16 Bug Zapper 2011-05-30 14:37:23 UTC
This message is a reminder that Fedora 13 is nearing its end of life.
Approximately 30 (thirty) days from now Fedora will stop maintaining
and issuing updates for Fedora 13.  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 '13'.

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 13'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 13 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 17 Bug Zapper 2011-06-28 11:06:14 UTC
Fedora 13 changed to end-of-life (EOL) status on 2011-06-25. Fedora 13 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.


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