我正在使用提供大部分存储在/ data磁盘上的那些云VPS提供程序之一,因此我的webroot是/data/www
而不是/var/www
。并且有一个符号链接,以便Apache在默认配置下可以正常工作。
我认为目标是复制下的所有规则/var/www
并创建相同的规则,只是/var/www
将更改为/data/www
。有没有办法快速做到这一点?
[~]$ sudo semanage fcontext -l | grep -i /var/www
/var/www(/.*)? all files system_u:object_r:httpd_sys_content_t:s0
/var/www(/.*)?/logs(/.*)? all files system_u:object_r:httpd_log_t:s0
/var/www/[^/]*/cgi-bin(/.*)? all files system_u:object_r:httpd_sys_script_exec_t:s0
/var/www/apcupsd/multimon\.cgi regular file system_u:object_r:apcupsd_cgi_script_exec_t:s0
... many more ...
我只知道如何通过以下方式一个接一个地做这些事情:
sudo semanage fcontext -a -t httpd_sys_content_t "/data/www(/.*)?"
sudo restorecon -R -v /data/www
这照顾到第一个规则。有没有办法快速做到这一点?
您是否在寻找替代品?来自man semanage-fcontext
:
选项
例子
-e EQUAL
,--equal EQUAL
生成默认标签时,将目标路径替换为sourcepath。与一起使用
fcontext
。需要源路径和目标路径参数。使目标子树的上下文标签等同于为源子树定义的上下文标签。
︙
设置文件上下文时 替换/home1
为/home
# semanage fcontext -a -e /home /home1 # restorecon -R -v /home1
演示:
mkdir -p /data/www2/html
touch /data/www2/html/foo
semanage fcontext -a -e /var/www /data/www2
restorecon -R /data/www2
ls -lhZ /data/www2/html/
-rw-r--r--. 1 root root unconfined_u:object_r:httpd_sys_content_t:s0 0 15. Jul 15:31 foo
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句