Using cron with SELinux
Another example of an SELinux-aware application is cron. Well, actually a set of cron implementations, as there is not a single cron application. Examples of cron implementations are vixie-cron, cronie, and fcron.
The cron implementations invoke commands for (and as) a particular Linux user. As these commands are not set in stone (the main purpose of cron is to allow any command to be run for a particular user or even for the system itself), it is not possible to easily create a policy that is sufficiently fine-grained to accommodate all features provided by cron. After all, for SELinux itself, there is no difference between cron calling a command for one user or another: all that is involved is the cron domain (crond_t
) and the target type of the command (such as bin_t
).
For this reason, many cron implementations are made SELinux-aware, allowing the cron implementation to select the proper target context.
How to do it…
To properly interact with an SELinux-aware cron...