Bug 878997

Summary: SELinux is preventing /usr/bin/fetchmail from write access on the directory /var/log
Product: [Fedora] Fedora Reporter: Vladislav Grigoryev <vg.aetera>
Component: selinux-policyAssignee: Miroslav Grepl <mgrepl>
Status: CLOSED CURRENTRELEASE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 17CC: dominick.grift, dwalsh, mgrepl, vg.aetera
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-01-07 04:00:30 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:

Description Vladislav Grigoryev 2012-11-21 18:42:44 UTC
Description of problem:
SELinux is preventing /usr/bin/fetchmail from write access on the directory /var/log.

*****  Plugin catchall (100. confidence) suggests  ***************************

If you believe that fetchmail should be allowed write access on the log directory 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 fetchmail /var/log/audit/audit.log | audit2allow -M mypol
# semodule -i mypol.pp


Additional Information:
Source Context                system_u:system_r:fetchmail_t:s0
Target Context                system_u:object_r:var_log_t:s0
Target Objects                /var/log [ dir ]
Source                        fetchmail
Source Path                   /usr/bin/fetchmail
Port                          <Unknown>
Host                          srv06.kola.fad.ru
Source RPM Packages           fetchmail-6.3.22-1.fc17.x86_64
Target RPM Packages           filesystem-3-2.fc17.x86_64
Policy RPM                    selinux-policy-3.10.0-161.fc17.noarch
Selinux Enabled               True
Policy Type                   targeted
Enforcing Mode                Enforcing
Host Name                     srv06.kola.fad.ru
Platform                      Linux srv06.kola.fad.ru 3.6.6-1.fc17.x86_64 #1 SMP
                              Mon Nov 5 21:59:35 UTC 2012 x86_64 x86_64
Alert Count                   3
First Seen                    2012-11-21 22:35:02 MSK
Last Seen                     2012-11-21 22:36:01 MSK
Local ID                      9548d7f0-9518-417f-a7da-7f9ac98d9576

Raw Audit Messages
type=AVC msg=audit(1353522961.329:274): avc:  denied  { write } for  pid=6516 comm="fetchmail" name="log" dev="dm-1" ino=1705216 scontext=system_u:system_r:fetchmail_t:s0 tcontext=system_u:object_r:var_log_t:s0 tclass=dir


type=SYSCALL msg=audit(1353522961.329:274): arch=x86_64 syscall=open success=no exit=EACCES a0=1be8a10 a1=441 a2=1b6 a3=8 items=0 ppid=1 pid=6516 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm=fetchmail exe=/usr/bin/fetchmail subj=system_u:system_r:fetchmail_t:s0 key=(null)

Hash: fetchmail,fetchmail_t,var_log_t,dir,write

audit2allow

#============= fetchmail_t ==============
#!!!! The source type 'fetchmail_t' can write to a 'dir' of the following types:
# fetchmail_var_run_t, sendmail_log_t, mail_spool_t, var_run_t, root_t

allow fetchmail_t var_log_t:dir write;

audit2allow -R

#============= fetchmail_t ==============
#!!!! The source type 'fetchmail_t' can write to a 'dir' of the following types:
# fetchmail_var_run_t, sendmail_log_t, mail_spool_t, var_run_t, root_t

allow fetchmail_t var_log_t:dir write;

How reproducible:
Always reproducible.

Steps to Reproduce:
# systemctl start fetchmail.service
  
Actual results:
Nov 21 22:36:01 srv06 fetchmail[6516]: fetchmail: cannot open /var/log/fetchmail.log: Permission denied
Nov 21 22:36:01 srv06 fetchmail[6516]: fetchmail: fetchmail: Cannot detach into background. Aborting.
Nov 21 22:36:01 srv06 systemd[1]: fetchmail.service: main process exited, code=exited, status=6
Nov 21 22:36:01 srv06 systemd[1]: Unit fetchmail.service entered failed state.
Nov 21 22:36:01 srv06 setroubleshoot: SELinux is preventing /usr/bin/fetchmail from write access on the directory /var/log. For complete SELinux messages. run sealert -l 9548d7f0-9518-417f-a7da-7f9ac98d9576

Additional info:
# cat /usr/lib/systemd/system/fetchmail.service 
[Unit]
Description=A remote-mail retrieval utility
After=network.target postfix.service

[Service]
PIDFile=/run/fetchmail.pid
User=root
ExecStart=/usr/bin/fetchmail --fetchmailrc /etc/fetchmail.conf
RestartSec=1

[Install]
WantedBy=multi-user.target

# cat /etc/fetchmail.conf 
set daemon 60
set logfile /var/log/fetchmail.log
set pidfile /run/fetchmail.pid
poll "mail.inet-provider.com" with proto POP3 user "user" there with password "qwerty" is "user" here

Comment 1 Daniel Walsh 2012-11-21 18:57:39 UTC
Added this to F18, 8d1d212f68795311d2d47bf86fd09c284e57962d.

Please back port.

Comment 2 Miroslav Grepl 2012-11-22 07:17:29 UTC
Added.

commit 605893473126332bfadb15d67ebd9e6c67d3a89a
Author: Miroslav Grepl <mgrepl>
Date:   Thu Nov 22 08:13:46 2012 +0100

    Allow fetchmail to create log files

Comment 3 Fedora Update System 2012-12-17 18:41:30 UTC
selinux-policy-3.10.0-165.fc17 has been submitted as an update for Fedora 17.
https://admin.fedoraproject.org/updates/selinux-policy-3.10.0-165.fc17

Comment 4 Fedora Update System 2012-12-18 02:37:06 UTC
Package selinux-policy-3.10.0-165.fc17:
* should fix your issue,
* was pushed to the Fedora 17 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-165.fc17'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2012-20544/selinux-policy-3.10.0-165.fc17
then log in and leave karma (feedback).

Comment 5 Fedora Update System 2013-01-05 06:40:39 UTC
Package selinux-policy-3.10.0-166.fc17:
* should fix your issue,
* was pushed to the Fedora 17 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-166.fc17'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2012-20544/selinux-policy-3.10.0-166.fc17
then log in and leave karma (feedback).

Comment 6 Fedora Update System 2013-01-07 04:00:32 UTC
selinux-policy-3.10.0-166.fc17 has been pushed to the Fedora 17 stable repository.  If problems still persist, please make note of it in this bug report.