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

257 lines
7.8 KiB
Plaintext
Raw Normal View History

2005-05-11 19:05:50 +00:00
########################################
#
# cron_per_userdomain_template(domainprefix)
2005-05-11 19:05:50 +00:00
#
define(`cron_per_userdomain_template',`
# Type of user crontabs once moved to cron spool.
type $1_cron_spool_t;
files_make_file($1_cron_spool_t)
type $1_crond_t; # user_crond_domain;
domain_make_domain($1_crond_t);
corecommands_make_shell_entrypoint($1_crond_t)
role $1_r types $1_crond_t;
type $1_crontab_t;
domain_make_domain($1_crontab_t)
domain_make_entrypoint_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
devices_get_pseudorandom_data($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
domain_execute_all_entrypoint_programs($1_crond_t)
2005-05-12 20:50:09 +00:00
files_read_general_application_resources($1_crond_t)
files_execute_system_config_script($1_crond_t)
# for nscd:
files_ignore_search_runtime_data_directory($1_crond_t)
2005-05-11 19:05:50 +00:00
corecommands_execute_general_programs($1_crond_t)
corecommands_execute_system_programs($1_crond_t)
2005-05-11 19:05:50 +00:00
libraries_use_dynamic_loader($1_crond_t)
libraries_use_shared_libraries($1_crond_t)
libraries_execute_library_scripts($1_crond_t)
libraries_execute_dynamic_loader($1_crond_t)
2005-05-11 19:05:50 +00:00
files_read_runtime_system_config($1_crond_t)
2005-05-11 19:05:50 +00:00
logging_search_system_log_directory($1_crond_t)
2005-05-11 19:05:50 +00:00
selinux_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
domain_use_widely_inheritable_file_descriptors($1_crontab_t)
2005-05-11 20:55:40 +00:00
files_read_general_system_config($1_crontab_t)
2005-05-11 20:55:40 +00:00
libraries_use_dynamic_loader($1_crontab_t)
libraries_use_shared_libraries($1_crontab_t)
2005-05-11 20:55:40 +00:00
logging_send_system_log_message($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)
#
define(`cron_admin_template',`
logging_read_system_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.
kernel_get_selinuxfs_mount_point($1_crontab_t)
2005-06-10 01:01:13 +00:00
kernel_validate_context($1_crontab_t)
kernel_compute_access_vector($1_crontab_t)
kernel_compute_create_context($1_crontab_t)
kernel_compute_relabel_context($1_crontab_t)
kernel_compute_reachable_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;
kernel_get_selinuxfs_mount_point($1_crontab_t)
')
')
########################################
#
# cron_modify_log(domain)
#
define(`cron_modify_log',`
requires_block_template(`$0'_depend)
2005-06-09 15:32:23 +00:00
allow $1 crond_log_t:file rw_file_perms;
')
define(`cron_modify_log_depend',`
type crond_log_t;
class file rw_file_perms;
')