SELinux的故障排除技巧

运维 系统运维
本文是作者在Puppet部署报错后,尝试关闭了SELinux,之后就正常。可是在测试环境中就没这个问题。系统环境基本一致。看看这个故障是如何排查出来的。

刚刚采用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?

尝试关闭了SELinux,之后就正常。可是在测试环境中就没这个问题。系统环境基本一致。

于是查看了下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

后来发现是因为将wiki的目录建在了“/”下面,并重新挂载了一个分区,重新赋予权限就好了

[root@localhost /]# chcon -t httpd_t /wiki

对SELinux的了解还是太浅,呵呵。

责任编辑:黄丹 来源: 博客
相关推荐

2013-01-16 08:56:53

iOS故障排除指南

2009-12-22 16:09:09

2023-07-26 15:46:52

Docker管理容器

2013-05-06 16:36:55

SELinuxSELinux故障

2011-05-10 09:54:13

打印机故障排除

2023-08-31 16:43:46

软件开发调试

2011-05-06 15:22:19

打印机故障排除

2011-04-27 14:04:16

打印机故障

2011-02-21 15:48:19

2010-08-26 10:10:18

宽带路由器

2010-04-01 18:22:36

无线交换机故障

2011-08-10 14:03:53

2021-01-25 09:05:21

Kubernetes命令运维

2020-10-13 12:21:59

Kubernetes程序技巧

2010-03-19 17:44:22

服务器RAIDRAID 5故障

2013-07-25 14:50:03

2020-03-03 10:47:47

LinuxSystemdDocker

2011-08-03 10:48:07

2010-09-28 15:42:36

DHCP服务故障排除

2010-04-19 21:25:33

IOS软件
点赞
收藏

51CTO技术栈公众号