1.5 KiB
1.5 KiB
LFCS 1.8: SELinux
Labels for a new web content location, a moved file, a new sshd port, a boolean, and the boot mode. Keep SELinux enforcing throughout.
Before you start
RHEL family only. The lab installs policycoreutils-python-utils (for
semanage) and adds a small service that notes the SELinux mode at every
boot, so task 5 can be checked. No web server is installed.
Tasks
- Serve web pages from
/srv/webwith httpd or nginx, as the document root ofhttp://localhost/.curl localhostreturns your/srv/web/index.html, andls -Zd /srv/webshowshttpd_sys_content_t, still aftersudo restorecon -Rv /srv/web. - Create a page
moved.htmlin your home directory,mvit into/srv/web, see it fail, and fix it.curl localhost/moved.htmlreturns the page. - Make sshd listen on port 2222 as well as 22.
ssh -p 2222 localhostconnects, andsudo semanage port -l | grep sshlists 2222. - Allow the web server to make outbound network connections, persistently.
- Make the system boot in permissive mode, reboot, then set it back to
enforcing for good.
getenforceshowsPermissiveafter the first reboot andEnforcingafter the second.
Hints
semanage fcontext -a -t ... '/srv/web(/.*)?',restorecon -Rv,matchpathcon; the web server's document root setting.ls -Z,ausearch -m AVC -ts recent,restorecon -v.semanage port -a -t ssh_port_t -p tcp, a file in/etc/ssh/sshd_config.d/,sshd -t.getsebool,setsebool -P./etc/selinux/config,getenforce,setenforce.