Goal
Break a service on purpose, find the SELinux denial in the logs, understand it, and fix it the right way.
Before you start
- Finish lab 22.1. Work as root.
Tasks
Tick a task when it is done. Only your browser remembers it.
- Install
setroubleshoot-serverandselinux-policy-doc. - Run
chcon -t user_home_t /web/index.htmland request the page. Find the AVC message, name the source type, target type and class, and fix the problem. - Change the sshd port to 2222 in a drop-in file without a SELinux change. Restart sshd, see it fail, find the denial, and fix it. Restore port 22 afterwards (or keep both ports).
- Set only
httpd_tto permissive, check that SELinux is still enforcing for the rest, then undo it. - Use the man page of httpd to find the boolean that allows Apache to connect to a database over the network.
Check your work
ausearch -m AVC -ts today | grep -c denied
ls -Z /web/index.html
semanage port -l | grep ssh_port_t
semanage permissive -l- The web page works again;
index.htmlhashttpd_sys_content_t. - sshd runs;
ssh_port_thas 2222. semanage permissive -lshows no httpd_t at the end.- Boolean:
httpd_can_network_connect_db.
Hints
Show the hints
ausearch -m AVC -ts recent,sealert -a /var/log/audit/audit.log,journalctl -t setroubleshoot.- The fix for a label is restorecon, for a port semanage port.
semanage permissive -a httpd_t/-d.man httpd_selinux, search for "database".
Solution
Show the solution
- Tools.
dnf install -y setroubleshoot-server selinux-policy-doc - Label problem.
chcon -t user_home_t /web/index.html curl -s -o /dev/null -w '%{http_code}\n' http://localhost/ 403 ausearch -m AVC -ts recent | grep index.html restorecon -v /web/index.html - Port problem.
- Permissive domain.
semanage permissive -a httpd_t getenforce semanage permissive -d httpd_t - Find the boolean.
My notes
No notes yet.