Signal9Signal9 — home
online
back to labs

SELinux File Context Rule

MediumRHCSA Prep10-15 min
The brief

Apache's DocumentRoot is moving to a new directory under /srv (the brief, /root/case/brief.txt, names it). Everything under /srv is labeled var_t by default, so on an enforcing box httpd is denied reading it. Add a persistent file-context rule so the new web root and everything beneath it gets httpd_sys_content_t, without widening it to the directory that sits beside it. On a live box you'd then apply it with restorecon -Rv. This lab machine's kernel has SELinux disabled, so labels can't be applied live; grading asks the policy (matchpathcon) what each path will be labeled, which is exactly what restorecon and a boot-time relabel apply.

What you'll do
  • Write a persistent file-context rule with semanage fcontext
  • Scope the rule to one directory tree
  • Know that restorecon applies the rule

Hands-on lab: you work on a real Linux box in your browser, graded on the machine's actual state.