Bug 975695 - SELinux prevent fail2ban (fail2ban-client werite) to start (F19-TC5)
Summary: SELinux prevent fail2ban (fail2ban-client werite) to start (F19-TC5)
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: selinux-policy-targeted
Version: 19
Hardware: x86_64
OS: Linux
unspecified
high
Target Milestone: ---
Assignee: Miroslav Grepl
QA Contact: Ben Levenson
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-06-19 06:59 UTC by Cristian Sava
Modified: 2013-12-25 23:26 UTC (History)
7 users (show)

Fixed In Version: selinux-policy-3.12.1-63.fc19
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2013-07-14 03:38:02 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
SELinux module policy file fail2ban-var-run.te (931 bytes, text/plain)
2013-07-03 04:35 UTC, Edgar Hoch
no flags Details

Description Cristian Sava 2013-06-19 06:59:47 UTC
Description of problem:

F19-TC5_x64 After recent updates SELinux prevent fail2ban to start.

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

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

Additional Information:
Source Context                system_u:system_r:fail2ban_client_t:s0
Target Context                system_u:object_r:fail2ban_var_run_t:s0
Target Objects                fail2ban [ dir ]
Source                        fail2ban-client
Source Path                   /usr/bin/python2.7
Port                          <Unknown>
Host                          s198.xx.yy.ro
Source RPM Packages           python-2.7.5-1.fc19.x86_64
Target RPM Packages           
Policy RPM                    selinux-policy-3.12.1-52.fc19.noarch
Selinux Enabled               True
Policy Type                   targeted
Enforcing Mode                Enforcing
Host Name                     s198.xx.yy.ro
Platform                      Linux s198.xx.yy.ro 3.9.5-301.fc19.x86_64
#1
                              SMP Tue Jun 11 19:39:38 UTC 2013 x86_64
x86_64
Alert Count                   35
First Seen                    2013-06-17 14:04:13 EEST
Last Seen                     2013-06-19 08:28:22 EEST
Local ID                      9d6fd1b8-250e-4425-b3e3-7590dc3bc1f1

Raw Audit Messages
type=AVC msg=audit(1371619702.236:67): avc:  denied  { write } for
pid=871 comm="fail2ban-client" name="fail2ban" dev="tmpfs" ino=11022
scontext=system_u:system_r:fail2ban_client_t:s0
tcontext=system_u:object_r:fail2ban_var_run_t:s0 tclass=dir


type=SYSCALL msg=audit(1371619702.236:67): arch=x86_64 syscall=access
success=no exit=EACCES a0=1ab48c0 a1=3 a2=32adbbbf88 a3=0 items=0 ppid=1
pid=871 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0
fsgid=0 ses=4294967295 tty=(none) comm=fail2ban-client
exe=/usr/bin/python2.7 subj=system_u:system_r:fail2ban_client_t:s0
key=(null)

Hash: fail2ban-client,fail2ban_client_t,fail2ban_var_run_t,dir,write


Version-Release number of selected component (if applicable):
F19-TC5 fail2ban-0.8.10-1.fc19.noarch selinux-policy-3.12.1-52.fc19.noarch ...


How reproducible:

# yum install fail2ban
# systemctl start fail2ban.service

Steps to Reproduce:

1. Install fail2ban
2. Try to start fail2ban
3. SELinux prevent fail2ban to start

Actual results:

[cristi@s198 ~]$ systemctl status fail2ban.service
fail2ban.service - Fail2ban Service
   Loaded: loaded (/usr/lib/systemd/system/fail2ban.service; enabled)
   Active: failed (Result: start-limit) since Wed 2013-06-19 08:28:22
EEST; 1min 45s ago
  Process: 871 ExecStart=/usr/bin/fail2ban-client -x start (code=exited,
status=255)

Jun 19 08:28:21 s198.xx.yy.ro systemd[1]: fail2ban.service holdoff
tim....
Jun 19 08:28:21 s198.xx.yy.ro systemd[1]: Stopping Fail2ban Service...
Jun 19 08:28:21 s198.xx.yy.ro systemd[1]: Starting Fail2ban Service...
Jun 19 08:28:22 s198.xx.yy.ro systemd[1]: fail2ban.service: control
pr...5
Jun 19 08:28:22 s198.xx.yy.ro systemd[1]: Failed to start Fail2ban
Ser....
Jun 19 08:28:22 s198.xx.yy.ro systemd[1]: Unit fail2ban.service
entere....
Jun 19 08:28:22 s198.xx.yy.ro systemd[1]: fail2ban.service holdoff
tim....
Jun 19 08:28:22 s198.xx.yy.ro systemd[1]: Stopping Fail2ban Service...
Jun 19 08:28:22 s198.xx.yy.ro systemd[1]: Starting Fail2ban Service...
Jun 19 08:28:22 s198.xx.yy.ro systemd[1]: fail2ban.service: control
pr...5

[cristi@s198 ~]$ sudo grep fail2ban-client /var/log/audit/audit.log |
audit2allow -M myfail2ban_client
[sudo] password for cristi: 
******************** IMPORTANT ***********************
To make this policy package active, execute:

semodule -i myfail2ban_client.pp

[cristi@s198 ~]$ sudo semodule -i myfail2ban_client.pp

[cristi@s198 ~]$ sudo systemctl restart fail2ban.service

[cristi@s198 ~]$ systemctl status fail2ban.servicefail2ban.service -
Fail2ban Service
   Loaded: loaded (/usr/lib/systemd/system/fail2ban.service; enabled)
   Active: active (running) since Wed 2013-06-19 08:33:09 EEST; 7s ago
  Process: 2083 ExecStart=/usr/bin/fail2ban-client -x start
(code=exited, status=0/SUCCESS)
 Main PID: 2086 (fail2ban-server)
   CGroup: name=systemd:/system/fail2ban.service
           └─2086 /usr/bin/python /usr/bin/fail2ban-server -b
-s /var/run/fai...

Jun 19 08:33:09 s198.xx.yy.ro fail2ban-server[2086]:
fail2ban.server : ...
Jun 19 08:33:09 s198.xx.yy.ro fail2ban-server[2086]:
fail2ban.jail   : ...
Jun 19 08:33:09 s198.xx.yy.ro fail2ban-server[2086]:
fail2ban.jail   : ...
Jun 19 08:33:09 s198.xx.yy.ro fail2ban-server[2086]:
fail2ban.jail   : ...
Jun 19 08:33:09 s198.xx.yy.ro fail2ban-server[2086]:
fail2ban.filter : ...
Jun 19 08:33:09 s198.xx.yy.ro fail2ban-server[2086]:
fail2ban.filter : ...
Jun 19 08:33:09 s198.xx.yy.ro fail2ban-server[2086]:
fail2ban.filter : ...
Jun 19 08:33:09 s198.xx.yy.ro fail2ban.actions[2086]: INFO   Set
banTim...
Jun 19 08:33:09 s198.xx.yy.ro fail2ban-server[2086]:
fail2ban.jail   : ...
Jun 19 08:33:09 s198.xx.yy.ro systemd[1]: Started Fail2ban Service.


Expected results:

Fail2ban to start without additional selinux modules.

Additional info:

Comment 1 Daniel Walsh 2013-06-19 20:29:32 UTC
commit 892b11ccdd613cc22878402dd1c3c335d9a78fbf fixes this in git.

Comment 2 Fedora Update System 2013-06-19 21:32:32 UTC
selinux-policy-3.12.1-54.fc19 has been submitted as an update for Fedora 19.
https://admin.fedoraproject.org/updates/selinux-policy-3.12.1-54.fc19

Comment 3 Fedora Update System 2013-06-20 18:03:15 UTC
Package selinux-policy-3.12.1-54.fc19:
* should fix your issue,
* was pushed to the Fedora 19 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.12.1-54.fc19'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2013-11355/selinux-policy-3.12.1-54.fc19
then log in and leave karma (feedback).

Comment 4 Fedora Update System 2013-06-23 06:28:06 UTC
selinux-policy-3.12.1-54.fc19 has been pushed to the Fedora 19 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 5 Edgar Hoch 2013-07-03 04:35:28 UTC
Created attachment 768070 [details]
SELinux module policy file fail2ban-var-run.te

I am not sure if this is the same problem as in this bug.
It affects /var/run/fail2ban/ but with selinux-policy-targeted-3.12.1-54.fc19 my problem is not fixed.

When I start fail2ban with
  systemctl start fail2ban.service
then it failed and I get the following message in /var/log/messages:

fail2ban-client[3295]: ERROR  Directory /var/run/fail2ban exists but not accessible for writing


If I set SELinux to permissive then fail2ban starts - with enforcing it fails.

I have not found any SELinux error messages in /var/log/audit/audit.log for fail2ban. To see more, I disables the dontaudit rules temporary. Then I found some SELinux error messages from fail2ban.

I have created a SELinux module file that solves the problem. With that module loaded fail2ban starts without errors.
I am not sure if all rules are neccessary - but selinx reported these as denied access.
See the attachment.


Package versions:
selinux-policy-3.12.1-54.fc19.noarch
selinux-policy-targeted-3.12.1-54.fc19.noarch
fail2ban-0.8.10-1.fc19.noarch

Comment 6 Daniel Walsh 2013-07-03 12:44:25 UTC
Edgar does just adding these rules get everything to work.

The only one I think needed is

allow fail2ban_client_t fail2ban_var_run_t:dir write;
759bd9dfe74a897d26a33fa8f326ec0b64c04e70 adds this in git.

Comment 7 Edgar Hoch 2013-07-03 13:27:06 UTC
I have build a new selinux module with only the rule you have suggested.
It works, fail2ban starts and stops without error.

Daniel, thanks for the evaluation.

Comment 8 Daniel Walsh 2013-07-09 15:23:11 UTC
fixed in selinux-policy-3.12.1-61.fc19

Comment 9 Ed Greshko 2013-07-09 23:51:40 UTC
I've confirmed the fix....  Thanks....

Comment 10 Miroslav Grepl 2013-07-10 07:43:43 UTC
Thank you for testing.

Comment 11 Fedora Update System 2013-07-11 08:57:19 UTC
selinux-policy-3.12.1-63.fc19 has been submitted as an update for Fedora 19.
https://admin.fedoraproject.org/updates/selinux-policy-3.12.1-63.fc19

Comment 12 Fedora Update System 2013-07-12 02:56:59 UTC
Package selinux-policy-3.12.1-63.fc19:
* should fix your issue,
* was pushed to the Fedora 19 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.12.1-63.fc19'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2013-12762/selinux-policy-3.12.1-63.fc19
then log in and leave karma (feedback).

Comment 13 Fedora Update System 2013-07-14 03:38:02 UTC
selinux-policy-3.12.1-63.fc19 has been pushed to the Fedora 19 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 14 Michael Gruys 2013-12-25 19:04:39 UTC
Not fixed in fc20 3.12.5-302.fc20.x86_64

Comment 15 Michael Gruys 2013-12-25 23:26:26 UTC
Please ignore my previous comment #14.
I had to install systemd-python as described

In the /etc/fail2ban/jail.conf the backend was set to auto.

I changed this to: backend = systemd

It works like a charm.


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