[root@kvm8 ~]# ll /var/www/html/ total 8 -rw-r--r--. 1 root root 10 Nov 6 20:55 file1 -rw-r--r--. 1 root root 10 Nov 6 21:18 file2
[root@kvm8 ~]# curl http://127.0.0.1:82/file1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html><head> <title>403 Forbidden</title> </head><body> <h1>Forbidden</h1> <p>You don't have permission to access /file1 on this server.<br /> </p> </body></html>
admin_home_t
,file2 是 httpd_sys_contect
。
[root@kvm8 ~]# ls -Z /var/www/html/ system_u:object_r:admin_home_t:s0 file1 system_u:object_r:httpd_sys_content_t:s0 file2
[root@kvm8 ~]# restorecon -Rv /var/www/html/
admin_home_t
。
[root@kvm8 ~]# ls -Z /var/www/html/ system_u:object_r:admin_home_t:s0 file1 system_u:object_r:httpd_sys_content_t:s0 file2
admin_home_t
。
[root@kvm8 ~]# cat /etc/selinux/targeted/contexts/files/file_contexts.local # This file is auto-generated by libsemanage # Do not edit directly. /var/www/html/file1 system_u:object_r:admin_home_t:s0
admin_home_t
。
[root@kvm8 ~]# semanage fcontext -d -t admin_home_t /var/www/html/file1
[root@kvm8 ~]# cat /etc/selinux/targeted/contexts/files/file_contexts.local # This file is auto-generated by libsemanage # Do not edit directly.
[root@kvm8 ~]# restorecon -Rv /var/www/html/ Relabeled /var/www/html/file1 from system_u:object_r:admin_home_t:s0 to system_u:object_r:httpd_sys_content_t:s0
httpd_sys_contect
。
[root@kvm8 ~]# ls -Z /var/www/html/ system_u:object_r:httpd_sys_content_t:s0 file1 system_u:object_r:httpd_sys_content_t:s0 file2
[root@kvm8 ~]# curl http://127.0.0.1:82/file1 web test1 [root@kvm8 ~]# curl http://127.0.0.1:82/file2 web test2