我想以root身份运行logstash以允许它读取所有日志(授予它访问每个日志非常烦人)。 但是,我不希望它在我的服务器上运行,我想在SELinux下进行约束。
我看到的选项是:
clogd_t放在clogd_t因为它已经log了它的名字,而且我无法使用sudo sesearch --allow -s clogd_t | grep clogd_t | less -p write查找任何可疑的写入权限sudo sesearch --allow -s clogd_t | grep clogd_t | less -p write sudo sesearch --allow -s clogd_t | grep clogd_t | less -p write 要么是正常的事情呢?
万一重要,我使用的是CentOS 6.7
我宁愿制定一个定制的政策,因为它更清洁,并使您掌控发生的事情。
据我所知这是一个基于java的守护进程,你将会运行,所以可能是明智的,使其作为system_u:system_r:logstash_t运行system_u:system_r:logstash_t 。 然后,您需要将(只读?)所有日志文件的访问权限授予logstash_t域,最后授予logstash可能需要运行的任何其他权限。
使用refpolicy接口,我们有这样的东西:
policy_module(logstash, 1.0) # define the entry point and the domain type logstash_exec_t init_daemon_domain(logstash_t, logstash_exec_t)
然后logstash守护进程需要能够读取日志文件:
logging_search_all_logs(logstash_t) logging_getattr_all_logs(logstash_t) logging_read_all_logs(logstash_t)
这应该做大部分的工作,然后你需要添加其余的。
关于第二点,我不确定为什么你没有得到任何由sesearch报告的写入许可,但是如果你看看来源:
# clogd.te storage_raw_read_fixed_disk(clogd_t) storage_raw_write_fixed_disk(clogd_t) # storage.te ######################################## ## <summary> ## Allow the caller to directly write to a fixed disk. ## This is extremely dangerous as it can bypass the ## SELinux protections for filesystem objects, and ## should only be used by trusted domains. ## </summary> ## <param name="domain"> ## <summary> ## Domain allowed access. ## </summary> ## </param> # interface(`storage_raw_write_fixed_disk',` # and the rest of the stuff here...
不是真的从日志logging监视工具中想要什么。 你可能会发现适合第二种解决scheme的东西,只要确保你没有获得额外的不必要的权限,因为这在selinux中失败了。
希望能帮助到你。