Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Macros for crontab domains.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Authors:  Jonathan Crowley (MITRE) <jonathan@mitre.org>
Chris PeBenito ab58ad
# Revised by Stephen Smalley <sds@epoch.ncsc.mil>
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# crontab_domain(domain_prefix)
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Define a derived domain for the crontab program when executed by
Chris PeBenito ab58ad
# a user domain.  
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# The type declaration for the executable type for this program is
Chris PeBenito ab58ad
# provided separately in domains/program/crontab.te. 
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
undefine(`crontab_domain')
Chris PeBenito ab58ad
define(`crontab_domain',`
Chris PeBenito ab58ad
# Derived domain based on the calling user domain and the program.
Chris PeBenito ab58ad
type $1_crontab_t, domain, privlog;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Transition from the user domain to the derived domain.
Chris PeBenito ab58ad
domain_auto_trans($1_t, crontab_exec_t, $1_crontab_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
can_ps($1_t, $1_crontab_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# for ^Z
Chris PeBenito ab58ad
allow $1_t $1_crontab_t:process signal;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# The user role is authorized for this domain.
Chris PeBenito ab58ad
role $1_r types $1_crontab_t;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
uses_shlib($1_crontab_t)
Chris PeBenito ab58ad
allow $1_crontab_t etc_t:file { getattr read };
Chris PeBenito ab58ad
allow $1_crontab_t self:unix_stream_socket create_socket_perms;
Chris PeBenito ab58ad
allow $1_crontab_t self:unix_dgram_socket create_socket_perms;
Chris PeBenito ab58ad
read_locale($1_crontab_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Use capabilities dac_override is to create the file in the directory
Chris PeBenito ab58ad
# under /tmp
Chris PeBenito ab58ad
allow $1_crontab_t self:capability { setuid setgid chown dac_override };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Type for temporary files.
Chris PeBenito ab58ad
file_type_auto_trans($1_crontab_t, tmp_t, $1_tmp_t, { dir file })
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Use the type when creating files in /var/spool/cron.
Chris PeBenito ab58ad
allow sysadm_crontab_t $1_cron_spool_t:file { getattr read };
Chris PeBenito ab58ad
allow $1_crontab_t { var_t var_spool_t }:dir { getattr search };
Chris PeBenito ab58ad
file_type_auto_trans($1_crontab_t, cron_spool_t, $1_cron_spool_t, file)
Chris PeBenito ab58ad
allow $1_crontab_t self:process { fork signal_perms };
Chris PeBenito ab58ad
ifdef(`fcron.te', `
Chris PeBenito ab58ad
# fcron wants an instant update of a crontab change for the administrator
Chris PeBenito ab58ad
# also crontab does a security check for crontab -u
Chris PeBenito ab58ad
ifelse(`$1', `sysadm', `
Chris PeBenito ab58ad
allow $1_crontab_t crond_t:process signal;
Chris PeBenito ab58ad
can_setfscreate($1_crontab_t)
Chris PeBenito ab58ad
', `
Chris PeBenito ab58ad
dontaudit $1_crontab_t crond_t:process signal;
Chris PeBenito ab58ad
')dnl end ifelse
Chris PeBenito ab58ad
')dnl end ifdef fcron
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# for the checks used by crontab -u
Chris PeBenito ab58ad
dontaudit $1_crontab_t security_t:dir search;
Chris PeBenito ab58ad
allow $1_crontab_t proc_t:dir search;
Chris PeBenito ab58ad
allow $1_crontab_t proc_t:{ file lnk_file } { getattr read };
Chris PeBenito ab58ad
allow $1_crontab_t selinux_config_t:dir search;
Chris PeBenito ab58ad
allow $1_crontab_t selinux_config_t:file { getattr read };
Chris PeBenito ab58ad
dontaudit $1_crontab_t self:dir search;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# crontab signals crond by updating the mtime on the spooldir
Chris PeBenito ab58ad
allow $1_crontab_t cron_spool_t:dir setattr;
Chris PeBenito ab58ad
# Allow crond to read those crontabs in cron spool.
Chris PeBenito ab58ad
allow crond_t $1_cron_spool_t:file r_file_perms;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Run helper programs as $1_t
Chris PeBenito ab58ad
allow $1_crontab_t { bin_t sbin_t }:dir search;
Chris PeBenito ab58ad
allow $1_crontab_t bin_t:lnk_file read;
Chris PeBenito ab58ad
domain_auto_trans($1_crontab_t, { bin_t sbin_t shell_exec_t }, $1_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Read user crontabs 
Chris PeBenito ab58ad
allow $1_crontab_t { $1_home_t $1_home_dir_t }:dir r_dir_perms;  
Chris PeBenito ab58ad
allow $1_crontab_t $1_home_t:file r_file_perms;  
Chris PeBenito ab58ad
dontaudit $1_crontab_t $1_home_dir_t:dir write;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Access the cron log file.
Chris PeBenito ab58ad
allow $1_crontab_t crond_log_t:file r_file_perms;
Chris PeBenito ab58ad
allow $1_crontab_t crond_log_t:file append;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Access terminals.
Chris PeBenito ab58ad
allow $1_crontab_t device_t:dir search;
Chris PeBenito ab58ad
access_terminal($1_crontab_t, $1);
Chris PeBenito ab58ad
Chris PeBenito ab58ad
allow $1_crontab_t fs_t:filesystem getattr;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Inherit and use descriptors from gnome-pty-helper.
Chris PeBenito ab58ad
ifdef(`gnome-pty-helper.te', `allow $1_crontab_t $1_gph_t:fd use;')
Chris PeBenito ab58ad
allow $1_crontab_t privfd:fd use;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
dontaudit $1_crontab_t var_run_t:dir search;
Chris PeBenito ab58ad
')