1.4 KiB
1.4 KiB
RHCSA 10.5: SELinux file and process contexts
Web content in a new place, a file moved from /tmp, and what chcon and
restorecon do.
Before you start
SELinux must be enforcing; keep it that way. The lab installs httpd
(serving the default /var/www/html) and policycoreutils-python-utils
(for semanage), and creates /web/index.html, a page that isn't labeled
for the web server yet, and /var/www/html/label.html.
Tasks
- Serve web content from
/web, with SELinux enforcing, persistently:DocumentRoot /webplus<Directory /web>/Require all granted/</Directory>in a file in/etc/httpd/conf.d/. Before the fix,curl http://localhost/gives a403andausearch -m AVC -ts recentshows anhttpddenial for/web; after it,curlshows the page andrestorecon -Rvn /weblists nothing to change. - Create a file
/tmp/page.html,mvit into/var/www/html, and fix it. Write the type it had right after the move to/root/lab-answers/2. - Change the type of
/var/www/html/label.htmlwithchcon, then runrestoreconon it. Write the typerestoreconput back to/root/lab-answers/3.
Hints
httpd -t,systemctl restart httpd;ls -Zd /web;semanage fcontext -a -t httpd_sys_content_t '/web(/.*)?',restorecon -Rv /web;matchpathcon /web.ls -Z,restorecon -v.chcon -t user_home_t FILE,restorecon -v FILE.