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