Chris PeBenito 23caa6
Chris PeBenito 3b857e
policy_module(cron, 1.0)
Chris PeBenito 23caa6
Chris PeBenito 23caa6
########################################
Chris PeBenito 23caa6
#
Chris PeBenito 23caa6
# Declarations
Chris PeBenito 23caa6
#
Chris PeBenito 23caa6
Chris PeBenito 3b3bf8
type anacron_exec_t;
Chris PeBenito c9428d
files_file_type(anacron_exec_t)
Chris PeBenito 3b3bf8
Chris PeBenito 23caa6
type cron_spool_t;
Chris PeBenito c9428d
files_file_type(cron_spool_t)
Chris PeBenito 23caa6
Chris PeBenito 075c4f
type crond_t; #, privmail, nscd_client_domain
Chris PeBenito 23caa6
type crond_exec_t;
Chris PeBenito c9428d
init_daemon_domain(crond_t,crond_exec_t)
Chris PeBenito c9428d
domain_wide_inherit_fd(crond_t)
Chris PeBenito 23caa6
Chris PeBenito 23caa6
type crond_log_t;
Chris PeBenito c9428d
logging_log_file(crond_log_t)
Chris PeBenito 23caa6
Chris PeBenito 23caa6
type crond_tmp_t;
Chris PeBenito c9428d
files_tmp_file(crond_tmp_t)
Chris PeBenito 23caa6
Chris PeBenito 23caa6
type crond_var_run_t;
Chris PeBenito c9428d
files_pid_file(crond_var_run_t)
Chris PeBenito 23caa6
Chris PeBenito 23caa6
type crontab_exec_t;
Chris PeBenito c9428d
files_file_type(crontab_exec_t)
Chris PeBenito 23caa6
Chris PeBenito 23caa6
type system_cron_spool_t;
Chris PeBenito 23caa6
type system_crond_t; #, privmail, nscd_client_domain;
Chris PeBenito c9428d
init_daemon_domain(system_crond_t,anacron_exec_t)
Chris PeBenito c9428d
corecmd_shell_entry_type(system_crond_t)
Chris PeBenito 23caa6
role system_r types system_crond_t;
Chris PeBenito 23caa6
Chris PeBenito 075c4f
type system_crond_lock_t;
Chris PeBenito c9428d
files_lock_file(system_crond_lock_t)
Chris PeBenito 075c4f
Chris PeBenito 23caa6
type system_crond_tmp_t;
Chris PeBenito c9428d
files_tmp_file(system_crond_tmp_t)
Chris PeBenito 23caa6
Chris PeBenito 23caa6
########################################
Chris PeBenito 23caa6
#
Chris PeBenito 23caa6
# Cron Local policy
Chris PeBenito 23caa6
#
Chris PeBenito 23caa6
Chris PeBenito 23caa6
allow crond_t self:capability { dac_override setgid setuid net_bind_service sys_nice };
Chris PeBenito 23caa6
dontaudit crond_t self:capability { sys_resource sys_tty_config };
Chris PeBenito 23caa6
allow crond_t self:process ~{ ptrace setcurrent setexec setfscreate setrlimit execmem dyntransition };
Chris PeBenito 23caa6
allow crond_t self:process setexec;
Chris PeBenito 23caa6
allow crond_t self:fd use;
Chris PeBenito 0a10b1
allow crond_t self:fifo_file rw_file_perms;
Chris PeBenito 0a10b1
allow crond_t self:unix_dgram_socket create_socket_perms;
Chris PeBenito 0a10b1
allow crond_t self:unix_stream_socket create_stream_socket_perms;
Chris PeBenito 23caa6
allow crond_t self:unix_dgram_socket sendto;
Chris PeBenito 23caa6
allow crond_t self:unix_stream_socket connectto;
Chris PeBenito 0a10b1
allow crond_t self:shm create_shm_perms;
Chris PeBenito 0a10b1
allow crond_t self:sem create_sem_perms;
Chris PeBenito 0a10b1
allow crond_t self:msgq create_msgq_perms;
Chris PeBenito 23caa6
allow crond_t self:msg { send receive };
Chris PeBenito 23caa6
Chris PeBenito 0a10b1
allow crond_t crond_log_t:file create_file_perms;
Chris PeBenito 23caa6
Chris PeBenito 3b857e
allow crond_t crond_var_run_t:file create_file_perms;
Chris PeBenito c9428d
files_create_pid(crond_t,crond_var_run_t)
Chris PeBenito 23caa6
Chris PeBenito 0a10b1
allow crond_t crond_tmp_t:dir create_dir_perms;
Chris PeBenito 0a10b1
allow crond_t crond_tmp_t:file create_file_perms;
Chris PeBenito c9428d
files_create_tmp_files(crond_t, crond_tmp_t, { file dir })
Chris PeBenito 23caa6
Chris PeBenito 0a10b1
allow crond_t cron_spool_t:dir r_dir_perms;
Chris PeBenito 0a10b1
allow crond_t cron_spool_t:file r_file_perms;
Chris PeBenito 0a10b1
allow crond_t system_cron_spool_t:dir r_dir_perms;
Chris PeBenito 0a10b1
allow crond_t system_cron_spool_t:file r_file_perms;
Chris PeBenito 075c4f
Chris PeBenito 23caa6
kernel_read_kernel_sysctl(crond_t)
Chris PeBenito 23caa6
kernel_read_hardware_state(crond_t)
Chris PeBenito 23caa6
kernel_get_selinuxfs_mount_point(crond_t)
Chris PeBenito 0fd9dc
kernel_validate_context(crond_t)
Chris PeBenito 0fd9dc
kernel_compute_access_vector(crond_t)
Chris PeBenito 0fd9dc
kernel_compute_create_context(crond_t)
Chris PeBenito 0fd9dc
kernel_compute_relabel_context(crond_t)
Chris PeBenito 0fd9dc
kernel_compute_reachable_user_contexts(crond_t)
Chris PeBenito 23caa6
Karl MacMillan f0c985
dev_read_urand(crond_t)
Chris PeBenito 23caa6
Chris PeBenito 0fd9dc
fs_getattr_all_fs(crond_t)
Chris PeBenito 23caa6
Chris PeBenito 0fd9dc
term_dontaudit_use_console(crond_t)
Chris PeBenito 23caa6
Chris PeBenito efd8ed
# need auth_chkpwd to check for locked accounts.
Chris PeBenito c9428d
auth_domtrans_chk_passwd(crond_t)
Chris PeBenito efd8ed
Chris PeBenito c9428d
corecmd_exec_shell(crond_t)
Chris PeBenito c9428d
corecmd_list_sbin(crond_t)
Chris PeBenito 23caa6
Chris PeBenito c9428d
domain_use_wide_inherit_fd(crond_t)
Chris PeBenito 23caa6
Chris PeBenito c9428d
files_read_generic_etc_files(crond_t)
Chris PeBenito c9428d
files_read_spools(crond_t)
Chris PeBenito 23caa6
Chris PeBenito c9428d
init_use_fd(crond_t)
Chris PeBenito c9428d
init_use_script_pty(crond_t)
Chris PeBenito 075c4f
Chris PeBenito c9428d
libs_use_ld_so(crond_t)
Chris PeBenito c9428d
libs_use_shared_libs(crond_t)
Chris PeBenito 23caa6
Chris PeBenito c9428d
logging_send_syslog_msg(crond_t)
Chris PeBenito 23caa6
Chris PeBenito 23caa6
selinux_read_config(crond_t)
Chris PeBenito 23caa6
selinux_read_default_contexts(crond_t)
Chris PeBenito 23caa6
selinux_newrole_sigchld(crond_t)
Chris PeBenito 23caa6
Chris PeBenito 23caa6
miscfiles_read_localization(crond_t)
Chris PeBenito 23caa6
Chris PeBenito c9428d
userdom_use_unpriv_users_fd(crond_t)
Chris PeBenito 23caa6
Chris PeBenito 075c4f
tunable_policy(`fcron_crond', `
Chris PeBenito 0a10b1
	allow crond_t system_cron_spool_t:file create_file_perms;
Chris PeBenito 075c4f
')
Chris PeBenito 075c4f
Chris PeBenito 254bbc
ifdef(`targeted_policy', `
Chris PeBenito 0fd9dc
	term_dontaudit_use_unallocated_tty(crond_t)
Chris PeBenito 31908b
	term_dontaudit_use_generic_pty(crond_t)
Chris PeBenito c9428d
	files_dontaudit_read_root_file(crond_t)
Chris PeBenito 23caa6
')
Chris PeBenito 23caa6
Chris PeBenito 23caa6
optional_policy(`udev.te', `
Chris PeBenito c9428d
	udev_read_db(crond_t)
Chris PeBenito 23caa6
')
Chris PeBenito 23caa6
Chris PeBenito 23caa6
ifdef(`TODO',`
Chris PeBenito 075c4f
# NB The constraints file has some entries for crond_t, this makes it
Chris PeBenito 075c4f
# different from all other domains...
Chris PeBenito 075c4f
Chris PeBenito 23caa6
allow crond_t autofs_t:dir { search getattr };
Chris PeBenito 23caa6
dontaudit crond_t sysadm_home_dir_t:dir search;
Chris PeBenito 075c4f
Chris PeBenito 23caa6
optional_policy(`rhgb.te', `
Chris PeBenito 23caa6
allow crond_t rhgb_t:process sigchld;
Chris PeBenito 23caa6
allow crond_t rhgb_t:fd use;
Chris PeBenito 23caa6
allow crond_t rhgb_t:fifo_file { read write };
Chris PeBenito 23caa6
')
Chris PeBenito 23caa6
Chris PeBenito 23caa6
can_ypbind(crond_t)
Chris PeBenito 23caa6
ifdef(`automount.te', `
Chris PeBenito 23caa6
allow crond_t autofs_t:dir { search getattr };
Chris PeBenito 23caa6
')
Chris PeBenito 23caa6
Chris PeBenito 23caa6
# Read from /var/spool/cron.
Chris PeBenito 23caa6
allow crond_t var_lib_t:dir search;
Chris PeBenito 7bba9d
allow crond_t mail_spool_t:dir search;
Chris PeBenito efd8ed
# for if /var/mail is a symlink
Chris PeBenito efd8ed
allow crond_t mail_spool_t:lnk_file read;
Chris PeBenito 23caa6
Chris PeBenito 23caa6
allow crond_t default_t:dir search;
Chris PeBenito 23caa6
Chris PeBenito 23caa6
# crond tries to search /root.  Not sure why.
Chris PeBenito 23caa6
allow crond_t sysadm_home_dir_t:dir r_dir_perms;
Chris PeBenito 23caa6
Chris PeBenito 23caa6
# to search /home
Chris PeBenito 23caa6
allow crond_t user_home_dir_type:dir r_dir_perms;
Chris PeBenito 23caa6
Chris PeBenito 23caa6
ifdef(`distro_redhat', `
Chris PeBenito 23caa6
# Run the rpm program in the rpm_t domain. Allow creation of RPM log files
Chris PeBenito 23caa6
# via redirection of standard out.
Chris PeBenito 23caa6
ifdef(`rpm.te', `
Chris PeBenito 23caa6
allow crond_t rpm_log_t: file create_file_perms;
Chris PeBenito 23caa6
Chris PeBenito 23caa6
system_crond_entry(rpm_exec_t, rpm_t)
Chris PeBenito 23caa6
allow system_crond_t rpm_log_t:file create_file_perms;
Chris PeBenito 23caa6
')
Chris PeBenito 23caa6
')
Chris PeBenito 23caa6
') dnl endif TODO
Chris PeBenito 23caa6
Chris PeBenito 23caa6
########################################
Chris PeBenito 23caa6
#
Chris PeBenito 23caa6
# System cron process domain
Chris PeBenito 23caa6
#
Chris PeBenito 23caa6
Chris PeBenito 23caa6
allow system_crond_t self:capability { dac_override dac_read_search chown setgid setuid fowner net_bind_service fsetid };
Chris PeBenito 0fd9dc
allow system_crond_t self:process { signal_perms setsched };
Chris PeBenito 0a10b1
allow system_crond_t self:fifo_file rw_file_perms;
Chris PeBenito 23caa6
allow system_crond_t self:passwd rootok;
Chris PeBenito 23caa6
Chris PeBenito 23caa6
# The entrypoint interface is not used as this is not
Chris PeBenito 23caa6
# a regular entrypoint.  Since crontab files are
Chris PeBenito 23caa6
# not directly executed, crond must ensure that
Chris PeBenito 23caa6
# the crontab file has a type that is appropriate
Chris PeBenito 23caa6
# for the domain of the user cron job.  It
Chris PeBenito 23caa6
# performs an entrypoint permission check
Chris PeBenito 23caa6
# for this purpose.
Chris PeBenito 23caa6
allow system_crond_t system_cron_spool_t:file entrypoint;
Chris PeBenito 23caa6
Chris PeBenito 0a10b1
allow system_crond_t system_cron_spool_t:file r_file_perms;
Chris PeBenito 23caa6
Chris PeBenito 075c4f
# Permit a transition from the crond_t domain to this domain.
Chris PeBenito 075c4f
# The transition is requested explicitly by the modified crond 
Chris PeBenito 075c4f
# via setexeccon.  There is no way to set up an automatic
Chris PeBenito 075c4f
# transition, since crontabs are configuration files, not executables.
Chris PeBenito 075c4f
allow crond_t system_crond_t:process transition;
Chris PeBenito 075c4f
dontaudit crond_t system_crond_t:process { noatsecure siginh rlimitinh };
Chris PeBenito f5d4ef
allow crond_t system_crond_t:fd use;
Chris PeBenito f5d4ef
allow system_crond_t crond_t:fd use;
Chris PeBenito f5d4ef
allow system_crond_t crond_t:fifo_file rw_file_perms;
Chris PeBenito f5d4ef
allow system_crond_t crond_t:process sigchld;
Chris PeBenito 075c4f
Chris PeBenito 075c4f
# Write /var/lock/makewhatis.lock.
Chris PeBenito 0a10b1
allow system_crond_t system_crond_lock_t:file create_file_perms;
Chris PeBenito c9428d
files_create_lock_file(system_crond_t,system_crond_lock_t)
Chris PeBenito 075c4f
Chris PeBenito 075c4f
# write temporary files
Chris PeBenito 0fd9dc
allow system_crond_t system_crond_tmp_t:file create_file_perms;
Chris PeBenito c9428d
files_create_tmp_files(system_crond_t,system_crond_tmp_t)
Chris PeBenito 075c4f
Chris PeBenito 075c4f
# write temporary files in crond tmp dir:
Chris PeBenito 0a10b1
allow system_crond_t crond_tmp_t:dir rw_dir_perms;
Chris PeBenito 075c4f
type_transition system_crond_t crond_tmp_t:file system_crond_tmp_t;
Chris PeBenito 075c4f
Chris PeBenito 075c4f
# Read from /var/spool/cron.
Chris PeBenito 0a10b1
allow system_crond_t cron_spool_t:dir r_dir_perms;
Chris PeBenito 0a10b1
allow system_crond_t cron_spool_t:file r_file_perms;
Chris PeBenito 075c4f
Chris PeBenito 075c4f
# Access crond log files
Chris PeBenito 0a10b1
allow system_crond_t crond_log_t:file create_file_perms;
Chris PeBenito c9428d
logging_create_log(system_crond_t,crond_log_t)
Chris PeBenito 075c4f
Chris PeBenito 23caa6
kernel_read_kernel_sysctl(system_crond_t)
Chris PeBenito 23caa6
kernel_read_system_state(system_crond_t)
Chris PeBenito 23caa6
kernel_read_software_raid_state(system_crond_t)
Chris PeBenito 23caa6
Chris PeBenito 075c4f
# ps does not need to access /boot when run from cron
Chris PeBenito 0fd9dc
bootloader_dontaudit_search_boot(system_crond_t)
Chris PeBenito 0fd9dc
Chris PeBenito 0fd9dc
corenet_tcp_sendrecv_all_if(system_crond_t)
Chris PeBenito 0fd9dc
corenet_raw_sendrecv_all_if(system_crond_t)
Chris PeBenito 0fd9dc
corenet_udp_sendrecv_all_if(system_crond_t)
Chris PeBenito 0fd9dc
corenet_tcp_sendrecv_all_nodes(system_crond_t)
Chris PeBenito 0fd9dc
corenet_raw_sendrecv_all_nodes(system_crond_t)
Chris PeBenito 0fd9dc
corenet_udp_sendrecv_all_nodes(system_crond_t)
Chris PeBenito 0fd9dc
corenet_tcp_sendrecv_all_ports(system_crond_t)
Chris PeBenito 0fd9dc
corenet_udp_sendrecv_all_ports(system_crond_t)
Chris PeBenito 0fd9dc
corenet_tcp_bind_all_nodes(system_crond_t)
Chris PeBenito 0fd9dc
corenet_udp_bind_all_nodes(system_crond_t)
Chris PeBenito 23caa6
Karl MacMillan f0c985
dev_getattr_all_blk_files(system_crond_t)
Karl MacMillan f0c985
dev_getattr_all_chr_files(system_crond_t)
Karl MacMillan f0c985
dev_read_urand(system_crond_t)
Chris PeBenito 23caa6
Chris PeBenito 0fd9dc
fs_getattr_all_fs(system_crond_t)
Chris PeBenito 0fd9dc
fs_getattr_all_files(system_crond_t)
Chris PeBenito 23caa6
Chris PeBenito c9428d
init_use_fd(system_crond_t)
Chris PeBenito c9428d
init_use_script_fd(system_crond_t)
Chris PeBenito c9428d
init_use_script_pty(system_crond_t)
Chris PeBenito c9428d
init_read_script_pid(system_crond_t)
Chris PeBenito c9428d
init_dontaudit_rw_script_pid(system_crond_t)
Chris PeBenito 23caa6
Chris PeBenito c9428d
domain_exec_all_entry_files(system_crond_t)
Chris PeBenito 23caa6
Chris PeBenito c9428d
files_exec_generic_etc_files(system_crond_t)
Chris PeBenito c9428d
files_read_generic_etc_files(system_crond_t)
Chris PeBenito c9428d
files_read_etc_runtime_files(system_crond_t)
Chris PeBenito c9428d
files_list_all_dirs(system_crond_t)
Chris PeBenito c9428d
files_getattr_all_files(system_crond_t)
Chris PeBenito c9428d
files_read_usr_files(system_crond_t)
Chris PeBenito 075c4f
# for nscd:
Chris PeBenito c9428d
files_dontaudit_search_pids(system_crond_t)
Chris PeBenito efd8ed
# Access other spool directories like
Chris PeBenito efd8ed
# /var/spool/anacron and /var/spool/slrnpull.
Chris PeBenito c9428d
files_manage_spools(system_crond_t)
Chris PeBenito 23caa6
Chris PeBenito c9428d
corecmd_exec_bin(system_crond_t)
Chris PeBenito c9428d
corecmd_exec_sbin(system_crond_t)
Chris PeBenito 23caa6
Chris PeBenito c9428d
libs_use_ld_so(system_crond_t)
Chris PeBenito c9428d
libs_use_shared_libs(system_crond_t)
Chris PeBenito c9428d
libs_exec_lib_files(system_crond_t)
Chris PeBenito c9428d
libs_exec_ld_so(system_crond_t)
Chris PeBenito 23caa6
Chris PeBenito c9428d
logging_read_generic_logs(system_crond_t)
Chris PeBenito c9428d
logging_send_syslog_msg(system_crond_t)
Chris PeBenito 23caa6
Chris PeBenito 23caa6
miscfiles_read_localization(system_crond_t)
Chris PeBenito 23caa6
miscfiles_read_man_pages(system_crond_t)
Chris PeBenito c9428d
miscfiles_rw_man_cache(system_crond_t)
Chris PeBenito 23caa6
Chris PeBenito 23caa6
selinux_read_config(system_crond_t)
Chris PeBenito 23caa6
Chris PeBenito 31908b
tunable_policy(`cron_can_relabel',`
Chris PeBenito c9428d
	selinux_domtrans_setfiles(system_crond_t)
Chris PeBenito 31908b
',`
Chris PeBenito 0c73cd
	kernel_get_selinuxfs_mount_point(system_crond_t)
Chris PeBenito 0fd9dc
	kernel_validate_context(system_crond_t)
Chris PeBenito 0fd9dc
	kernel_compute_access_vector(system_crond_t)
Chris PeBenito 0fd9dc
	kernel_compute_create_context(system_crond_t)
Chris PeBenito 0fd9dc
	kernel_compute_relabel_context(system_crond_t)
Chris PeBenito 0fd9dc
	kernel_compute_reachable_user_contexts(system_crond_t)
Chris PeBenito 0c73cd
	selinux_read_file_contexts(system_crond_t)
Chris PeBenito 31908b
')
Chris PeBenito 23caa6
Chris PeBenito 23caa6
ifdef(`TODO',`
Chris PeBenito 23caa6
Chris PeBenito 23caa6
can_ypbind(system_crond_t)
Chris PeBenito 23caa6
Chris PeBenito 7bba9d
dontaudit userdomain system_crond_t:fd use;
Chris PeBenito 23caa6
Chris PeBenito 23caa6
# quiet other ps operations
Chris PeBenito 23caa6
dontaudit system_crond_t domain:dir { getattr search };
Chris PeBenito 23caa6
Chris PeBenito 7bba9d
# Do not audit attempts to search unlabeled directories (e.g. slocate).
Chris PeBenito 7bba9d
dontaudit system_crond_t unlabeled_t:dir r_dir_perms;
Chris PeBenito 7bba9d
dontaudit system_crond_t unlabeled_t:file r_file_perms;
Chris PeBenito 7bba9d
Chris PeBenito 23caa6
allow system_crond_t { sysfs_t rpc_pipefs_t }:dir getattr;
Chris PeBenito 23caa6
Chris PeBenito 7bba9d
# prelink tells init to restart it self, we either need to allow or dontaudit
Chris PeBenito 7bba9d
allow system_crond_t initctl_t:fifo_file write;
Chris PeBenito 7bba9d
Chris PeBenito 7bba9d
allow system_crond_t var_t:dir r_dir_perms;
Chris PeBenito 0a10b1
allow system_crond_t var_t:file r_file_perms;
Chris PeBenito 7bba9d
Chris PeBenito 23caa6
# Write to /var/lib/slocate.db.
Chris PeBenito 23caa6
allow system_crond_t var_lib_t:dir rw_dir_perms;
Chris PeBenito 23caa6
allow system_crond_t var_lib_t:file create_file_perms;
Chris PeBenito 23caa6
Chris PeBenito 7bba9d
# for if /var/mail is a symlink
Chris PeBenito 7bba9d
allow system_crond_t mail_spool_t:lnk_file read;
Chris PeBenito 23caa6
Chris PeBenito 23caa6
#
Chris PeBenito 23caa6
#  These rules are here to allow system cron jobs to su
Chris PeBenito 23caa6
#
Chris PeBenito 23caa6
ifdef(`su.te', `
Chris PeBenito 23caa6
su_restricted_domain(system_crond,system)
Chris PeBenito 23caa6
role system_r types system_crond_su_t;
Chris PeBenito 23caa6
allow system_crond_su_t crond_t:fifo_file ioctl;
Chris PeBenito 23caa6
')
Chris PeBenito 23caa6
Chris PeBenito 23caa6
#
Chris PeBenito 23caa6
# Required for webalizer
Chris PeBenito 23caa6
#
Chris PeBenito 23caa6
ifdef(`apache.te', `
Chris PeBenito 0a10b1
allow system_crond_t httpd_log_t:file r_file_perms;
Chris PeBenito 23caa6
')
Chris PeBenito 23caa6
Chris PeBenito 254bbc
ifdef(`distro_redhat', `
Chris PeBenito 075c4f
optional_policy(`rpm.te', `
Chris PeBenito 075c4f
allow system_crond_t rpm_log_t:file create_file_perms;
Chris PeBenito 075c4f
')
Chris PeBenito 075c4f
')
Chris PeBenito 075c4f
Chris PeBenito 7bba9d
ifdef(`mta.te', `
Chris PeBenito 7bba9d
mta_send_mail_transition(system_crond_t)
Chris PeBenito 7bba9d
Chris PeBenito 7bba9d
# system_mail_t should only be reading from the cron fifo not needing to write
Chris PeBenito 7bba9d
dontaudit system_mail_t crond_t:fifo_file write;
Chris PeBenito 7bba9d
allow mta_user_agent system_crond_t:fd use;
Chris PeBenito 7bba9d
r_dir_file(system_mail_t, crond_tmp_t)
Chris PeBenito 7bba9d
')
Chris PeBenito 7bba9d
Chris PeBenito 23caa6
') dnl end TODO