我有一个简单的场景:我想符号链接/home/leonard/apache/sandbox/markdown
到/home/leonard/github/markdown-editor
,以便markdown-editor
可以从我的浏览器中查看。
我设置了链接,ln -s /home/leonard/github/markdown-editor /home/leonard/apache/sandbox/public/markdown
它显示出来并且可以很好地导航。
但是,当我在浏览器中查看时,我得到403 Forbidden
. 我audit.log
的显示如下:
type=AVC msg=audit(1461759062.021:1232192): avc: denied { read } for pid=30107 comm="httpd" name="markdown" dev=md2 ino=25300345 scontext=unconfined_u:system_r:httpd_t:s0 tcontext=unconfined_u:object_r:user_home_t:s0 tclass=lnk_file
type=SYSCALL msg=audit(1461759062.021:1232192): arch=c000003e syscall=4 success=no exit=-13 a0=7f88e34cff28 a1=7ffc036e2dd0 a2=7ffc036e2dd0 a3=7f88dec032e0 items=0 ppid=36009 pid=30107 auid=0 uid=48 gid=48 euid=48 suid=48 fsuid=48 egid=48 sgid=48 fsgid=48 tty=(none) ses=88286 comm="httpd" exe="/usr/sbin/httpd" subj=unconfined_u:system_r:httpd_t:s0 key=(null)
type=AVC msg=audit(1461759062.022:1232193): avc: denied { getattr } for pid=30107 comm="httpd" path="/home/leonard/apache/sandbox/public/markdown" dev=md2 ino=25300345 scontext=unconfined_u:system_r:httpd_t:s0 tcontext=unconfined_u:object_r:user_home_t:s0 tclass=lnk_file
type=SYSCALL msg=audit(1461759062.022:1232193): arch=c000003e syscall=6 success=no exit=-13 a0=7f88e34d0018 a1=7ffc036e2dd0 a2=7ffc036e2dd0 a3=1 items=0 ppid=36009 pid=30107 auid=0 uid=48 gid=48 euid=48 suid=48 fsuid=48 egid=48 sgid=48 fsgid=48 tty=(none) ses=88286 comm="httpd" exe="/usr/sbin/httpd" subj=unconfined_u:system_r:httpd_t:s0 key=(null)
我在这里看到了其他问题,询问如何设置符号链接的上下文,但我不确定它们是否相关,因为链接与其他(在浏览器中完全可以查看)相邻目录相同:
[leonard@ombrelle public]$ ls -alZ
drwxr-xr-x. leonard developers unconfined_u:object_r:user_home_t:s0 .
drwxr-xr-x. leonard developers unconfined_u:object_r:user_home_t:s0 ..
-rw-r--r--. leonard developers unconfined_u:object_r:user_home_t:s0 .htaccess
-rw-r--r--. leonard developers unconfined_u:object_r:user_home_t:s0 index.php
lrwxrwxrwx. leonard developers unconfined_u:object_r:user_home_t:s0 markdown -> /home/leonard/github/markdown-editor
drwxr-xr-x. leonard developers unconfined_u:object_r:user_home_t:s0 notes
我怎样才能让符号链接以这种方式工作?
更新
使用伊恩的回答,我跑了audit2why < /var/log/audit/audit.log
,得到了:
type=AVC msg=audit(1461761590.750:1232443): avc: denied { getattr } for pid=37683 comm="httpd" path="/home/leonard/apache/sandbox/public/markdown" dev=md2 ino=25300345 scontext=unconfined_u:system_r:httpd_t:s0 tcontext=unconfined_u:object_r:user_home_t:s0 tclass=lnk_file
Was caused by:
The boolean httpd_enable_homedirs was set incorrectly.
Description:
Allow httpd to read home directories
Allow access by executing:
# setsebool -P httpd_enable_homedirs 1
运行setsebool
命令神奇地使它工作。我只是不确定/home/*/apache/sitename.tld
在没有启用此功能的情况下,我们拥有的所有其他站点 () 是如何工作的?