Chris PeBenito 23caa6
Chris PeBenito 23caa6
########################################
Chris PeBenito 23caa6
#
Chris PeBenito daa0e0
# cron_per_userdomain_template(domainprefix)
Chris PeBenito 23caa6
#
Chris PeBenito 23caa6
Chris PeBenito 23caa6
define(`cron_per_userdomain_template',`
Chris PeBenito 23caa6
Chris PeBenito 0c73cd
	# Type of user crontabs once moved to cron spool.
Chris PeBenito 0c73cd
	type $1_cron_spool_t;
Chris PeBenito c9428d
	files_file_type($1_cron_spool_t)
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	type $1_crond_t; # user_crond_domain;
Chris PeBenito c9428d
	domain_type($1_crond_t);
Chris PeBenito c9428d
	corecmd_shell_entry_type($1_crond_t)
Chris PeBenito 0c73cd
	role $1_r types $1_crond_t;
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	type $1_crontab_t;
Chris PeBenito c9428d
	domain_type($1_crontab_t)
Chris PeBenito c9428d
	domain_entry_file($1_crontab_t,crontab_exec_t)
Chris PeBenito 0c73cd
	role $1_r types $1_crontab_t;
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	##############################
Chris PeBenito 0c73cd
	#
Chris PeBenito 0c73cd
	# $1_crond_t local policy
Chris PeBenito 0c73cd
	#
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	allow $1_crond_t self:capability dac_override;
Chris PeBenito 0fd9dc
	allow $1_crond_t self:process { signal_perms setsched };
Chris PeBenito 0a10b1
	allow $1_crond_t self:fifo_file rw_file_perms;
Chris PeBenito 0fd9dc
	allow $1_crond_t self:unix_stream_socket create_stream_socket_perms;
Chris PeBenito 0fd9dc
	allow $1_crond_t self:unix_dgram_socket create_socket_perms;
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	# The entrypoint interface is not used as this is not
Chris PeBenito 0c73cd
	# a regular entrypoint.  Since crontab files are
Chris PeBenito 0c73cd
	# not directly executed, crond must ensure that
Chris PeBenito 0c73cd
	# the crontab file has a type that is appropriate
Chris PeBenito 0c73cd
	# for the domain of the user cron job.  It
Chris PeBenito 0c73cd
	# performs an entrypoint permission check
Chris PeBenito 0c73cd
	# for this purpose.
Chris PeBenito 0c73cd
	allow $1_crond_t $1_cron_spool_t:file entrypoint;
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	# Permit a transition from the crond_t domain to this domain.
Chris PeBenito 0c73cd
	# The transition is requested explicitly by the modified crond 
Chris PeBenito 0c73cd
	# via setexeccon.  There is no way to set up an automatic
Chris PeBenito 0c73cd
	# transition, since crontabs are configuration files, not executables.
Chris PeBenito 0c73cd
	allow crond_t $1_crond_t:process transition;
Chris PeBenito 0c73cd
	dontaudit crond_t $1_crond_t:process { noatsecure siginh rlimitinh };
Chris PeBenito 0c73cd
	allow crond_t $1_crond_t:fd use;
Chris PeBenito 0c73cd
	allow $1_crond_t crond_t:fd use;
Chris PeBenito 0c73cd
	allow $1_crond_t crond_t:fifo_file rw_file_perms;
Chris PeBenito 0c73cd
	allow $1_crond_t crond_t:process sigchld;
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	kernel_read_system_state($1_crond_t)
Chris PeBenito 0c73cd
	kernel_read_kernel_sysctl($1_crond_t)
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	# ps does not need to access /boot when run from cron
Chris PeBenito 0fd9dc
	bootloader_dontaudit_search_boot($1_crond_t)
Chris PeBenito 0fd9dc
Chris PeBenito 0fd9dc
	corenet_tcp_sendrecv_all_if($1_crond_t)
Chris PeBenito 0fd9dc
	corenet_raw_sendrecv_all_if($1_crond_t)
Chris PeBenito 0fd9dc
	corenet_udp_sendrecv_all_if($1_crond_t)
Chris PeBenito 0fd9dc
	corenet_tcp_sendrecv_all_nodes($1_crond_t)
Chris PeBenito 0fd9dc
	corenet_raw_sendrecv_all_nodes($1_crond_t)
Chris PeBenito 0fd9dc
	corenet_udp_sendrecv_all_nodes($1_crond_t)
Chris PeBenito 0fd9dc
	corenet_tcp_sendrecv_all_ports($1_crond_t)
Chris PeBenito 0fd9dc
	corenet_udp_sendrecv_all_ports($1_crond_t)
Chris PeBenito 0fd9dc
	corenet_tcp_bind_all_nodes($1_crond_t)
Chris PeBenito 0fd9dc
	corenet_udp_bind_all_nodes($1_crond_t)
Chris PeBenito 23caa6
Karl MacMillan f0c985
	dev_read_urand($1_crond_t)
Chris PeBenito d18e3d
Chris PeBenito 0fd9dc
	fs_getattr_all_fs($1_crond_t)
Chris PeBenito d18e3d
Chris PeBenito c9428d
	domain_exec_all_entry_files($1_crond_t)
Chris PeBenito 075c4f
Chris PeBenito c9428d
	files_read_usr_files($1_crond_t)
Chris PeBenito c9428d
	files_exec_generic_etc_files($1_crond_t)
Chris PeBenito 0c73cd
	# for nscd:
Chris PeBenito c9428d
	files_dontaudit_search_pids($1_crond_t)
Chris PeBenito 23caa6
Chris PeBenito c9428d
	corecmd_exec_bin($1_crond_t)
Chris PeBenito c9428d
	corecmd_exec_sbin($1_crond_t)
Chris PeBenito 23caa6
Chris PeBenito c9428d
	libs_use_ld_so($1_crond_t)
Chris PeBenito c9428d
	libs_use_shared_libs($1_crond_t)
Chris PeBenito c9428d
	libs_exec_lib_files($1_crond_t)
Chris PeBenito c9428d
	libs_exec_ld_so($1_crond_t)
Chris PeBenito 23caa6
Chris PeBenito c9428d
	files_read_etc_runtime_files($1_crond_t)
Chris PeBenito 23caa6
Chris PeBenito c9428d
	logging_search_logs($1_crond_t)
Chris PeBenito 23caa6
Chris PeBenito 5e0da6
	seutil_read_config($1_crond_t)
Chris PeBenito 23caa6
Chris PeBenito 0c73cd
	miscfiles_read_localization($1_crond_t)
Chris PeBenito d18e3d
Chris PeBenito 0c73cd
	tunable_policy(`fcron_crond', `
Chris PeBenito 0a10b1
		allow crond_t $1_cron_spool_t:file create_file_perms;
Chris PeBenito 0c73cd
	')
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	ifdef(`TODO',`
Chris PeBenito 0c73cd
	# Access user files and dirs.
Chris PeBenito 0c73cd
	allow $1_crond_t home_root_t:dir search;
Chris PeBenito 0c73cd
	file_type_auto_trans($1_crond_t, $1_home_dir_t, $1_home_t)
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	# Run scripts in user home directory and access shared libs.
Chris PeBenito 0c73cd
	can_exec($1_crond_t, $1_home_t)
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	file_type_auto_trans($1_crond_t, tmp_t, $1_tmp_t)
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	ifdef(`mta.te', `
Chris PeBenito 0c73cd
		domain_auto_trans($1_crond_t, sendmail_exec_t, $1_mail_t)
Chris PeBenito 0a10b1
		allow $1_crond_t sendmail_exec_t:lnk_file r_file_perms;
Chris PeBenito d18e3d
Chris PeBenito 0c73cd
		# $1_mail_t should only be reading from the cron fifo not needing to write
Chris PeBenito 0c73cd
		dontaudit $1_mail_t crond_t:fifo_file write;
Chris PeBenito 0c73cd
		allow mta_user_agent $1_crond_t:fd use;
Chris PeBenito 0c73cd
	')
Chris PeBenito d18e3d
Chris PeBenito 0c73cd
	# This domain is granted permissions common to most domains.
Chris PeBenito 0c73cd
	can_ypbind($1_crond_t)
Chris PeBenito 0c73cd
	allow $1_crond_t var_spool_t:dir search;
Chris PeBenito 0c73cd
	allow $1_crond_t var_t:dir r_dir_perms;
Chris PeBenito 0a10b1
	allow $1_crond_t var_t:file r_file_perms;
Chris PeBenito d18e3d
Chris PeBenito 0c73cd
	# quiet other ps operations
Chris PeBenito 0c73cd
	dontaudit $1_crond_t domain:dir { getattr search };
Chris PeBenito 0c73cd
	') dnl endif TODO
Chris PeBenito d18e3d
Chris PeBenito 0c73cd
	##############################
Chris PeBenito 0c73cd
	#
Chris PeBenito 0c73cd
	# $1_crontab_t local policy
Chris PeBenito 0c73cd
	#
Chris PeBenito 075c4f
Chris PeBenito 0c73cd
	# for ^Z
Chris PeBenito 0c73cd
	allow $1_t $1_crontab_t:process signal;
Chris PeBenito d18e3d
Chris PeBenito 0c73cd
	# Allow crond to read those crontabs in cron spool.
Chris PeBenito 0a10b1
	allow crond_t $1_cron_spool_t:file r_file_perms;
Chris PeBenito d18e3d
Chris PeBenito 0c73cd
	# dac_override is to create the file in the directory under /tmp
Chris PeBenito 0c73cd
	allow $1_crontab_t self:capability { setuid setgid chown dac_override };
Chris PeBenito 0a10b1
	allow $1_crontab_t self:process signal_perms;
Chris PeBenito d18e3d
Chris PeBenito 0c73cd
	# create files in /var/spool/cron
Chris PeBenito 0a10b1
	allow $1_crontab_t $1_cron_spool_t:file create_file_perms;
Chris PeBenito 0a10b1
	allow $1_crontab_t cron_spool_t:dir rw_dir_perms;
Chris PeBenito 0c73cd
	type_transition $1_crontab_t $1_cron_spool_t:file system_crond_tmp_t;
Chris PeBenito d18e3d
Chris PeBenito 0c73cd
	# crontab signals crond by updating the mtime on the spooldir
Chris PeBenito 0c73cd
	allow $1_crontab_t cron_spool_t:dir setattr;
Chris PeBenito d18e3d
Chris PeBenito 0a10b1
	allow $1_crontab_t crond_log_t:file ra_file_perms;
Chris PeBenito d18e3d
Chris PeBenito 0fd9dc
	fs_getattr_xattr_fs($1_crontab_t)
Chris PeBenito d18e3d
Chris PeBenito c9428d
	domain_use_wide_inherit_fd($1_crontab_t)
Chris PeBenito d18e3d
Chris PeBenito c9428d
	files_read_generic_etc_files($1_crontab_t)
Chris PeBenito d18e3d
Chris PeBenito c9428d
	libs_use_ld_so($1_crontab_t)
Chris PeBenito c9428d
	libs_use_shared_libs($1_crontab_t)
Chris PeBenito d18e3d
Chris PeBenito c9428d
	logging_send_syslog_msg($1_crontab_t)
Chris PeBenito d18e3d
Chris PeBenito 0c73cd
	miscfiles_read_localization($1_crontab_t)
Chris PeBenito d18e3d
Chris PeBenito 0c73cd
	tunable_policy(`fcron_crond', `
Chris PeBenito 0c73cd
		# fcron wants an instant update of a crontab change for the administrator
Chris PeBenito 0c73cd
		# also crontab does a security check for crontab -u
Chris PeBenito 0c73cd
		dontaudit $1_crontab_t crond_t:process signal;
Chris PeBenito 0c73cd
	')
Chris PeBenito d18e3d
Chris PeBenito 0c73cd
	ifdef(`TODO',`
Chris PeBenito d18e3d
Chris PeBenito 0c73cd
	# Transition from the user domain to the derived domain.
Chris PeBenito 0c73cd
	domain_auto_trans($1_t, crontab_exec_t, $1_crontab_t)
Chris PeBenito d18e3d
Chris PeBenito 0c73cd
	can_ps($1_t, $1_crontab_t)
Chris PeBenito d18e3d
Chris PeBenito 0c73cd
	dontaudit $1_crontab_t proc_t:dir search;
Chris PeBenito 0c73cd
	dontaudit $1_crontab_t selinux_config_t:dir search;
Chris PeBenito 0c73cd
	# for the checks used by crontab -u
Chris PeBenito 0c73cd
	dontaudit $1_crontab_t security_t:dir search;
Chris PeBenito d18e3d
Chris PeBenito 0c73cd
	# Type for temporary files.
Chris PeBenito 0c73cd
	file_type_auto_trans($1_crontab_t, tmp_t, $1_tmp_t, { dir file })
Chris PeBenito d18e3d
Chris PeBenito 0c73cd
	# Use the type when creating files in /var/spool/cron.
Chris PeBenito 0c73cd
	allow sysadm_crontab_t $1_cron_spool_t:file { getattr read };
Chris PeBenito d18e3d
Chris PeBenito 0c73cd
	# Run helper programs as $1_t
Chris PeBenito 0c73cd
	allow $1_crontab_t { bin_t sbin_t }:dir search;
Chris PeBenito 0c73cd
	allow $1_crontab_t bin_t:lnk_file read;
Chris PeBenito 0c73cd
	domain_auto_trans($1_crontab_t, { bin_t sbin_t shell_exec_t }, $1_t)
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	# Read user crontabs 
Chris PeBenito 0c73cd
	allow $1_crontab_t { $1_home_t $1_home_dir_t }:dir r_dir_perms;  
Chris PeBenito 0c73cd
	allow $1_crontab_t $1_home_t:file r_file_perms;  
Chris PeBenito 0c73cd
	dontaudit $1_crontab_t $1_home_dir_t:dir write;
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	# Access terminals.
Chris PeBenito 0a10b1
	allow $1_crontab_t devpts_t:dir r_dir_perms;
Chris PeBenito 0a10b1
	allow $1_crontab_t $1_tty_device_t:chr_file rw_file_perms;
Chris PeBenito 0a10b1
	allow $1_crontab_t $1_devpts_t:chr_file rw_file_perms;
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	# Inherit and use descriptors from gnome-pty-helper.
Chris PeBenito 0c73cd
	ifdef(`gnome-pty-helper.te', `allow $1_crontab_t $1_gph_t:fd use;')
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	dontaudit $1_crontab_t var_run_t:dir search;
Chris PeBenito 0c73cd
	') dnl endif TODO
Chris PeBenito 23caa6
')
Chris PeBenito daa0e0
Chris PeBenito daa0e0
########################################
Chris PeBenito daa0e0
#
Chris PeBenito daa0e0
# cron_admin_template(domainprefix)
Chris PeBenito daa0e0
#
Chris PeBenito daa0e0
Chris PeBenito daa0e0
define(`cron_admin_template',`
Chris PeBenito c9428d
	logging_read_generic_logs($1_crond_t)
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	# Allow our crontab domain to unlink a user cron spool file.
Chris PeBenito 0c73cd
	#allow $1_crontab_t user_cron_spool_t:file unlink;
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	# Manipulate other users crontab.
Chris PeBenito 5e0da6
	selinux_get_fs_mount($1_crontab_t)
Chris PeBenito 5e0da6
	selinux_validate_context($1_crontab_t)
Chris PeBenito 5e0da6
	selinux_compute_access_vector($1_crontab_t)
Chris PeBenito 5e0da6
	selinux_compute_create_context($1_crontab_t)
Chris PeBenito 5e0da6
	selinux_compute_relabel_context($1_crontab_t)
Chris PeBenito 5e0da6
	selinux_compute_user_contexts($1_crontab_t)
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	tunable_policy(`fcron_crond', `
Chris PeBenito 0c73cd
		# fcron wants an instant update of a crontab change for the administrator
Chris PeBenito 0c73cd
		# also crontab does a security check for crontab -u
Chris PeBenito 0c73cd
		allow $1_crontab_t self:process setfscreate;
Chris PeBenito 5e0da6
		selinux_get_fs_mount($1_crontab_t)
Chris PeBenito 0c73cd
	')
Chris PeBenito daa0e0
')
Chris PeBenito 3b857e
Chris PeBenito 3b857e
########################################
Chris PeBenito 3b857e
#
Chris PeBenito c9428d
# cron_rw_log(domain)
Chris PeBenito 3b857e
#
Chris PeBenito c9428d
define(`cron_rw_log',`
Chris PeBenito fa7bea
	gen_require(`$0'_depend)
Chris PeBenito 0c73cd
Chris PeBenito 0a10b1
	allow $1 crond_log_t:file rw_file_perms;
Chris PeBenito 3b857e
')
Chris PeBenito 3b857e
Chris PeBenito c9428d
define(`cron_rw_log_depend',`
Chris PeBenito 0c73cd
	type crond_log_t;
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	class file rw_file_perms;
Chris PeBenito 3b857e
')