Chris PeBenito 29f3bf
policy_module(clamav, 1.8.1)
Chris PeBenito 4804cd
Chris PeBenito 4804cd
## <desc>
Dominick Grift 68ac47
##	

Dominick Grift 68ac47
##	Allow clamd to use JIT compiler
Dominick Grift 68ac47
##	

Chris PeBenito 4804cd
## </desc>
Chris PeBenito 4804cd
gen_tunable(clamd_use_jit, false)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
########################################
Chris PeBenito 17de1b
#
Chris PeBenito 17de1b
# Declarations
Chris PeBenito 17de1b
#
Chris PeBenito 17de1b
Chris PeBenito 17de1b
# Main clamd domain
Chris PeBenito 17de1b
type clamd_t;
Chris PeBenito 17de1b
type clamd_exec_t;
Chris PeBenito 17de1b
init_daemon_domain(clamd_t, clamd_exec_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
# configuration files
Chris PeBenito 17de1b
type clamd_etc_t;
Chris PeBenito ad0aea
files_config_file(clamd_etc_t)
Chris PeBenito ad0aea
Chris PeBenito ad0aea
type clamd_initrc_exec_t;
Chris PeBenito ad0aea
init_script_file(clamd_initrc_exec_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
# tmp files
Chris PeBenito 17de1b
type clamd_tmp_t;
Chris PeBenito 17de1b
files_tmp_file(clamd_tmp_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
# log files
Chris PeBenito 17de1b
type clamd_var_log_t;
Chris PeBenito 17de1b
logging_log_file(clamd_var_log_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
# var/lib files
Chris PeBenito 17de1b
type clamd_var_lib_t;
Chris PeBenito 17de1b
files_type(clamd_var_lib_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
# pid files
Chris PeBenito 17de1b
type clamd_var_run_t;
Chris PeBenito 17de1b
files_pid_file(clamd_var_run_t)
Chris PeBenito 465510
typealias clamd_var_run_t alias clamd_sock_t;
Chris PeBenito 17de1b
Chris PeBenito 17de1b
type clamscan_t;
Chris PeBenito 17de1b
type clamscan_exec_t;
Chris PeBenito 17de1b
init_daemon_domain(clamscan_t, clamscan_exec_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
# tmp files
Chris PeBenito 17de1b
type clamscan_tmp_t;
Chris PeBenito 17de1b
files_tmp_file(clamscan_tmp_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
type freshclam_t;
Chris PeBenito 17de1b
type freshclam_exec_t;
Chris PeBenito 17de1b
init_daemon_domain(freshclam_t, freshclam_exec_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
# log files
Chris PeBenito 17de1b
type freshclam_var_log_t;
Chris PeBenito 17de1b
logging_log_file(freshclam_var_log_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
########################################
Chris PeBenito 17de1b
#
Chris PeBenito 17de1b
# clamd local policy
Chris PeBenito 17de1b
#
Chris PeBenito 17de1b
Chris PeBenito 17de1b
allow clamd_t self:capability { kill setgid setuid dac_override };
Chris PeBenito 4804cd
dontaudit clamd_t self:capability sys_tty_config;
Dan Walsh 521289
allow clamd_t self:process signal;
Dan Walsh 521289
Chris PeBenito c0868a
allow clamd_t self:fifo_file rw_fifo_file_perms;
Chris PeBenito ad0aea
allow clamd_t self:unix_stream_socket { create_stream_socket_perms connectto };
Chris PeBenito 17de1b
allow clamd_t self:unix_dgram_socket create_socket_perms;
Chris PeBenito 17de1b
allow clamd_t self:tcp_socket { listen accept };
Chris PeBenito 17de1b
Chris PeBenito 17de1b
# configuration files
Chris PeBenito c0868a
allow clamd_t clamd_etc_t:dir list_dir_perms;
Chris PeBenito 0bfccd
read_files_pattern(clamd_t, clamd_etc_t, clamd_etc_t)
Chris PeBenito 0bfccd
read_lnk_files_pattern(clamd_t, clamd_etc_t, clamd_etc_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
# tmp files
Chris PeBenito 0bfccd
manage_dirs_pattern(clamd_t, clamd_tmp_t, clamd_tmp_t)
Chris PeBenito 0bfccd
manage_files_pattern(clamd_t, clamd_tmp_t, clamd_tmp_t)
Chris PeBenito 0bfccd
files_tmp_filetrans(clamd_t, clamd_tmp_t, { file dir })
Chris PeBenito 17de1b
Chris PeBenito 17de1b
# var/lib files for clamd
Dan Walsh 3eaa99
manage_sock_files_pattern(clamd_t, clamd_var_lib_t, clamd_var_lib_t)
Chris PeBenito 0bfccd
manage_dirs_pattern(clamd_t, clamd_var_lib_t, clamd_var_lib_t)
Chris PeBenito 0bfccd
manage_files_pattern(clamd_t, clamd_var_lib_t, clamd_var_lib_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
# log files
Chris PeBenito 0bfccd
manage_dirs_pattern(clamd_t, clamd_var_log_t, clamd_var_log_t)
Chris PeBenito 0bfccd
manage_files_pattern(clamd_t, clamd_var_log_t, clamd_var_log_t)
Chris PeBenito 0bfccd
logging_log_filetrans(clamd_t, clamd_var_log_t, { dir file })
Chris PeBenito 17de1b
Chris PeBenito 17de1b
# pid file
Dan Walsh 08e567
manage_dirs_pattern(clamd_t, clamd_var_run_t, clamd_var_run_t)
Chris PeBenito 0bfccd
manage_files_pattern(clamd_t, clamd_var_run_t, clamd_var_run_t)
Chris PeBenito 0bfccd
manage_sock_files_pattern(clamd_t, clamd_var_run_t, clamd_var_run_t)
Dan Walsh 3eaa99
files_pid_filetrans(clamd_t, clamd_var_run_t, { sock_file file dir })
Chris PeBenito 17de1b
Chris PeBenito 17de1b
kernel_dontaudit_list_proc(clamd_t)
Chris PeBenito d6d16b
kernel_read_sysctl(clamd_t)
Chris PeBenito 016e5c
kernel_read_kernel_sysctls(clamd_t)
Chris PeBenito ad0aea
kernel_read_system_state(clamd_t)
Chris PeBenito ad0aea
Chris PeBenito ad0aea
corecmd_exec_shell(clamd_t)
Chris PeBenito 17de1b
Chris PeBenito 190066
corenet_all_recvfrom_unlabeled(clamd_t)
Chris PeBenito 190066
corenet_all_recvfrom_netlabel(clamd_t)
Chris PeBenito 668b30
corenet_tcp_sendrecv_generic_if(clamd_t)
Chris PeBenito c12621
corenet_tcp_sendrecv_generic_node(clamd_t)
Chris PeBenito 17de1b
corenet_tcp_sendrecv_all_ports(clamd_t)
Chris PeBenito 17de1b
corenet_tcp_sendrecv_clamd_port(clamd_t)
Chris PeBenito c12621
corenet_tcp_bind_generic_node(clamd_t)
Chris PeBenito 17de1b
corenet_tcp_bind_clamd_port(clamd_t)
Chris PeBenito ad0aea
corenet_tcp_bind_generic_port(clamd_t)
Chris PeBenito ad0aea
corenet_tcp_connect_generic_port(clamd_t)
Chris PeBenito 17de1b
corenet_sendrecv_clamd_server_packets(clamd_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
dev_read_rand(clamd_t)
Chris PeBenito 17de1b
dev_read_urand(clamd_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
domain_use_interactive_fds(clamd_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
files_read_etc_files(clamd_t)
Chris PeBenito 17de1b
files_read_etc_runtime_files(clamd_t)
Chris PeBenito 17de1b
files_search_spool(clamd_t)
Chris PeBenito 17de1b
Chris PeBenito 192fb8
auth_use_nsswitch(clamd_t)
Chris PeBenito 192fb8
Chris PeBenito 17de1b
logging_send_syslog_msg(clamd_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
miscfiles_read_localization(clamd_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
cron_use_fds(clamd_t)
Chris PeBenito 17de1b
cron_use_system_job_fds(clamd_t)
Chris PeBenito 17de1b
cron_rw_pipes(clamd_t)
Chris PeBenito 17de1b
Chris PeBenito ad0aea
mta_read_config(clamd_t)
Chris PeBenito ad0aea
mta_send_mail(clamd_t)
Chris PeBenito ad0aea
Chris PeBenito 17de1b
optional_policy(`
Chris PeBenito 17de1b
	amavis_read_lib_files(clamd_t)
Chris PeBenito 17de1b
	amavis_read_spool_files(clamd_t)
Chris PeBenito 3f67f7
	amavis_spool_filetrans(clamd_t, clamd_var_run_t, sock_file)
Chris PeBenito 2c3ac4
	amavis_create_pid_files(clamd_t)
Chris PeBenito 17de1b
')
Chris PeBenito 17de1b
Chris PeBenito ad0aea
optional_policy(`
Chris PeBenito ad0aea
	exim_read_spool_files(clamd_t)
Chris PeBenito ad0aea
')
Chris PeBenito ad0aea
Chris PeBenito 29f3bf
tunable_policy(`clamd_use_jit',`
Chris PeBenito 29f3bf
	allow clamd_t self:process execmem;
Dan Walsh 3eaa99
	allow clamscan_t self:process execmem;
Dominick Grift 68ac47
',`
Chris PeBenito 29f3bf
	dontaudit clamd_t self:process execmem;
Dan Walsh 3eaa99
	dontaudit clamscan_t self:process execmem;
Chris PeBenito 29f3bf
')
Chris PeBenito 29f3bf
Chris PeBenito 17de1b
########################################
Chris PeBenito 17de1b
#
Chris PeBenito 17de1b
# Freshclam local policy
Chris PeBenito 17de1b
#
Chris PeBenito 17de1b
Chris PeBenito 17de1b
allow freshclam_t self:capability { setgid setuid dac_override };
Chris PeBenito c0868a
allow freshclam_t self:fifo_file rw_fifo_file_perms;
Chris PeBenito 17de1b
allow freshclam_t self:unix_stream_socket create_stream_socket_perms;
Chris PeBenito 17de1b
allow freshclam_t self:unix_dgram_socket create_socket_perms;
Chris PeBenito 17de1b
allow freshclam_t self:tcp_socket { listen accept };
Chris PeBenito 17de1b
Chris PeBenito 17de1b
# configuration files
Chris PeBenito c0868a
allow freshclam_t clamd_etc_t:dir list_dir_perms;
Chris PeBenito 0bfccd
read_files_pattern(freshclam_t, clamd_etc_t, clamd_etc_t)
Chris PeBenito 0bfccd
read_lnk_files_pattern(freshclam_t, clamd_etc_t, clamd_etc_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
# var/lib files together with clamd
Chris PeBenito 0bfccd
manage_dirs_pattern(freshclam_t, clamd_var_lib_t, clamd_var_lib_t)
Chris PeBenito 0bfccd
manage_files_pattern(freshclam_t, clamd_var_lib_t, clamd_var_lib_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
# pidfiles- var/run together with clamd
Chris PeBenito 0bfccd
manage_files_pattern(freshclam_t, clamd_var_run_t, clamd_var_run_t)
Chris PeBenito 0bfccd
manage_sock_files_pattern(freshclam_t, clamd_var_run_t, clamd_var_run_t)
Chris PeBenito 0bfccd
files_pid_filetrans(freshclam_t, clamd_var_run_t, file)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
# log files (own logfiles only)
Chris PeBenito 0bfccd
manage_files_pattern(freshclam_t, freshclam_var_log_t, freshclam_var_log_t)
Dominick Grift 1dfc76
allow freshclam_t freshclam_var_log_t:dir setattr_dir_perms;
Dan Walsh f5b49a
read_files_pattern(freshclam_t, clamd_var_log_t, clamd_var_log_t)
Chris PeBenito 0bfccd
logging_log_filetrans(freshclam_t, freshclam_var_log_t, file)
Chris PeBenito 17de1b
Dan Walsh 3eaa99
kernel_read_kernel_sysctls(freshclam_t)
Dan Walsh 3eaa99
kernel_read_system_state(freshclam_t)
Dan Walsh 3eaa99
Dan Walsh f5b49a
corecmd_exec_shell(freshclam_t)
Dan Walsh f5b49a
corecmd_exec_bin(freshclam_t)
Dan Walsh f5b49a
Chris PeBenito 190066
corenet_all_recvfrom_unlabeled(freshclam_t)
Chris PeBenito 190066
corenet_all_recvfrom_netlabel(freshclam_t)
Chris PeBenito 668b30
corenet_tcp_sendrecv_generic_if(freshclam_t)
Chris PeBenito c12621
corenet_tcp_sendrecv_generic_node(freshclam_t)
Chris PeBenito 17de1b
corenet_tcp_sendrecv_all_ports(freshclam_t)
Chris PeBenito 17de1b
corenet_tcp_sendrecv_clamd_port(freshclam_t)
Chris PeBenito 17de1b
corenet_tcp_connect_http_port(freshclam_t)
Dan Walsh 3eaa99
corenet_tcp_connect_clamd_port(freshclam_t)
Chris PeBenito 17de1b
corenet_sendrecv_http_client_packets(freshclam_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
dev_read_rand(freshclam_t)
Chris PeBenito 17de1b
dev_read_urand(freshclam_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
domain_use_interactive_fds(freshclam_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
files_read_etc_files(freshclam_t)
Chris PeBenito 17de1b
files_read_etc_runtime_files(freshclam_t)
Chris PeBenito 17de1b
Chris PeBenito 192fb8
auth_use_nsswitch(freshclam_t)
Chris PeBenito 17de1b
Chris PeBenito 4804cd
logging_send_syslog_msg(freshclam_t)
Chris PeBenito 4804cd
Chris PeBenito 192fb8
miscfiles_read_localization(freshclam_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
clamav_stream_connect(freshclam_t)
Chris PeBenito 17de1b
Dan Walsh 3eaa99
userdom_stream_connect(freshclam_t)
Dan Walsh 3eaa99
Chris PeBenito 29f3bf
tunable_policy(`clamd_use_jit',`
Chris PeBenito 29f3bf
	allow freshclam_t self:process execmem;
Dominick Grift 68ac47
',`
Chris PeBenito 29f3bf
	dontaudit freshclam_t self:process execmem;
Chris PeBenito 29f3bf
')
Chris PeBenito 29f3bf
Dominick Grift ef521e
optional_policy(`
Dominick Grift ef521e
	cron_system_entry(freshclam_t, freshclam_exec_t)
Dominick Grift ef521e
')
Dominick Grift ef521e
Chris PeBenito 17de1b
########################################
Chris PeBenito 17de1b
#
Chris PeBenito 17de1b
# clamscam local policy
Chris PeBenito 17de1b
#
Chris PeBenito 17de1b
Chris PeBenito 17de1b
allow clamscan_t self:capability { setgid setuid dac_override };
Chris PeBenito 17de1b
allow clamscan_t self:fifo_file rw_file_perms;
Chris PeBenito 17de1b
allow clamscan_t self:unix_stream_socket create_stream_socket_perms;
Chris PeBenito 17de1b
allow clamscan_t self:unix_dgram_socket create_socket_perms;
Chris PeBenito ad0aea
allow clamscan_t self:tcp_socket create_stream_socket_perms;
Chris PeBenito 17de1b
Chris PeBenito 17de1b
# configuration files
Chris PeBenito c0868a
allow clamscan_t clamd_etc_t:dir list_dir_perms;
Chris PeBenito 0bfccd
read_files_pattern(clamscan_t, clamd_etc_t, clamd_etc_t)
Chris PeBenito 0bfccd
read_lnk_files_pattern(clamscan_t, clamd_etc_t, clamd_etc_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
# tmp files
Chris PeBenito 0bfccd
manage_dirs_pattern(clamscan_t, clamscan_tmp_t, clamscan_tmp_t)
Chris PeBenito 0bfccd
manage_files_pattern(clamscan_t, clamscan_tmp_t, clamscan_tmp_t)
Chris PeBenito 0bfccd
files_tmp_filetrans(clamscan_t, clamscan_tmp_t, { file dir })
Chris PeBenito 17de1b
Chris PeBenito 17de1b
# var/lib files together with clamd
Chris PeBenito 0bfccd
manage_files_pattern(clamscan_t, clamd_var_lib_t, clamd_var_lib_t)
Chris PeBenito c0868a
allow clamscan_t clamd_var_lib_t:dir list_dir_perms;
Chris PeBenito 17de1b
Chris PeBenito ad0aea
corenet_all_recvfrom_unlabeled(clamscan_t)
Chris PeBenito ad0aea
corenet_all_recvfrom_netlabel(clamscan_t)
Chris PeBenito ad0aea
corenet_tcp_sendrecv_generic_if(clamscan_t)
Chris PeBenito ad0aea
corenet_tcp_sendrecv_generic_node(clamscan_t)
Chris PeBenito ad0aea
corenet_tcp_sendrecv_all_ports(clamscan_t)
Chris PeBenito ad0aea
corenet_tcp_sendrecv_clamd_port(clamscan_t)
Chris PeBenito ad0aea
corenet_tcp_connect_clamd_port(clamscan_t)
Chris PeBenito ad0aea
Chris PeBenito 17de1b
kernel_read_kernel_sysctls(clamscan_t)
Dan Walsh 3eaa99
kernel_read_system_state(clamscan_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
files_read_etc_files(clamscan_t)
Chris PeBenito 17de1b
files_read_etc_runtime_files(clamscan_t)
Chris PeBenito 17de1b
files_search_var_lib(clamscan_t)
Chris PeBenito 17de1b
Chris PeBenito 016e5c
init_read_utmp(clamscan_t)
Chris PeBenito 016e5c
init_dontaudit_write_utmp(clamscan_t)
Chris PeBenito 016e5c
Chris PeBenito 17de1b
miscfiles_read_localization(clamscan_t)
Chris PeBenito 17de1b
miscfiles_read_public_files(clamscan_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
clamav_stream_connect(clamscan_t)
Chris PeBenito 17de1b
Chris PeBenito ad0aea
mta_send_mail(clamscan_t)
Chris PeBenito ad0aea
Chris PeBenito 17de1b
optional_policy(`
Chris PeBenito 192fb8
	amavis_read_spool_files(clamscan_t)
Chris PeBenito 192fb8
')
Chris PeBenito 192fb8
Chris PeBenito 192fb8
optional_policy(`
Chris PeBenito 17de1b
	apache_read_sys_content(clamscan_t)
Chris PeBenito 17de1b
')