allow httpd_t home_root_t : dir { ioctl read getattr lock search open } ;
allow httpd_t home_root_t : lnk_file { read getattr } ;
allow httpd_t user_home_type : dir { getattr search open } ;
allow httpd_t user_home_type : lnk_file { read getatt
r } ;
....(
后面省略
)....
#
从
上面的
数
据才可以理½,在
这个规则
中,主要是放行
httpd_t
能否
读
取用
户
家目
录
的
文件
!
#
所以,如果
这个规则没
有
启动
,基本上,
httpd_t
这
种
½
程就
无
法
读
取用
户
家目
录
下的
文件
!
.
修改
SELinux
规则的布尔值
setsebool
那么如果查询到某个
SELinux rule
,并且以
sesearch
知道该规则的用途后,想要关闭或启动他,又
该如何处置?
[root@study ~]#
setsebool [
-
P]
『
规则
名
称
』
[0|1]
选项
与
参数
:
-
P
:直½
½设
定值
写
入配置文件,
该设
定
数
据未
来会
生效的!
范例一:查
询
httpd_enable_homedirs
这个规则
的
状态
,并且修改
这个规则
成
为
不同的布
尔
值
[root@study ~]#
getsebool httpd_enable_homedirs
httpd_enable_homedirs
--
>
off
<==
½
果是
off
,依
题
意
给
他
启动
看看!
[root@study ~]#
setsebool
-
P httpd_enable_homedirs 1
#
会
跑很久很久!
请
耐心等待!
[root@study ~]#
getsebool httpd_enable_homedirs
httpd_enable_homedirs
--
>
on
这个
setsebool
最好记得一定要加上
-P
的选项!因为这样才能½此设定写入配置文件!
这是非常
棒的工具组!你一定要知道如何使用
getsebool
与
setsebool
才行!
16.5.5 SELinux
安全本文的修改
再次的回到
图
16.5.4
上头去,现在我们知道
SELinux
对受限的主体½程有没有影响,第一关考虑
SELinux
的三种类型,第二关考虑
SELinux
的政策规则是否放行,第三关则是开始比对
SELinux
type
啦!从刚刚
16.5.4
小½我们也知道可以透过
sesearch
来找到主体½程与文件的
SELinux type
关系!
好,现在总算要来修改文件的
SELinux type
,以让主体½程能够读到正确的文件啊!这时就
得要几个重要的小东西了~来瞧瞧~
.
使用
chcon
手动修改
文件
的
SELinux type
[root@study ~]#
chcon [
-
R] [
-
t type] [
-
u user] [
-
r role]
文件
[root@study ~]#
chcon [
-
R]
--
reference=
范例文件
文件
选项
与
参数
:
-
R
:
连
同
该
目
录
下的次目
录
也同
时
修改;
-
t
:后面½安全性本文的
类
型字段!例如
httpd_sys_content_t
;