SELinux and file contexts

apache root document folder was changed from normal folder to /repos folder attempting to get index.html resutls in an error [root@server01 repos]# curl localhost/index.html Forbidden You don't have permission to access /index.html on this server. set the correct context on the new folder [root@server01 repos]# semanage fcontext -a -t httpd_sys_content_t "/repos(/.*)?" check the context [root@server01 repos]# ls -laZ total 4 drwxr-s---. 2 root apache unconfined_u:object_r:default_t:s0 24 Oct 29 14:57 . dr-xr-xr-x. 18 root root system_u:object_r:root_t:s0 237 Oct 29 14:56 .. -rw-r--r--. 1 root apache unconfined_u:object_r:default_t:s0 6 Oct 29 14:57 index.html it has not applied it, is has only made the change in the policy. apply the new policy to the folder [root@server01 repos]# restorecon -R -v /repos Relabeled /repos from unconfined_u:object_r:default_t:s0 to unconfined_u:object_r:httpd_sys_content_t:s0 Relabeled /repos/index.html from unconfined_u:object_r:default_t:s0 to unconfined_u:object_r:httpd_sys_content_t:s0 check folder now has new permissions/context [root@server01 repos]# ls -laZ total 4 drwxr-s---. 2 root apache unconfined_u:object_r:httpd_sys_content_t:s0 24 Oct 29 14:57 . dr-xr-xr-x. 18 root root system_u:object_r:root_t:s0 237 Oct 29 14:56 .. -rw-r--r--. 1 root apache unconfined_u:object_r:httpd_sys_content_t:s0 6 Oct 29 14:57 index.html test web page is accessable [root@server01 repos]# curl localhost/index.html hello
Tags:

Theme by Danetsoft and Danang Probo Sayekti inspired by Maksimer