policy_module(spamassassin, 2.6.1)

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

## <desc>
##	<p>
##	Allow user spamassassin clients to use the network.
##	</p>
## </desc>
gen_tunable(spamassassin_can_network, false)

## <desc>
##	<p>
##	Allow spamd to read/write user home directories.
##	</p>
## </desc>
gen_tunable(spamd_enable_home_dirs, true)

## <desc>
##	<p>
##	Allow spamd_update to connect to all ports.
##	</p>
## </desc>
gen_tunable(spamd_update_can_network, false)


type spamd_update_t;
type spamd_update_exec_t;
init_system_domain(spamd_update_t, spamd_update_exec_t)
init_daemon_domain(spamd_update_t, spamd_update_exec_t)
role system_r types spamd_update_t;

type spamd_t;
type spamd_exec_t;
init_daemon_domain(spamd_t, spamd_exec_t)

type spamd_compiled_t;
files_type(spamd_compiled_t)

type spamd_initrc_exec_t;
init_script_file(spamd_initrc_exec_t)

type spamd_log_t;
logging_log_file(spamd_log_t)

type spamd_spool_t;
files_spool_file(spamd_spool_t)

type spamd_tmp_t;
files_tmp_file(spamd_tmp_t)

# var/lib files
type spamd_var_lib_t;
files_type(spamd_var_lib_t)

type spamd_var_run_t;
files_pid_file(spamd_var_run_t)

ifdef(`distro_redhat',`
	# spamassassin client executable
	type spamc_t;
	type spamc_exec_t;
	application_domain(spamc_t, spamc_exec_t)
	role system_r types spamc_t;

	type spamd_etc_t;
	files_config_file(spamd_etc_t)

	typealias spamc_exec_t  alias spamassassin_exec_t;
	typealias spamc_t alias spamassassin_t;

	type spamc_home_t;
	userdom_user_home_content(spamc_home_t)
	typealias spamc_home_t alias { spamassassin_home_t user_spamassassin_home_t staff_spamassassin_home_t sysadm_spamassassin_home_t };
	typealias spamc_home_t alias { auditadm_spamassassin_home_t secadm_spamassassin_home_t };
	typealias spamc_home_t alias { user_spamc_home_t staff_spamc_home_t sysadm_spamc_home_t };
	typealias spamc_home_t alias { auditadm_spamc_home_t secadm_spamc_home_t };

	type spamc_tmp_t;
	files_tmp_file(spamc_tmp_t)
	typealias spamc_tmp_t alias spamassassin_tmp_t;
	typealias spamc_tmp_t alias { user_spamassassin_tmp_t staff_spamassassin_tmp_t sysadm_spamassassin_tmp_t };
	typealias spamc_tmp_t alias { auditadm_spamassassin_tmp_t secadm_spamassassin_tmp_t };

	typealias spamc_tmp_t alias { user_spamc_tmp_t staff_spamc_tmp_t sysadm_spamc_tmp_t };
	typealias spamc_tmp_t alias { auditadm_spamc_tmp_t secadm_spamc_tmp_t };
	typealias spamc_t alias pyzor_t;
	typealias spamc_exec_t alias pyzor_exec_t;
	typealias spamd_t alias pyzord_t;
	typealias spamd_initrc_exec_t alias pyzord_initrc_exec_t;
	typealias spamd_exec_t alias pyzord_exec_t;
	typealias spamc_tmp_t alias pyzor_tmp_t;
	typealias spamd_log_t alias pyzor_log_t;
	typealias spamd_log_t alias pyzord_log_t;
	typealias spamd_var_lib_t alias pyzor_var_lib_t;
	typealias spamd_etc_t alias pyzor_etc_t;
	typealias spamc_home_t alias pyzor_home_t;
	typealias spamc_home_t alias user_pyzor_home_t;
	typealias spamc_t alias razor_t;
	typealias spamc_exec_t alias razor_exec_t;
	typealias spamd_log_t alias razor_log_t;
	typealias spamd_var_lib_t alias razor_var_lib_t;
	typealias spamd_etc_t alias razor_etc_t;
	typealias spamc_home_t alias razor_home_t;
	typealias spamc_home_t alias { user_razor_home_t staff_razor_home_t sysadm_razor_home_t };
	typealias spamc_home_t alias { auditadm_razor_home_t secadm_razor_home_t };
	typealias spamc_tmp_t alias { user_razor_tmp_t staff_razor_tmp_t sysadm_razor_tmp_t };
	typealias spamc_tmp_t alias { auditadm_razor_tmp_t secadm_razor_tmp_t };
',`
	type spamassassin_t;
	type spamassassin_exec_t;
	typealias spamassassin_t alias { user_spamassassin_t staff_spamassassin_t sysadm_spamassassin_t };
	typealias spamassassin_t alias { auditadm_spamassassin_t secadm_spamassassin_t };
	application_domain(spamassassin_t, spamassassin_exec_t)
	ubac_constrained(spamassassin_t)

	type spamassassin_home_t;
	typealias spamassassin_home_t alias { user_spamassassin_home_t staff_spamassassin_home_t sysadm_spamassassin_home_t };
	typealias spamassassin_home_t alias { auditadm_spamassassin_home_t secadm_spamassassin_home_t };
	userdom_user_home_content(spamassassin_home_t)

	type spamassassin_tmp_t;
	typealias spamassassin_tmp_t alias { user_spamassassin_tmp_t staff_spamassassin_tmp_t sysadm_spamassassin_tmp_t };
	typealias spamassassin_tmp_t alias { auditadm_spamassassin_tmp_t secadm_spamassassin_tmp_t };
	files_tmp_file(spamassassin_tmp_t)
	ubac_constrained(spamassassin_tmp_t)

	type spamc_t;
	type spamc_exec_t;
	typealias spamc_t alias { user_spamc_t staff_spamc_t sysadm_spamc_t };
	typealias spamc_t alias { auditadm_spamc_t secadm_spamc_t };
	application_domain(spamc_t, spamc_exec_t)
	ubac_constrained(spamc_t)

	type spamc_tmp_t;
	typealias spamc_tmp_t alias { user_spamc_tmp_t staff_spamc_tmp_t sysadm_spamc_tmp_t };
	typealias spamc_tmp_t alias { auditadm_spamc_tmp_t secadm_spamc_tmp_t };
	files_tmp_file(spamc_tmp_t)
	ubac_constrained(spamc_tmp_t)
')

##############################
#
# Standalone program local policy
#

allow spamassassin_t self:process ~{ ptrace setcurrent setexec setfscreate setrlimit execmem execstack execheap };
allow spamassassin_t self:fd use;
allow spamassassin_t self:fifo_file rw_fifo_file_perms;
allow spamassassin_t self:sock_file read_sock_file_perms;
allow spamassassin_t self:unix_dgram_socket create_socket_perms;
allow spamassassin_t self:unix_stream_socket create_stream_socket_perms;
allow spamassassin_t self:unix_dgram_socket sendto;
allow spamassassin_t self:unix_stream_socket connectto;
allow spamassassin_t self:shm create_shm_perms;
allow spamassassin_t self:sem create_sem_perms;
allow spamassassin_t self:msgq create_msgq_perms;
allow spamassassin_t self:msg { send receive };

manage_dirs_pattern(spamassassin_t, spamassassin_home_t, spamassassin_home_t)
manage_files_pattern(spamassassin_t, spamassassin_home_t, spamassassin_home_t)
manage_lnk_files_pattern(spamassassin_t, spamassassin_home_t, spamassassin_home_t)
manage_fifo_files_pattern(spamassassin_t, spamassassin_home_t, spamassassin_home_t)
manage_sock_files_pattern(spamassassin_t, spamassassin_home_t, spamassassin_home_t)

manage_dirs_pattern(spamassassin_t, spamassassin_tmp_t, spamassassin_tmp_t)
manage_files_pattern(spamassassin_t, spamassassin_tmp_t, spamassassin_tmp_t)
files_tmp_filetrans(spamassassin_t, spamassassin_tmp_t, { file dir })

manage_dirs_pattern(spamd_t, spamassassin_home_t, spamassassin_home_t)
manage_files_pattern(spamd_t, spamassassin_home_t, spamassassin_home_t)
manage_lnk_files_pattern(spamd_t, spamassassin_home_t, spamassassin_home_t)
manage_fifo_files_pattern(spamd_t, spamassassin_home_t, spamassassin_home_t)
manage_sock_files_pattern(spamd_t, spamassassin_home_t, spamassassin_home_t)
userdom_home_manager(spamassassin_t)

kernel_read_kernel_sysctls(spamassassin_t)

dev_read_urand(spamassassin_t)

fs_search_auto_mountpoints(spamassassin_t)
fs_getattr_all_fs(spamassassin_t)

# this should probably be removed
corecmd_list_bin(spamassassin_t)
corecmd_read_bin_symlinks(spamassassin_t)
corecmd_read_bin_files(spamassassin_t)
corecmd_read_bin_pipes(spamassassin_t)
corecmd_read_bin_sockets(spamassassin_t)

domain_use_interactive_fds(spamassassin_t)

files_read_etc_runtime_files(spamassassin_t)
files_list_home(spamassassin_t)
files_dontaudit_search_var(spamassassin_t)

logging_send_syslog_msg(spamassassin_t)

# cjp: this could probably be removed
seutil_read_config(spamassassin_t)

sysnet_dns_name_resolve(spamassassin_t)

# set tunable if you have spamassassin do DNS lookups
tunable_policy(`spamassassin_can_network',`
	allow spamassassin_t self:tcp_socket create_stream_socket_perms;
	allow spamassassin_t self:udp_socket create_socket_perms;

	corenet_tcp_sendrecv_generic_if(spamassassin_t)
	corenet_udp_sendrecv_generic_if(spamassassin_t)
	corenet_tcp_sendrecv_generic_node(spamassassin_t)
	corenet_udp_sendrecv_generic_node(spamassassin_t)
	corenet_tcp_sendrecv_all_ports(spamassassin_t)
	corenet_udp_sendrecv_all_ports(spamassassin_t)
	corenet_tcp_connect_all_ports(spamassassin_t)
	corenet_sendrecv_all_client_packets(spamassassin_t)
	corenet_udp_bind_generic_node(spamassassin_t)
	corenet_udp_bind_generic_port(spamassassin_t)
	corenet_dontaudit_udp_bind_all_ports(spamassassin_t)

	sysnet_read_config(spamassassin_t)
')

tunable_policy(`spamd_enable_home_dirs',`
	userdom_manage_user_home_content_dirs(spamd_t)
	userdom_manage_user_home_content_files(spamd_t)
	userdom_manage_user_home_content_symlinks(spamd_t)
	userdom_exec_user_bin_files(spamd_t)
')

optional_policy(`
	# Write pid file and socket in ~/.evolution/cache/tmp
	evolution_home_filetrans(spamd_t, spamd_tmp_t, { file sock_file })
')

optional_policy(`
	tunable_policy(`spamassassin_can_network && nis_enabled',`
		nis_use_ypbind_uncond(spamassassin_t)
	')
')

optional_policy(`
	mta_read_config(spamassassin_t)
	sendmail_stub(spamassassin_t)
	sendmail_dontaudit_rw_unix_stream_sockets(spamassassin_t)
	sendmail_dontaudit_rw_tcp_sockets(spamassassin_t)
')

########################################
#
# Client local policy
#

allow spamc_t self:process ~{ ptrace setcurrent setexec setfscreate setrlimit execmem execstack execheap };
allow spamc_t self:fd use;
allow spamc_t self:fifo_file rw_fifo_file_perms;
allow spamc_t self:sock_file read_sock_file_perms;
allow spamc_t self:shm create_shm_perms;
allow spamc_t self:sem create_sem_perms;
allow spamc_t self:msgq create_msgq_perms;
allow spamc_t self:msg { send receive };
allow spamc_t self:unix_dgram_socket create_socket_perms;
allow spamc_t self:unix_stream_socket create_stream_socket_perms;
allow spamc_t self:unix_dgram_socket sendto;
allow spamc_t self:unix_stream_socket connectto;
allow spamc_t self:tcp_socket create_stream_socket_perms;
allow spamc_t self:udp_socket create_socket_perms;

can_exec(spamc_t, spamc_exec_t)

manage_dirs_pattern(spamc_t, spamc_tmp_t, spamc_tmp_t)
manage_files_pattern(spamc_t, spamc_tmp_t, spamc_tmp_t)
files_tmp_filetrans(spamc_t, spamc_tmp_t, { file dir })

manage_dirs_pattern(spamc_t, spamc_home_t, spamc_home_t)
manage_files_pattern(spamc_t, spamc_home_t, spamc_home_t)
manage_lnk_files_pattern(spamc_t, spamc_home_t, spamc_home_t)
manage_fifo_files_pattern(spamc_t, spamc_home_t, spamc_home_t)
manage_sock_files_pattern(spamc_t, spamc_home_t, spamc_home_t)
userdom_append_user_home_content_files(spamc_t)
spamassassin_filetrans_home_content(spamc_t)
spamassassin_filetrans_admin_home_content(spamc_t)
# for /root/.pyzor
allow spamc_t self:capability { dac_read_search dac_override };

list_dirs_pattern(spamc_t, spamd_var_lib_t, spamd_var_lib_t)
read_files_pattern(spamc_t, spamd_var_lib_t, spamd_var_lib_t)

read_files_pattern(spamc_t, spamd_spool_t, spamd_spool_t)
list_dirs_pattern(spamc_t, spamd_spool_t, spamd_spool_t)

allow spamc_t spamd_etc_t:dir list_dir_perms;
allow spamc_t spamd_etc_t:file read_file_perms;

# Allow connecting to a local spamd
allow spamc_t spamd_t:unix_stream_socket connectto;
allow spamc_t spamd_tmp_t:sock_file rw_sock_file_perms;
spamd_stream_connect(spamc_t)
allow spamc_t spamd_tmp_t:file read_inherited_file_perms;

kernel_read_kernel_sysctls(spamc_t)
kernel_read_network_state(spamc_t)
kernel_read_system_state(spamc_t)

corecmd_exec_bin(spamc_t)

corenet_all_recvfrom_netlabel(spamc_t)
corenet_tcp_sendrecv_generic_if(spamc_t)
corenet_udp_sendrecv_generic_if(spamc_t)
corenet_tcp_sendrecv_generic_node(spamc_t)
corenet_udp_sendrecv_generic_node(spamc_t)
corenet_tcp_sendrecv_all_ports(spamc_t)
corenet_udp_sendrecv_all_ports(spamc_t)
corenet_tcp_connect_all_ports(spamc_t)
corenet_sendrecv_all_client_packets(spamc_t)
corenet_tcp_connect_spamd_port(spamc_t)

fs_search_auto_mountpoints(spamc_t)

# cjp: these should probably be removed:
corecmd_list_bin(spamc_t)
corecmd_read_bin_symlinks(spamc_t)
corecmd_read_bin_files(spamc_t)
corecmd_read_bin_pipes(spamc_t)
corecmd_read_bin_sockets(spamc_t)

domain_use_interactive_fds(spamc_t)

files_read_etc_runtime_files(spamc_t)
files_dontaudit_search_var(spamc_t)
# cjp: this may be removable:
files_list_home(spamc_t)
files_list_var_lib(spamc_t)

fs_search_auto_mountpoints(spamc_t)

libs_exec_ldconfig(spamc_t)

logging_send_syslog_msg(spamc_t)

auth_use_nsswitch(spamc_t)

userdom_home_manager(spamc_t)

optional_policy(`
	abrt_stream_connect(spamc_t)
')

optional_policy(`
	amavis_manage_spool_files(spamc_t)
')

optional_policy(`
	# Allow connection to spamd socket above
	evolution_stream_connect(spamc_t)
')

optional_policy(`
    cyrus_stream_connect(spamc_t)
')

optional_policy(`
	milter_manage_spamass_state(spamc_t)
')

optional_policy(`
	postfix_domtrans_postdrop(spamc_t)
	postfix_search_spool(spamc_t)
	postfix_rw_local_pipes(spamc_t)
	postfix_rw_inherited_master_pipes(spamc_t)
')

optional_policy(`
	mta_send_mail(spamc_t)
	mta_read_config(spamc_t)
	mta_read_queue(spamc_t)
	sendmail_stub(spamc_t)
	sendmail_rw_pipes(spamc_t)
    mta_read_home_rw(spamc_t)
')

optional_policy(`
	postfix_domtrans_postdrop(spamc_t)
	postfix_search_spool(spamc_t)
	postfix_rw_local_pipes(spamc_t)
	postfix_rw_inherited_master_pipes(spamc_t)
')

########################################
#
# Server local policy
#

# Spamassassin, when run as root and using per-user config files,
# setuids to the user running spamc.  Comment this if you are not
# using this ability.

allow spamd_t self:capability { kill setuid setgid dac_read_search dac_override sys_tty_config };
dontaudit spamd_t self:capability sys_tty_config;
allow spamd_t self:process ~{ ptrace setcurrent setexec setfscreate setrlimit execmem execstack execheap };
allow spamd_t self:fd use;
allow spamd_t self:fifo_file rw_fifo_file_perms;
allow spamd_t self:sock_file read_sock_file_perms;
allow spamd_t self:shm create_shm_perms;
allow spamd_t self:sem create_sem_perms;
allow spamd_t self:msgq create_msgq_perms;
allow spamd_t self:msg { send receive };
allow spamd_t self:unix_dgram_socket create_socket_perms;
allow spamd_t self:unix_stream_socket create_stream_socket_perms;
allow spamd_t self:unix_dgram_socket sendto;
allow spamd_t self:unix_stream_socket connectto;
allow spamd_t self:tcp_socket create_stream_socket_perms;
allow spamd_t self:udp_socket create_socket_perms;

# needed by razor
list_dirs_pattern(spamd_t, spamd_etc_t, spamd_etc_t)
read_lnk_files_pattern(spamd_t, spamd_etc_t, spamd_etc_t)
rw_files_pattern(spamd_t, spamd_etc_t, spamd_etc_t)

can_exec(spamd_t, spamd_compiled_t)
manage_dirs_pattern(spamd_t, spamd_compiled_t, spamd_compiled_t)
manage_files_pattern(spamd_t, spamd_compiled_t, spamd_compiled_t)

manage_files_pattern(spamd_t, spamd_log_t, spamd_log_t)
logging_log_filetrans(spamd_t, spamd_log_t, file)

manage_dirs_pattern(spamd_t, spamd_spool_t, spamd_spool_t)
manage_files_pattern(spamd_t, spamd_spool_t, spamd_spool_t)
manage_sock_files_pattern(spamd_t, spamd_spool_t, spamd_spool_t)
manage_lnk_files_pattern(spamd_t, spamd_spool_t, spamd_spool_t)
files_spool_filetrans(spamd_t, spamd_spool_t, { file dir lnk_file })

manage_dirs_pattern(spamd_t, spamd_tmp_t, spamd_tmp_t)
manage_files_pattern(spamd_t, spamd_tmp_t, spamd_tmp_t)
files_tmp_filetrans(spamd_t, spamd_tmp_t, { file dir })

# var/lib files for spamd
manage_dirs_pattern(spamd_t, spamd_var_lib_t, spamd_var_lib_t)
manage_files_pattern(spamd_t, spamd_var_lib_t, spamd_var_lib_t)
manage_lnk_files_pattern(spamd_t, spamd_var_lib_t, spamd_var_lib_t)

manage_dirs_pattern(spamd_t, spamd_var_run_t, spamd_var_run_t)
manage_files_pattern(spamd_t, spamd_var_run_t, spamd_var_run_t)
manage_sock_files_pattern(spamd_t, spamd_var_run_t, spamd_var_run_t)
files_pid_filetrans(spamd_t, spamd_var_run_t, { file dir })

read_files_pattern(spamd_t, spamc_home_t, spamc_home_t)

can_exec(spamd_t, spamd_exec_t)

kernel_read_all_sysctls(spamd_t)
kernel_read_system_state(spamd_t)
kernel_read_network_state(spamd_t)

corenet_all_recvfrom_netlabel(spamd_t)
corenet_tcp_sendrecv_generic_if(spamd_t)
corenet_udp_sendrecv_generic_if(spamd_t)
corenet_tcp_sendrecv_generic_node(spamd_t)
corenet_udp_sendrecv_generic_node(spamd_t)
corenet_tcp_sendrecv_all_ports(spamd_t)
corenet_udp_sendrecv_all_ports(spamd_t)
corenet_tcp_bind_generic_node(spamd_t)
corenet_tcp_bind_spamd_port(spamd_t)
corenet_tcp_connect_all_unreserved_ports(spamd_t)
corenet_tcp_connect_spamd_port(spamd_t)
corenet_tcp_connect_razor_port(spamd_t)
corenet_tcp_connect_smtp_port(spamd_t)
corenet_sendrecv_razor_client_packets(spamd_t)
corenet_sendrecv_spamd_server_packets(spamd_t)
# spamassassin 3.1 needs this for its
# DnsResolver.pm module which binds to
# random ports >= 1024.
corenet_udp_bind_generic_node(spamd_t)
corenet_udp_bind_generic_port(spamd_t)
corenet_udp_bind_imaze_port(spamd_t)
corenet_dontaudit_udp_bind_all_ports(spamd_t)
corenet_sendrecv_imaze_server_packets(spamd_t)
corenet_sendrecv_generic_server_packets(spamd_t)

dev_read_sysfs(spamd_t)
dev_read_urand(spamd_t)

fs_getattr_all_fs(spamd_t)
fs_search_auto_mountpoints(spamd_t)

auth_dontaudit_read_shadow(spamd_t)

corecmd_exec_bin(spamd_t)

domain_use_interactive_fds(spamd_t)

files_read_etc_runtime_files(spamd_t)
# /var/lib/spamassin
files_read_var_lib_files(spamd_t)

init_dontaudit_rw_utmp(spamd_t)

auth_use_nsswitch(spamd_t)

libs_use_ld_so(spamd_t)
libs_use_shared_libs(spamd_t)

logging_send_syslog_msg(spamd_t)

userdom_use_unpriv_users_fds(spamd_t)
userdom_search_user_home_dirs(spamd_t)
userdom_home_manager(spamd_t)

optional_policy(`
	antivirus_stream_connect(spamd_t)
	antivirus_manage_db(spamd_t)
')

optional_policy(`
	exim_manage_spool_dirs(spamd_t)
	exim_manage_spool_files(spamd_t)
')

optional_policy(`
	cron_system_entry(spamd_t, spamd_exec_t)
')

optional_policy(`
	daemontools_service_domain(spamd_t, spamd_exec_t)
')

optional_policy(`
	dcc_domtrans_cdcc(spamd_t)
	dcc_domtrans_client(spamd_t)
	dcc_signal_client(spamd_t)
	dcc_stream_connect_dccifd(spamd_t)
')

optional_policy(`
	milter_manage_spamass_state(spamd_t)
')

optional_policy(`
	mysql_tcp_connect(spamd_t)
	mysql_search_db(spamd_t)
	mysql_stream_connect(spamd_t)
')

optional_policy(`
    logwatch_manage_cache(spamd_t)
')

optional_policy(`
	postfix_read_config(spamd_t)
')

optional_policy(`
	postgresql_tcp_connect(spamd_t)
	postgresql_stream_connect(spamd_t)
')

optional_policy(`
	pyzor_domtrans(spamd_t)
	pyzor_signal(spamd_t)
')

optional_policy(`
	razor_domtrans(spamd_t)
	razor_read_lib_files(spamd_t)
')

optional_policy(`
	tunable_policy(`spamd_enable_home_dirs',`
		razor_manage_user_home_files(spamd_t)
	')
')

optional_policy(`
    spamassassin_filetrans_home_content(spamd_t)
    spamassassin_filetrans_admin_home_content(spamd_t)
')

optional_policy(`
	seutil_sigchld_newrole(spamd_t)
')

optional_policy(`
	mta_send_mail(spamd_t)
	sendmail_stub(spamd_t)
	mta_read_config(spamd_t)
    mta_manage_spool(spamd_t)
')

optional_policy(`
	udev_read_db(spamd_t)
')

########################################
#
# spamd_update local policy
#

allow spamd_update_t self:fifo_file manage_fifo_file_perms;
allow spamd_update_t self:unix_dgram_socket create_socket_perms;
allow spamd_update_t self:unix_stream_socket create_stream_socket_perms;
allow spamd_update_t self:capability { dac_read_search dac_override };

manage_dirs_pattern(spamd_update_t, spamd_tmp_t, spamd_tmp_t)
manage_files_pattern(spamd_update_t, spamd_tmp_t, spamd_tmp_t)
files_tmp_filetrans(spamd_update_t, spamd_tmp_t, { file dir })

allow spamd_update_t spamd_var_lib_t:dir list_dir_perms;
manage_dirs_pattern(spamd_update_t, spamd_var_lib_t, spamd_var_lib_t)
manage_files_pattern(spamd_update_t, spamd_var_lib_t, spamd_var_lib_t)
manage_lnk_files_pattern(spamd_update_t, spamd_var_lib_t, spamd_var_lib_t)

manage_files_pattern(spamd_update_t, spamd_log_t, spamd_log_t)
logging_log_filetrans(spamd_update_t, spamd_log_t, file)

allow spamd_update_t spamc_home_t:dir search_dir_perms;
allow spamd_update_t spamd_tmp_t:file read_file_perms;

allow spamd_update_t spamc_home_t:dir search_dir_perms;

kernel_read_network_state(spamd_update_t)
kernel_read_system_state(spamd_update_t)

can_exec(spamd_update_t, spamd_update_exec_t)

can_exec(spamd_update_t, spamd_update_exec_t)

# for updating rules
corenet_tcp_connect_http_port(spamd_update_t)

corecmd_exec_bin(spamd_update_t)
corecmd_exec_shell(spamd_update_t)

dev_read_urand(spamd_update_t)

domain_use_interactive_fds(spamd_update_t)
domain_read_all_domains_state(spamd_update_t)

auth_use_nsswitch(spamd_update_t)
auth_dontaudit_read_shadow(spamd_update_t)

mta_read_config(spamd_update_t)

userdom_search_admin_dir(spamd_update_t)
userdom_use_inherited_user_ptys(spamd_update_t)

optional_policy(`
	antivirus_systemctl(spamd_update_t)
')

optional_policy(`
	cron_system_entry(spamd_update_t, spamd_update_exec_t)
')

optional_policy(`
	gpg_domtrans(spamd_update_t)
	gpg_manage_home_content(spamd_update_t)
')

tunable_policy(`spamd_update_can_network',`
	corenet_sendrecv_all_client_packets(spamd_update_t)
	corenet_tcp_connect_all_ports(spamd_update_t)
	corenet_tcp_sendrecv_all_ports(spamd_update_t)
')

optional_policy(`
    systemd_exec_systemctl(spamd_update_t)
')
