policy_module(yam, 1.5.0)

########################################
#
# Declarations
#

attribute_role yam_roles;

type yam_t alias yam_crond_t;
type yam_exec_t;
application_domain(yam_t, yam_exec_t)
role yam_roles types yam_t;

type yam_content_t;
files_mountpoint(yam_content_t)

type yam_etc_t;
files_config_file(yam_etc_t)

type yam_tmp_t;
files_tmp_file(yam_tmp_t)

########################################
#
# Local policy
#

allow yam_t self:capability { chown fowner fsetid dac_read_search  };
allow yam_t self:process ~{ ptrace setcurrent setexec setfscreate setrlimit execstack execheap };
allow yam_t self:fd use;
allow yam_t self:fifo_file rw_fifo_file_perms;
allow yam_t self:unix_stream_socket { accept connectto listen };
allow yam_t self:unix_dgram_socket sendto;

manage_dirs_pattern(yam_t, yam_content_t, yam_content_t)
manage_files_pattern(yam_t, yam_content_t, yam_content_t)
manage_lnk_files_pattern(yam_t, yam_content_t, yam_content_t)

allow yam_t yam_etc_t:file read_file_perms;

manage_files_pattern(yam_t, yam_tmp_t, yam_tmp_t)
manage_dirs_pattern(yam_t, yam_tmp_t, yam_tmp_t)
files_tmp_filetrans(yam_t, yam_tmp_t, { file dir })

kernel_read_system_state(yam_t)

corecmd_exec_bin(yam_t)
corecmd_exec_shell(yam_t)

corenet_all_recvfrom_unlabeled(yam_t)
corenet_all_recvfrom_netlabel(yam_t)
corenet_tcp_sendrecv_generic_if(yam_t)
corenet_tcp_sendrecv_generic_node(yam_t)

corenet_sendrecv_http_client_packets(yam_t)
corenet_tcp_connect_http_port(yam_t)
corenet_tcp_sendrecv_http_port(yam_t)

corenet_sendrecv_rsync_client_packets(yam_t)
corenet_tcp_connect_rsync_port(yam_t)
corenet_tcp_sendrecv_rsync_port(yam_t)

dev_read_urand(yam_t)

files_read_etc_runtime_files(yam_t)
files_exec_usr_files(yam_t)

fs_search_auto_mountpoints(yam_t)
fs_read_iso9660_files(yam_t)

auth_use_nsswitch(yam_t)

logging_send_syslog_msg(yam_t)

seutil_read_config(yam_t)

sysnet_read_config(yam_t)

userdom_use_inherited_user_terminals(yam_t)
userdom_use_unpriv_users_fds(yam_t)
userdom_search_user_home_dirs(yam_t)

apache_search_sys_content(yam_t)

optional_policy(`
	cron_system_entry(yam_t, yam_exec_t)
')

optional_policy(`
	mount_domtrans(yam_t)
')

optional_policy(`
	rsync_exec(yam_t)
')
