|
Chris PeBenito |
23caa6 |
# Copyright (C) 2005 Tresys Technology, LLC
|
|
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 |
23caa6 |
# Type of user crontabs once moved to cron spool.
|
|
Chris PeBenito |
23caa6 |
type $1_cron_spool_t;
|
|
Chris PeBenito |
23caa6 |
files_make_file($1_cron_spool_t)
|
|
Chris PeBenito |
23caa6 |
|
|
Chris PeBenito |
23caa6 |
type $1_crond_t; # user_crond_domain;
|
|
Chris PeBenito |
23caa6 |
domain_make_domain($1_crond_t);
|
|
Chris PeBenito |
23caa6 |
corecommands_make_shell_entrypoint($1_crond_t)
|
|
Chris PeBenito |
23caa6 |
role $1_r types $1_crond_t;
|
|
Chris PeBenito |
23caa6 |
|
|
Chris PeBenito |
d18e3d |
type $1_crontab_t;
|
|
Chris PeBenito |
d18e3d |
domain_make_domain($1_crontab_t)
|
|
Chris PeBenito |
d18e3d |
domain_make_entrypoint_file($1_crontab_t,crontab_exec_t)
|
|
Chris PeBenito |
d18e3d |
role $1_r types $1_crontab_t;
|
|
Chris PeBenito |
d18e3d |
|
|
Chris PeBenito |
d18e3d |
##############################
|
|
Chris PeBenito |
d18e3d |
#
|
|
Chris PeBenito |
d18e3d |
# $1_crond_t local policy
|
|
Chris PeBenito |
d18e3d |
#
|
|
Chris PeBenito |
d18e3d |
|
|
Chris PeBenito |
23caa6 |
allow $1_crond_t self:capability dac_override;
|
|
Chris PeBenito |
23caa6 |
allow $1_crond_t self:process { sigkill sigstop signull signal setsched };
|
|
Chris PeBenito |
23caa6 |
allow $1_crond_t self:fifo_file { read getattr write append };
|
|
Chris PeBenito |
23caa6 |
allow $1_crond_t self:unix_stream_socket { create ioctl read getattr write setattr append bind connect getopt setopt shutdown listen accept };
|
|
Chris PeBenito |
23caa6 |
allow $1_crond_t self:unix_dgram_socket { create ioctl read getattr write setattr append bind connect getopt setopt shutdown };
|
|
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 $1_crond_t $1_cron_spool_t:file entrypoint;
|
|
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 $1_crond_t:process transition;
|
|
Chris PeBenito |
075c4f |
dontaudit crond_t $1_crond_t:process { noatsecure siginh rlimitinh };
|
|
Chris PeBenito |
23caa6 |
|
|
Chris PeBenito |
23caa6 |
kernel_read_system_state($1_crond_t)
|
|
Chris PeBenito |
23caa6 |
kernel_read_kernel_sysctl($1_crond_t)
|
|
Chris PeBenito |
23caa6 |
|
|
Chris PeBenito |
075c4f |
# ps does not need to access /boot when run from cron
|
|
Chris PeBenito |
075c4f |
bootloader_ignore_search_bootloader_data_directory($1_crond_t)
|
|
Chris PeBenito |
075c4f |
|
|
Chris PeBenito |
23caa6 |
corenetwork_network_tcp_on_all_interfaces($1_crond_t)
|
|
Chris PeBenito |
23caa6 |
corenetwork_network_raw_on_all_interfaces($1_crond_t)
|
|
Chris PeBenito |
23caa6 |
corenetwork_network_udp_on_all_interfaces($1_crond_t)
|
|
Chris PeBenito |
23caa6 |
corenetwork_network_tcp_on_all_nodes($1_crond_t)
|
|
Chris PeBenito |
23caa6 |
corenetwork_network_raw_on_all_nodes($1_crond_t)
|
|
Chris PeBenito |
23caa6 |
corenetwork_network_udp_on_all_nodes($1_crond_t)
|
|
Chris PeBenito |
23caa6 |
corenetwork_network_tcp_on_all_ports($1_crond_t)
|
|
Chris PeBenito |
23caa6 |
corenetwork_network_udp_on_all_ports($1_crond_t)
|
|
Chris PeBenito |
23caa6 |
corenetwork_bind_tcp_on_all_nodes($1_crond_t)
|
|
Chris PeBenito |
23caa6 |
corenetwork_bind_udp_on_all_nodes($1_crond_t)
|
|
Chris PeBenito |
23caa6 |
|
|
Chris PeBenito |
23caa6 |
devices_get_pseudorandom_data($1_crond_t)
|
|
Chris PeBenito |
23caa6 |
|
|
Chris PeBenito |
23caa6 |
filesystem_get_all_filesystems_attributes($1_crond_t)
|
|
Chris PeBenito |
23caa6 |
|
|
Chris PeBenito |
23caa6 |
domain_execute_all_entrypoint_programs($1_crond_t)
|
|
Chris PeBenito |
23caa6 |
|
|
Chris PeBenito |
23caa6 |
files_read_general_application_resources($1_crond_t)
|
|
Chris PeBenito |
23caa6 |
files_execute_system_config_script($1_crond_t)
|
|
Chris PeBenito |
075c4f |
# for nscd:
|
|
Chris PeBenito |
075c4f |
files_ignore_search_runtime_data_directory($1_crond_t)
|
|
Chris PeBenito |
23caa6 |
|
|
Chris PeBenito |
23caa6 |
corecommands_execute_general_programs($1_crond_t)
|
|
Chris PeBenito |
23caa6 |
corecommands_execute_system_programs($1_crond_t)
|
|
Chris PeBenito |
23caa6 |
|
|
Chris PeBenito |
23caa6 |
libraries_use_dynamic_loader($1_crond_t)
|
|
Chris PeBenito |
dd14d0 |
libraries_use_shared_libraries($1_crond_t)
|
|
Chris PeBenito |
23caa6 |
libraries_execute_library_scripts($1_crond_t)
|
|
Chris PeBenito |
075c4f |
libraries_execute_dynamic_loader($1_crond_t)
|
|
Chris PeBenito |
23caa6 |
|
|
Chris PeBenito |
23caa6 |
files_read_runtime_system_config($1_crond_t)
|
|
Chris PeBenito |
23caa6 |
|
|
Chris PeBenito |
075c4f |
logging_search_system_log_directory($1_crond_t)
|
|
Chris PeBenito |
075c4f |
|
|
Chris PeBenito |
23caa6 |
selinux_read_config($1_crond_t)
|
|
Chris PeBenito |
23caa6 |
|
|
Chris PeBenito |
23caa6 |
miscfiles_read_localization($1_crond_t)
|
|
Chris PeBenito |
23caa6 |
|
|
Chris PeBenito |
075c4f |
tunable_policy(`fcron_crond', `
|
|
Chris PeBenito |
075c4f |
allow crond_t $1_cron_spool_t:file { create ioctl read getattr lock write setattr append link unlink rename };
|
|
Chris PeBenito |
075c4f |
')
|
|
Chris PeBenito |
075c4f |
|
|
Chris PeBenito |
23caa6 |
ifdef(`TODO',`
|
|
Chris PeBenito |
23caa6 |
# Access user files and dirs.
|
|
Chris PeBenito |
23caa6 |
allow $1_crond_t home_root_t:dir search;
|
|
Chris PeBenito |
23caa6 |
file_type_auto_trans($1_crond_t, $1_home_dir_t, $1_home_t)
|
|
Chris PeBenito |
23caa6 |
|
|
Chris PeBenito |
23caa6 |
# Run scripts in user home directory and access shared libs.
|
|
Chris PeBenito |
23caa6 |
can_exec($1_crond_t, $1_home_t)
|
|
Chris PeBenito |
23caa6 |
|
|
Chris PeBenito |
23caa6 |
file_type_auto_trans($1_crond_t, tmp_t, $1_tmp_t)
|
|
Chris PeBenito |
23caa6 |
|
|
Chris PeBenito |
23caa6 |
ifdef(`mta.te', `
|
|
Chris PeBenito |
23caa6 |
domain_auto_trans($1_crond_t, sendmail_exec_t, $1_mail_t)
|
|
Chris PeBenito |
23caa6 |
allow $1_crond_t sendmail_exec_t:lnk_file { getattr read };
|
|
Chris PeBenito |
23caa6 |
|
|
Chris PeBenito |
23caa6 |
# $1_mail_t should only be reading from the cron fifo not needing to write
|
|
Chris PeBenito |
23caa6 |
dontaudit $1_mail_t crond_t:fifo_file write;
|
|
Chris PeBenito |
23caa6 |
allow mta_user_agent $1_crond_t:fd use;
|
|
Chris PeBenito |
23caa6 |
')
|
|
Chris PeBenito |
23caa6 |
|
|
Chris PeBenito |
23caa6 |
# This domain is granted permissions common to most domains.
|
|
Chris PeBenito |
23caa6 |
can_ypbind($1_crond_t)
|
|
Chris PeBenito |
23caa6 |
allow $1_crond_t var_spool_t:dir search;
|
|
Chris PeBenito |
23caa6 |
allow $1_crond_t var_t:dir r_dir_perms;
|
|
Chris PeBenito |
23caa6 |
allow $1_crond_t var_t:file { getattr read ioctl };
|
|
Chris PeBenito |
23caa6 |
|
|
Chris PeBenito |
23caa6 |
# quiet other ps operations
|
|
Chris PeBenito |
23caa6 |
dontaudit $1_crond_t domain:dir { getattr search };
|
|
Chris PeBenito |
d18e3d |
') dnl endif TODO
|
|
Chris PeBenito |
d18e3d |
|
|
Chris PeBenito |
d18e3d |
##############################
|
|
Chris PeBenito |
d18e3d |
#
|
|
Chris PeBenito |
d18e3d |
# $1_crontab_t local policy
|
|
Chris PeBenito |
d18e3d |
#
|
|
Chris PeBenito |
d18e3d |
|
|
Chris PeBenito |
d18e3d |
# for ^Z
|
|
Chris PeBenito |
d18e3d |
allow $1_t $1_crontab_t:process signal;
|
|
Chris PeBenito |
d18e3d |
|
|
Chris PeBenito |
d18e3d |
# Allow crond to read those crontabs in cron spool.
|
|
Chris PeBenito |
d18e3d |
allow crond_t $1_cron_spool_t:file { getattr read };
|
|
Chris PeBenito |
d18e3d |
|
|
Chris PeBenito |
d18e3d |
# dac_override is to create the file in the directory under /tmp
|
|
Chris PeBenito |
d18e3d |
allow $1_crontab_t self:capability { setuid setgid chown dac_override };
|
|
Chris PeBenito |
d18e3d |
allow $1_crontab_t self:process { sigkill sigstop signull signal };
|
|
Chris PeBenito |
d18e3d |
|
|
Chris PeBenito |
075c4f |
# create files in /var/spool/cron
|
|
Chris PeBenito |
075c4f |
allow $1_crontab_t $1_cron_spool_t:file { create ioctl read getattr lock write setattr append link unlink rename };
|
|
Chris PeBenito |
075c4f |
allow $1_crontab_t cron_spool_t:dir { getattr search read write add_name remove_name };
|
|
Chris PeBenito |
075c4f |
type_transition $1_crontab_t $1_cron_spool_t:file system_crond_tmp_t;
|
|
Chris PeBenito |
075c4f |
|
|
Chris PeBenito |
d18e3d |
# crontab signals crond by updating the mtime on the spooldir
|
|
Chris PeBenito |
d18e3d |
allow $1_crontab_t cron_spool_t:dir setattr;
|
|
Chris PeBenito |
d18e3d |
|
|
Chris PeBenito |
d18e3d |
allow $1_crontab_t crond_log_t:file { getattr read append };
|
|
Chris PeBenito |
d18e3d |
|
|
Chris PeBenito |
d18e3d |
filesystem_get_persistent_filesystem_attributes($1_crontab_t)
|
|
Chris PeBenito |
d18e3d |
|
|
Chris PeBenito |
d18e3d |
domain_use_widely_inheritable_file_descriptors($1_crontab_t)
|
|
Chris PeBenito |
d18e3d |
|
|
Chris PeBenito |
d18e3d |
files_read_general_system_config($1_crontab_t)
|
|
Chris PeBenito |
d18e3d |
|
|
Chris PeBenito |
d18e3d |
libraries_use_dynamic_loader($1_crontab_t)
|
|
Chris PeBenito |
dd14d0 |
libraries_use_shared_libraries($1_crontab_t)
|
|
Chris PeBenito |
d18e3d |
|
|
Chris PeBenito |
d18e3d |
logging_send_system_log_message($1_crontab_t)
|
|
Chris PeBenito |
d18e3d |
|
|
Chris PeBenito |
d18e3d |
miscfiles_read_localization($1_crontab_t)
|
|
Chris PeBenito |
d18e3d |
|
|
Chris PeBenito |
d18e3d |
ifdef(`TODO',`
|
|
Chris PeBenito |
d18e3d |
|
|
Chris PeBenito |
d18e3d |
# Transition from the user domain to the derived domain.
|
|
Chris PeBenito |
d18e3d |
domain_auto_trans($1_t, crontab_exec_t, $1_crontab_t)
|
|
Chris PeBenito |
d18e3d |
|
|
Chris PeBenito |
d18e3d |
can_ps($1_t, $1_crontab_t)
|
|
Chris PeBenito |
d18e3d |
|
|
Chris PeBenito |
d18e3d |
dontaudit $1_crontab_t proc_t:dir search;
|
|
Chris PeBenito |
d18e3d |
dontaudit $1_crontab_t selinux_config_t:dir search;
|
|
Chris PeBenito |
d18e3d |
# for the checks used by crontab -u
|
|
Chris PeBenito |
d18e3d |
dontaudit $1_crontab_t security_t:dir search;
|
|
Chris PeBenito |
d18e3d |
|
|
Chris PeBenito |
d18e3d |
# Type for temporary files.
|
|
Chris PeBenito |
d18e3d |
file_type_auto_trans($1_crontab_t, tmp_t, $1_tmp_t, { dir file })
|
|
Chris PeBenito |
d18e3d |
|
|
Chris PeBenito |
d18e3d |
# Use the type when creating files in /var/spool/cron.
|
|
Chris PeBenito |
d18e3d |
allow sysadm_crontab_t $1_cron_spool_t:file { getattr read };
|
|
Chris PeBenito |
d18e3d |
|
|
Chris PeBenito |
075c4f |
tunable_policy(`fcron_crond', `
|
|
Chris PeBenito |
d18e3d |
# fcron wants an instant update of a crontab change for the administrator
|
|
Chris PeBenito |
d18e3d |
# also crontab does a security check for crontab -u
|
|
Chris PeBenito |
d18e3d |
ifelse(`$1', `sysadm', `
|
|
Chris PeBenito |
d18e3d |
allow $1_crontab_t self:process setfscreate;
|
|
Chris PeBenito |
d18e3d |
kernel_get_selinuxfs_mount_point($1_crontab_t)
|
|
Chris PeBenito |
d18e3d |
', `
|
|
Chris PeBenito |
d18e3d |
dontaudit $1_crontab_t crond_t:process signal;
|
|
Chris PeBenito |
d18e3d |
')dnl end ifelse
|
|
Chris PeBenito |
d18e3d |
')dnl end ifdef fcron
|
|
Chris PeBenito |
d18e3d |
|
|
Chris PeBenito |
d18e3d |
# Run helper programs as $1_t
|
|
Chris PeBenito |
d18e3d |
allow $1_crontab_t { bin_t sbin_t }:dir search;
|
|
Chris PeBenito |
d18e3d |
allow $1_crontab_t bin_t:lnk_file read;
|
|
Chris PeBenito |
d18e3d |
domain_auto_trans($1_crontab_t, { bin_t sbin_t shell_exec_t }, $1_t)
|
|
Chris PeBenito |
d18e3d |
|
|
Chris PeBenito |
d18e3d |
# Read user crontabs
|
|
Chris PeBenito |
d18e3d |
allow $1_crontab_t { $1_home_t $1_home_dir_t }:dir r_dir_perms;
|
|
Chris PeBenito |
d18e3d |
allow $1_crontab_t $1_home_t:file r_file_perms;
|
|
Chris PeBenito |
d18e3d |
dontaudit $1_crontab_t $1_home_dir_t:dir write;
|
|
Chris PeBenito |
d18e3d |
|
|
Chris PeBenito |
d18e3d |
# Access terminals.
|
|
Chris PeBenito |
075c4f |
allow $1_crontab_t devpts_t:dir { read search getattr };
|
|
Chris PeBenito |
075c4f |
allow $1_crontab_t $1_tty_device_t:chr_file { read write getattr ioctl };
|
|
Chris PeBenito |
075c4f |
allow $1_crontab_t $1_devpts_t:chr_file { read write getattr ioctl };
|
|
Chris PeBenito |
d18e3d |
|
|
Chris PeBenito |
d18e3d |
# Inherit and use descriptors from gnome-pty-helper.
|
|
Chris PeBenito |
d18e3d |
ifdef(`gnome-pty-helper.te', `allow $1_crontab_t $1_gph_t:fd use;')
|
|
Chris PeBenito |
d18e3d |
|
|
Chris PeBenito |
d18e3d |
dontaudit $1_crontab_t var_run_t:dir search;
|
|
Chris PeBenito |
23caa6 |
') 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 |
daa0e0 |
|
|
Chris PeBenito |
daa0e0 |
logging_read_system_logs($1_crond_t)
|
|
Chris PeBenito |
daa0e0 |
|
|
Chris PeBenito |
daa0e0 |
# Allow our crontab domain to unlink a user cron spool file.
|
|
Chris PeBenito |
daa0e0 |
#allow $1_crontab_t user_cron_spool_t:file unlink;
|
|
Chris PeBenito |
daa0e0 |
|
|
Chris PeBenito |
daa0e0 |
# Manipulate other users crontab.
|
|
Chris PeBenito |
daa0e0 |
kernel_get_selinuxfs_mount_point($1_crontab_t)
|
|
Chris PeBenito |
daa0e0 |
kernel_validate_selinux_context($1_crontab_t)
|
|
Chris PeBenito |
daa0e0 |
kernel_compute_selinux_access_vector($1_crontab_t)
|
|
Chris PeBenito |
daa0e0 |
kernel_compute_selinux_create_context($1_crontab_t)
|
|
Chris PeBenito |
daa0e0 |
kernel_compute_selinux_relabel_context($1_crontab_t)
|
|
Chris PeBenito |
daa0e0 |
kernel_compute_selinux_reachable_user_contexts($1_crontab_t)
|
|
Chris PeBenito |
daa0e0 |
')
|
|
Chris PeBenito |
3b857e |
|
|
Chris PeBenito |
3b857e |
########################################
|
|
Chris PeBenito |
3b857e |
#
|
|
Chris PeBenito |
3b857e |
# cron_modify_log(domain)
|
|
Chris PeBenito |
3b857e |
#
|
|
Chris PeBenito |
3b857e |
define(`cron_modify_log',`
|
|
Chris PeBenito |
3b857e |
requires_block_template(`$0'_depend)
|
|
Chris PeBenito |
3b857e |
allow $1 crond_log_t:file { getattr read write ioctl lock append };
|
|
Chris PeBenito |
3b857e |
')
|
|
Chris PeBenito |
3b857e |
|
|
Chris PeBenito |
3b857e |
define(`cron_modify_log_depend',`
|
|
Chris PeBenito |
3b857e |
type crond_log_t;
|
|
Chris PeBenito |
3b857e |
class file rw_file_perms;
|
|
Chris PeBenito |
3b857e |
')
|