我的系统是fedora 23 .
试图在/ etc / crontab中运行被selinux阻止的cronjob .
* * * * sun,mon,tue,wed,thu,fri,sat root DISPLAY=:0 eog $HOME/Pictures/somepic.jpg
crontab的上下文:
-rw-r--r--. 1 root root unconfined_u:object_r:etc_t:s0 2664 Jan 23 18:12 /etc/crontab
如果我在许可模式下运行selinux,则每次都会运行该作业 .
这是'强制模式'中crond的日记条目:
-- Logs begin at Wed 2016-01-20 10:40:21 PST. --
Jan 23 18:25:01 localhost.localdomain CROND[20342]: (root) CMDOUT (/bin/sh: root: command not found)
Jan 23 18:25:25 localhost.localdomain crond[938]: (CRON) INFO (Shutting down)
Jan 23 18:25:25 localhost.localdomain crond[18645]: (CRON) INFO (Syslog will be used instead of sendmail.)
Jan 23 18:25:25 localhost.localdomain crond[18645]: (CRON) INFO (RANDOM_DELAY will be scaled with factor 12% if used.)
Jan 23 18:25:25 localhost.localdomain crond[18645]: ((null)) Unauthorized SELinux context=system_u:system_r:system_cronjob_t:s0-s0:c0.c1023 file_context=unconfined_u:object_r:etc_t:s0 (/etc/crontab)
Jan 23 18:25:25 localhost.localdomain crond[18645]: (root) FAILED (loading cron table)
Jan 23 18:25:25 localhost.localdomain crond[18645]: (root) Unauthorized SELinux context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 file_context=unconfined_u:object_r:user_cron_spool_t:s0 (/var/spool/cron/root)
Jan 23 18:25:25 localhost.localdomain crond[18645]: (root) FAILED (loading cron table)
Jan 23 18:25:25 localhost.localdomain crond[18645]: (CRON) INFO (running with inotify support)
Jan 23 18:25:25 localhost.localdomain crond[18645]: (CRON) INFO (@reboot jobs will be run at computer's startup.)
sebool设置:
cron_can_relabel --> off
cron_system_cronjob_use_shares --> off
cron_userdomain_transition --> on
fcron_crond --> off
1 回答
我有同样的问题 . 有一个很长时间工作的crontab . 使用crontab -e进行编辑,它停止工作 . 尝试为root用户和普通用户 . 一些搜索,这是一个目前已知的错误 .
https://bugzilla.redhat.com/show_bug.cgi?id=1263328
我尝试了注释#19中列出的解决方法 . 它工作正常 .
创建文件mycron.cil
(允许unconfined_t user_cron_spool_t(文件(入口点)))
然后运行:
semodule -i mycron.cil
然后重启cron:
systemctl重启crond.service
注释21说明了在发出修复时如何删除变通方法 .
通过运行删除:
semodule -r mycron
(我再次假设重启cron)