selinux-policy/refpolicy/policy/modules/services/cron.if

256 lines
7.5 KiB
Plaintext
Raw Normal View History

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