如何在 SELinux 中授予“搜索”权限

如何在 SELinux 中授予“搜索”权限

我正在尝试让 dspam 在 SELinux (CentOS 7) 下运行。我添加了以下内容,没有任何问题:

allow dspam_t dspam_rw_content_t:dir getattr;
allow dspam_t dspam_rw_content_t:file { append getattr lock open write };

然而 dspam 仍然无法通过 procmail 工作:

/bin/sh: /usr/bin/dspam: Permission denied
procmail: Program failure (126) of "/usr/bin/dspam"

当我将 SELinux 设置为宽容时,它工作正常。我尝试使用它audit2allow来识别缺少的内容:

[root@opus ~]# audit2allow -i /var/log/audit/audit.log
#============= dspam_t ==============
allow dspam_t dspam_rw_content_t:dir search;

但将其添加到我的政策中会导致checkmodule错误:

checkmodule:  loading policy configuration from OPUS.te
OPUS.te:19:ERROR 'permission search is not defined for class dir' at token ';' on line 19:
allow dspam_t dspam_rw_content_t:dir getattr;
allow dspam_t dspam_rw_content_t:dir search;
checkmodule:  error(s) encountered while parsing configuration

我搜索了一下,但找不到解决方案。我该如何添加或定义search指示的权限?

答案1

虽然它不能解决我的最终问题(dspam 在 SELinux 强制模式下不起作用),但我发布此信息是因为它确实回答了我提出的实际问题(如何授予搜索权限)。

事实证明我遗漏了这个模块的searchrequire。我有:

require {
[...]
    class dir getattr;
}

当我浏览@harrymc 评论中的链接时发现,我需要:

require {
[...]
    class dir { write getattr add_name search };
}

此后,模块可以正确编译和加载。

相关内容