SELinux的故障排除技巧
作者:Rex Kang
本文是作者在Puppet部署報錯后,嘗試關(guān)閉了SELinux,之后就正常??墒窃跍y試環(huán)境中就沒這個問題。系統(tǒng)環(huán)境基本一致??纯催@個故障是如何排查出來的。
剛剛采用Puppet部署了dokuwiki,不過配置完成后報錯:
DokuWiki Setup Error The datadir ('pages') at /pages is not found, isn't accessible or writable. You should check your config and permission settings. Or maybe you want to run the installer?
嘗試關(guān)閉了SELinux,之后就正常??墒窃跍y試環(huán)境中就沒這個問題。系統(tǒng)環(huán)境基本一致。
于是查看了下audit.log:
tail -f /var/log/audit/audit.log | grep -i httpd
type=AVC msg=audit(1377479847.165:7269): avc: denied { search } for pid=11160 comm="httpd" name="/" dev=dm-2 ino=2 scontext=unconfined_u:system_r:httpd_t:s0 tcontext=system_u:object_r:file_t:s0 tclass=dir type=SYSCALL msg=audit(1377479847.165:7269): arch=40000003 syscall=33 success=no exit=-13 a0=1ebef68 a1=0 a2=1323e18 a3=f items=0 ppid=11149 pid=11160 auid=0 uid=48 gid=48 euid=48 suid=48 fsuid=48 egid=48 sgid=48 fsgid=48 tty=(none) ses=1122 comm="httpd" exe="/usr/sbin/httpd" subj=unconfined_u:system_r:httpd_t:s0 key=(null) type=AVC msg=audit(1377479847.166:7270): avc: denied { search } for pid=11160 comm="httpd" name="/" dev=dm-2 ino=2 scontext=unconfined_u:system_r:httpd_t:s0 tcontext=system_u:object_r:file_t:s0 tclass=dir type=SYSCALL msg=audit(1377479847.166:7270): arch=40000003 syscall=33 success=no exit=-13 a0=1ec5a58 a1=0 a2=1323e18 a3=f items=0 ppid=11149 pid=11160 auid=0 uid=48 gid=48 euid=48 suid=48 fsuid=48 egid=48 sgid=48 fsgid=48 tty=(none) ses=1122 comm="httpd" exe="/usr/sbin/httpd" subj=unconfined_u:system_r:httpd_t:s0 key=(null) type=AVC msg=audit(1377479847.166:7271): avc: denied { search } for pid=11160 comm="httpd" name="/" dev=dm-2 ino=2 scontext=unconfined_u:system_r:httpd_t:s0 tcontext=system_u:object_r:file_t:s0 tclass=dir type=SYSCALL msg=audit(1377479847.166:7271): arch=40000003 syscall=33 success=no exit=-13 a0=1eafc54 a1=0 a2=1323e18 a3=f items=0 ppid=11149 pid=11160 auid=0 uid=48 gid=48 euid=48 suid=48 fsuid=48 egid=48 sgid=48 fsgid=48 tty=(none) ses=1122 comm="httpd" exe="/usr/sbin/httpd" subj=unconfined_u:system_r:httpd_t:s0 key=(null) type=AVC msg=audit(1377479847.166:7272): avc: denied { search } for pid=11160 comm="httpd" name="/" dev=dm-2 ino=2 scontext=unconfined_u:system_r:httpd_t:s0 tcontext=system_u:object_r:file_t:s0 tclass=dir type=SYSCALL msg=audit(1377479847.166:7272): arch=40000003 syscall=33 success=no exit=-13 a0=1eafcb8 a1=0 a2=1323e18 a3=f items=0 ppid=11149 pid=11160 auid=0 uid=48 gid=48 euid=48 suid=48 fsuid=48 egid=48 sgid=48 fsgid=48 tty=(none) ses=1122 comm="httpd" exe="/usr/sbin/httpd" subj=unconfined_u:system_r:httpd_t:s0 key=(null) type=AVC msg=audit(1377479847.166:7273): avc: denied { search } for pid=11160 comm="httpd" name="/" dev=dm-2 ino=2 scontext=unconfined_u:system_r:httpd_t:s0 tcontext=system_u:object_r:file_t:s0 tclass=dir type=SYSCALL msg=audit(1377479847.166:7273): arch=40000003 syscall=33 success=no exit=-13 a0=1eb04e8 a1=0 a2=1323e18 a3=f items=0 ppid=11149 pid=11160 auid=0 uid=48 gid=48 euid=48 suid=48 fsuid=48 egid=48 sgid=48 fsgid=48 tty=(none) ses=1122 comm="httpd" exe="/usr/sbin/httpd" subj=unconfined_u:system_r:httpd_t:s0 key=(null) type=AVC msg=audit(1377479847.166:7274): avc: denied { search } for pid=11160 comm="httpd" name="/" dev=dm-2 ino=2 scontext=unconfined_u:system_r:httpd_t:s0 tcontext=system_u:object_r:file_t:s0 tclass=dir type=SYSCALL msg=audit(1377479847.166:7274): arch=40000003 syscall=33 success=no exit=-13 a0=1eb0624 a1=0 a2=1323e18 a3=f items=0 ppid=11149 pid=11160 auid=0 uid=48 gid=48 euid=48 suid=48 fsuid=48 egid=48 sgid=48 fsgid=48 tty=(none) ses=1122 comm="httpd" exe="/usr/sbin/httpd" subj=unconfined_u:system_r:httpd_t:s0 key=(null) |
HOHO,第一次處理SELinux的故障,看到其中的name、dev以及scontext和tcontext,于是在“/”下找找:
[root@localhost /]# ll -Z / drwxr-xr-x. apache apache system_u:object_r:file_t:s0 wiki
后來發(fā)現(xiàn)是因為將wiki的目錄建在了“/”下面,并重新掛載了一個分區(qū),重新賦予權(quán)限就好了
[root@localhost /]# chcon -t httpd_t /wiki
對SELinux的了解還是太淺,呵呵。
責(zé)任編輯:黃丹
來源:
博客