SElinux:如何使用上下文类型来批准或阻止访问?

SElinux: How Context type is used to approve or prevent access?

我是 SElinux 的新手,希望得到您的帮助:

我们如何检查程序的上下文类型是否符合文件的 SElinux 上下文类型,从而防止拒绝。

例如 shadow_t/etc/shadow 文件与 [= /usr/sbin/unix_chkpwd 程序的 29=]

非常感谢 Z

您可以指定上下文之间允许的交互。 SELinux 禁止所有未明确允许的交互。

如果你想允许 /usr/sbin/unix_chkpwd 读取 /etc/shadow 那么应该有一个明确允许它的策略:

allow chkpwd_t shadow_t:file getattr open read ioctl lock map;

您可以使用 sesearch 搜索现有政策。

sesearch --allow --source chkpwd_t --target shadow_t --class file