Hi, Some time ago I had SELinux problems with Fail2ban. One of the users on this list suggested that it might be due to the fact that I'm using a bone-headed iptables script instead of FirewallD. I've spent the past few weeks getting up to date with doing things in a more orthodox manner. So currently my internet-facing CentOS server has a nicely configured NetworkManager, and FirewallD has replaced the iptables script. Unfortunately when I install FirewallD from EPEL, I still get the same error. SELinux is preventing /usr/bin/python2.7 from read access on the file disable. ***** Plugin catchall (100. confidence) suggests ***** If you believe that python2.7 should be allowed read access on the disable 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: # ausearch -c 'f2b/server' --raw | audit2allow -M my-f2bserver # semodule -i my-f2bserver.pp Weirdly enough, when I follow this suggestion and then empty audit.log and restart my server, I still get the exact same error again. Which makes Fail2ban unusable with SELinux in enforcing mode in the current state. Any suggestions ? Niki -- Microlinux - Solutions informatiques durables 7, place de l'?glise - 30730 Montpezat Site : https://www.microlinux.fr Mail : info at microlinux.fr T?l. : 04 66 63 10 32 Mob. : 06 51 80 12 12
Le 26/02/2020 ? 11:51, Nicolas Kovacs a ?crit?:> SELinux is preventing /usr/bin/python2.7 from read access on the file disable. > > *****? Plugin catchall (100. confidence) suggests?? ***** > > If you believe that python2.7 should be allowed read access on the disable 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: > # ausearch -c 'f2b/server' --raw | audit2allow -M my-f2bserver > # semodule -i my-f2bserver.pp > > Weirdly enough, when I follow this suggestion and then empty audit.log and > restart my server, I still get the exact same error again.I reinstalled this server from scratch and took some notes. This time I was successful, though I don't know exactly what I did differently this time. Usually I work as non-root user and call sudo whenever I need root permissions. But is this OK when enabling SELinux modules? Let's consider the example given above: # ausearch -c 'f2b/server' --raw | audit2allow -M my-f2bserver # semodule -i my-f2bserver.pp Can I also perform it like this? $ sudo ausearch -c 'f2b/server' --raw | sudo audit2allow -M my-f2bserver $ sudo semodule -i my-f2bserver.pp I'm not sure with SELinux. Cheers, Niki -- Microlinux - Solutions informatiques durables 7, place de l'?glise - 30730 Montpezat Site : https://www.microlinux.fr Mail : info at microlinux.fr T?l. : 04 66 63 10 32 Mob. : 06 51 80 12 12
On Feb 26, 2020, at 08:52, Nicolas Kovacs <info at microlinux.fr> wrote:> >> Le 26/02/2020 ? 11:51, Nicolas Kovacs a ?crit : >> SELinux is preventing /usr/bin/python2.7 from read access on the file disable. >> ***** Plugin catchall (100. confidence) suggests ***** >> If you believe that python2.7 should be allowed read access on the disable 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: >> # ausearch -c 'f2b/server' --raw | audit2allow -M my-f2bserver >> # semodule -i my-f2bserver.pp >> Weirdly enough, when I follow this suggestion and then empty audit.log and restart my server, I still get the exact same error again. > > I reinstalled this server from scratch and took some notes. This time I was successful, though I don't know exactly what I did differently this time. > > Usually I work as non-root user and call sudo whenever I need root permissions. > > But is this OK when enabling SELinux modules? Let's consider the example given above: > > # ausearch -c 'f2b/server' --raw | audit2allow -M my-f2bserver > # semodule -i my-f2bserver.pp > > Can I also perform it like this? > > $ sudo ausearch -c 'f2b/server' --raw | sudo audit2allow -M my-f2bserver > $ sudo semodule -i my-f2bserver.pp > > I'm not sure with SELinux.https://bugzilla.redhat.com/show_bug.cgi?id=1777562 This bug was posted earlier. Sadly, it was closed WONTFIX, but the policy you need is: allow fail2ban_t sysfs_t:file { getattr open read }; allow fail2ban_t sysctl_net_t:dir { search }; allow fail2ban_t sysctl_net_t:file { getattr open read }; Honestly, if this really affects all users of fail2ban, I?ll probably push back on the ticket to get it updated. I?ve successfully had the policy updated to handle issues with popular non-RHEL/CentOS packages. -- Jonathan Billings
On Wed, 26 Feb 2020, Nicolas Kovacs wrote:>Some time ago I had SELinux problems with Fail2ban.>Unfortunately when I install [...] from EPEL, I still get the same error.EPEL packages are often crap quality (as packages), merely blind imports of the upstream package without any adjustments needed for the RHEL/CentOS environment (sometimes not even for Fedora), which is often somewhat different than the Fedora environment which go unnoticed or unrepaired, for years.> If you believe that python2.7 should be allowed read access on the disable > file by default. > Then you should report this as a bug.Have you reported it? To the Fail2Ban EPEL package maintainer, not to the (upstream) Fail2Ban maintainers, nor the CentOS (thus RHEL) Python package maintainer, nor the Python maintainers, i.e., the issue is that the EPEL Fail2Ban package does not (seem to, based on your message) have the correct RHEL/CentOS SELinux definitions.> You can generate a local policy module to allow this access.>Weirdly enough, when I follow this suggestion and then empty audit.log and >restart my server, I still get the exact same error again.This sometimes needs multiple iterations to catch all the types of access attempted, e.g., initially it might be that read is denied, but later the process would want other permissions like write but which were never logged because of the initial read failure.>Any suggestions ?Try repeating. That either means multiple binary modules, or a text module that you add each new audit2allow "fix", increment the version number, rebuild the policy and module then re-insert -- lather, rinse, ... /mark
On Thu, 2020-02-27 at 02:49 -0800, Mark Milhollan wrote:> On Wed, 26 Feb 2020, Nicolas Kovacs wrote: > > > Some time ago I had SELinux problems with Fail2ban. > > Unfortunately when I install [...] from EPEL, I still get the same > > error. > > EPEL packages are often crap quality (as packages), merely blind > imports > of the upstream package without any adjustments needed for the > RHEL/CentOS environment (sometimes not even for Fedora), which is > often > somewhat different than the Fedora environment which go unnoticed or > unrepaired, for years.This sounds a bit harsh. But I had my problems with fail2ban too.> > > > > This sometimes needs multiple iterations to catch all the types of > access attempted, e.g., initially it might be that read is denied, > but > later the process would want other permissions like write but which > were > never logged because of the initial read failure. > > > Any suggestions ? > > Try repeating. That either means multiple binary modules, or a text > module that you add each new audit2allow "fix", increment the > version > number, rebuild the policy and module then re-insert -- lather, > rinse, > ...A better way is to put selinux in permissive mode and then generate the policy from the alerts. This will disable the blocking so you can get all issues in one go /Louis
On 2/26/20 9:52 AM, Nicolas Kovacs wrote:> Le 26/02/2020 ? 11:51, Nicolas Kovacs a ?crit?: >> SELinux is preventing /usr/bin/python2.7 from read access on the file >> disable. >> >> *****? Plugin catchall (100. confidence) suggests?? ***** >> >> If you believe that python2.7 should be allowed read access on the >> disable 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: >> # ausearch -c 'f2b/server' --raw | audit2allow -M my-f2bserver >> # semodule -i my-f2bserver.pp >> >> Weirdly enough, when I follow this suggestion and then empty audit.log >> and restart my server, I still get the exact same error again. > > I reinstalled this server from scratch and took some notes. This time I > was successful, though I don't know exactly what I did differently this > time. > > Usually I work as non-root user and call sudo whenever I need root > permissions. > > But is this OK when enabling SELinux modules? Let's consider the example > given above: > > # ausearch -c 'f2b/server' --raw | audit2allow -M my-f2bserver > # semodule -i my-f2bserver.pp > > Can I also perform it like this? > > $ sudo ausearch -c 'f2b/server' --raw | sudo audit2allow -M my-f2bserver > $ sudo semodule -i my-f2bserver.ppThis should work. Likely the reason that it didn't resolve in one go is that there were multiple denials - but the first time it just failed on the first one. Someone else mentioned running in non-enforcing mode to allow the audit log to collect all of the denials and then generating the module - this is a good practice. -- Orion Poplawski Manager of NWRA Technical Systems 720-772-5637 NWRA, Boulder/CoRA Office FAX: 303-415-9702 3380 Mitchell Lane orion at nwra.com Boulder, CO 80301 https://www.nwra.com/