SELinux : Use SETroubleShoot
2021/03/02 |
To use SETroubleShoot, it's possible to generate additional information for solving SELinux related troubles.
|
|
[1] |
Messages from SETroubleShoot are sent by Audit Event Dispatcher to Systemd Journald. (or [/var/log/messages] if Rsyslog enabled)
So it needs to run Auditd, refer to here. |
[2] | SETroubleShoot is installed by default if Base Environment is [Server] or others, but if not, Install it. |
[root@dlp ~]# dnf -y install setroubleshoot-server
|
[3] | Additional logs for AVC denial are recorded to Systemd Journald or [/var/log/messages] if Rsyslog is enabled. The logs follows are the one in [/var/log/messages]. |
[root@dlp ~]# grep -E 'setroubleshoot|preventing' /var/log/messages Mar 2 15:01:06 dlp setroubleshoot[1533]: SELinux is preventing /usr/sbin/httpd from name_bind access on the tcp_socket port 85. For complete SELinux messages run: sealert -l e5e65eb1-dfed-4e0f-8a92-ceaf39781df9 Mar 2 15:01:06 dlp setroubleshoot[1533]: SELinux is preventing /usr/sbin/httpd from name_bind access on the tcp_socket port 85.#012#012***** Plugin bind_ports (99.5 confidence) suggests ************************#012#012If you want to allow /usr/sbin/httpd to bind to network port 85#012Then you need to modify the port type.#012Do#012# semanage port -a -t PORT_TYPE -p tcp 85#012 where PORT_TYPE is one of the following: http_cache_port_t, http_port_t, jboss_management_port_t, jboss_messaging_port_t, ntop_port_t, puppet_port_t.#012#012***** Plugin catchall (1.49 confidence) suggests **************************#012#012If you believe that httpd should be allowed name_bind access on the port 85 tcp_socket by default.#012Then you should report this as a bug.#012You can generate a local policy module to allow this access.#012Do#012allow this access for now by executing:#012# ausearch -c 'httpd' --raw | audit2allow -M my-httpd#012# semodule -X 300 -i my-httpd.pp#012 |
[4] | For the 2nd line on the example above, a command is given to see more details and it displays logs like follows. |
[root@dlp ~]# sealert -l e5e65eb1-dfed-4e0f-8a92-ceaf39781df9 SELinux is preventing /usr/sbin/httpd from name_bind access on the tcp_socket port 85. ***** Plugin bind_ports (99.5 confidence) suggests ************************ If you want to allow /usr/sbin/httpd to bind to network port 85 Then you need to modify the port type. Do # semanage port -a -t PORT_TYPE -p tcp 85 where PORT_TYPE is one of the following: http_cache_port_t, http_port_t, jboss_management_port_t, jboss_messaging_port_t, ntop_port_t, puppet_port_t. ***** Plugin catchall (1.49 confidence) suggests ************************** If you believe that httpd should be allowed name_bind access on the port 85 tcp_socket 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 'httpd' --raw | audit2allow -M my-httpd # semodule -X 300 -i my-httpd.pp Additional Information: Source Context system_u:system_r:httpd_t:s0 Target Context system_u:object_r:reserved_port_t:s0 Target Objects port 85 [ tcp_socket ] Source httpd Source Path /usr/sbin/httpd Port 85 Host dlp.srv.world Source RPM Packages httpd-2.4.37-30.module_el8.3.0+462+ba287492.0.1.x8 6_64 Target RPM Packages SELinux Policy RPM selinux-policy-targeted-3.14.3-64.el8.noarch Local Policy RPM selinux-policy-targeted-3.14.3-64.el8.noarch Selinux Enabled True Policy Type targeted Enforcing Mode Enforcing Host Name dlp.srv.world Platform Linux dlp.srv.world 4.18.0-277.el8.x86_64 #1 SMP Wed Feb 3 20:35:19 UTC 2021 x86_64 x86_64 Alert Count 6 First Seen 2021-02-25 13:52:38 JST Last Seen 2021-03-02 15:01:01 JST Local ID e5e65eb1-dfed-4e0f-8a92-ceaf39781df9 Raw Audit Messages type=AVC msg=audit(1614664861.679:94): avc: denied { name_bind } for pid=1161 comm="httpd" src=85 scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:object_r:reserved_port_t:s0 tclass=tcp_socket permissive=0 type=SYSCALL msg=audit(1614664861.679:94): arch=x86_64 syscall=bind success=no exit=EACCES a0=3 a1=55d8544028c0 a2=10 a3=7ffdc187063c items=0 ppid=1 pid=1161 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm=httpd exe=/usr/sbin/httpd subj=system_u:system_r:httpd_t:s0 key=(null) Hash: httpd,httpd_t,reserved_port_t,tcp_socket,name_bind |