【问题标题】:How to fix "No SELinux security context (/etc/crontab)" issue?如何解决“没有 SELinux 安全上下文 (/etc/crontab)”的问题?
【发布时间】:2019-10-10 09:42:53
【问题描述】:

我在我的 yocto 项目(warrior 分支)中启用了 SELinux,但由于某些 SELinux 上下文问题,cron 无法正常工作。我正在使用minimum SELinux 策略。这是来自/var/log/messages的错误

Oct  9 04:50:01 panther2 cron.info crond[261]: ((null)) No SELinux security context (/etc/crontab)        
Oct  9 04:50:01 panther2 cron.info crond[261]: (root) FAILED (loading cron table)                       

以下是相关文件的一些上下文,

root@panther2:~# ps -efZ | grep cron
system_u:system_r:kernel_t:s0   root       464     1  0 04:54 ?    00:00:00 /usr/sbin/crond -n

root@panther2:~# ls -lZ /etc/crontab 
-rw-------. 1 root root system_u:object_r:unconfined_t:s0 653 Oct  9  2019 /etc/crontab

root@panther2:~# ls -lZ /usr/sbin/crond 
-rwxr-xr-x. 1 root root system_u:object_r:unlabeled_t:s0 68160 Oct  9  2019 /usr/sbin/crond

有什么帮助吗?谢谢!!

【问题讨论】:

标签: cron yocto selinux


【解决方案1】:

unconfined_t 是一种与活动实体(进程)相关联的类型。您将其与 /etc/crontab 相关联,它是一个被动实体(文件)。进程做事,因此需要权限。对象(被动实体)由主动实体操作,因此与文件关联的类型通常没有与之关联的权限,但在适用的情况下与文件系统关联的权限除外。

unlabeled_t 表示 /usr/sbin/crond 具有无效标签或根本没有与之关联的标签。

Cron 支持 SELinux。 Cron 代表系统或代表用户运行任务(使用 pam_selinux)。这些任务通常使用与 crond 本身上下文相关的权限不同的权限运行。 Crond 尝试通过查看 crontab 的标签(/ett/crontab 是系统任务的 crontab)来确定运行给定任务的上下文,然后使用该标签确定使用 libselinux API 运行任务的上下文.它确定与 crontab 关联的类型是否可以用于运行具有给定上下文的任务,然后确定它是否具有运行具有给定上下文的任务的权限。

在您的上述情况中,crond 确定(在 SELinux API 的帮助下)与系统 crontab (/etc/crontab) 关联的上下文不能用于运行具有它想要运行任务的上下文的任务。

您需要确保与 /etc/crontab 关联的上下文是有效的,并且它可以用作您希望 crond 运行任务的上下文的入口点。

如果您需要示例,请查看参考策略随附的 cron 策略和 cron 上下文配置文件。

【讨论】:

    猜你喜欢
    • 2016-04-30
    • 2022-01-25
    • 1970-01-01
    • 2021-07-09
    • 1970-01-01
    • 1970-01-01
    • 2022-06-15
    • 2017-06-19
    • 1970-01-01
    相关资源
    最近更新 更多