[root@study ~]#
sesearch [
-
A] [
-
s
主体
类别
] [
-
t
目
标类别
] [
-
b
布
尔
值
]
选项
与
参数
:
-
A
:列出后面
数
据中,允
许
『
读
取或放行』的相
关数
据
-
t
:后面
还
要½
类别
,例如
-
t httpd_t
-
b
:后面
还
要½
SELinux
的
规则
,例如
-
b httpd_enable_ftp_server
范例一:找出
crond_t
这个
主体
½
程能
够读
取的
文件
SELinux type
[root@study ~]#
sesearch
-
A
-
s crond_t | grep spool
allow
crond_t system_cron_spool_t
: file
{ ioctl read write create getattr ..
allow
crond_t system_cron_spool_t : dir
{ ioctl read getattr lock search op..
allow
crond_t user_cron_spool_t : file
{ ioctl read write create getattr se..
allow
crond_t user_cron_spool_t : dir
{ ioctl r
ead write getattr lock add_n..
allow
crond_t user_cron_spool_t : lnk_file
{ read getattr } ;
# allow
后面½主体
½
程以及
文件
的
SELinux type
,上面的
数
据是
撷
取出
来
的,
#
意思是
说
,
crond_t
可以
读
取
system_cron_spool_t
的
文件
/
目
录类
型~等等!
范例二:找出
crond_t
是否能
够读
取
/etc/cron.d/checktime
这个
我
们
自定
义
的配置文件?
[root@study ~]#
ll
-
Z /etc/cron.d/checktime
-
rw
-
r
--
r
--
. root root unconfined_u:object_r:
admin_home_t
:s0 /etc/cron.d/checktime
#
两个
重
点
,一
个
是
SELinux type
为
admin_home_t
,一
个
是
文件
(file)
[root@study ~]#
sesearch
-
A
-
s crond_t | grep admin_home_t
allow domain admin_home_t : dir { getattr search open } ;
allow domain admin_home_t : lnk_file { read getattr } ;
allow crond_t admin_home_t : dir { ioctl read getattr lock search open } ;
allow crond_t admin_home_t : lnk_file { read getattr }
;
#
仔
细
看!看仔
细
~
虽
然有
crond_t admin_home_t
存在,但是
这
是
总
体的信息,
#
并
没
有
针对
某些
规则
的
寻
找~所以
还
是不确定
checktime
能否被
读
取。但是,基本上就是
SELinux
# type
出
问题
~因此才
会无
法
读
取的!
所以,现在我们知道
/etc/cron.d/checktime
这个我们自己复制过去的文件会没有办法被读取的原因,
就是因为
SELinux type
错误啦!
根本就无法被读取~好~那现在我们来查一查,那
getsebool -a
里
面看到的
httpd_enable_homedirs
到底是什么?又是规范了哪些主体½程能够读取的
SELinux type
呢?
[root@study ~]#
semanage boolean
-
l | grep httpd_enable_homedirs
SELinux boolean State Default Description
httpd_enable_homedirs (off , off) Allow httpd to enable hom
edirs
# httpd_enable_homedirs
的功能是允
许
httpd
½
程去
读
取用
户
家目
录
的意思~
[root@study ~]#
sesearch
-
A
-
b httpd_enable_homedirs
范例三:列出
httpd_enable_homedirs
这个规则当
中,主体
½
程能
够读
取的
文件
SELinux type
Found 43 semantic av rules: