Chris PeBenito 29af4c
policy_module(clamav, 1.8.0)
Chris PeBenito 4804cd
Chris PeBenito 4804cd
## <desc>
Chris PeBenito 4804cd
## 

Chris PeBenito 4804cd
## Allow clamd to use JIT compiler
Chris PeBenito 4804cd
## 

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;
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
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
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_run_t, clamd_var_run_t)
Chris PeBenito 0bfccd
manage_sock_files_pattern(clamd_t, clamd_var_run_t, clamd_var_run_t)
Chris PeBenito 0bfccd
files_pid_filetrans(clamd_t, clamd_var_run_t, { 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 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)
Chris PeBenito c0868a
allow freshclam_t freshclam_var_log_t:dir setattr;
Chris PeBenito c0868a
allow freshclam_t clamd_var_log_t:dir search_dir_perms;
Chris PeBenito 0bfccd
logging_log_filetrans(freshclam_t, freshclam_var_log_t, file)
Chris PeBenito 17de1b
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)
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
Chris PeBenito 192fb8
optional_policy(`
Chris PeBenito 192fb8
	cron_system_entry(freshclam_t, freshclam_exec_t)
Chris PeBenito 192fb8
')
Chris PeBenito 17de1b
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)
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 4804cd
tunable_policy(`clamd_use_jit',`
Chris PeBenito 4804cd
	allow clamd_t self:process execmem;
Chris PeBenito 4804cd
', `
Chris PeBenito 4804cd
	dontaudit clamd_t self:process execmem;
Chris PeBenito 4804cd
')
Chris PeBenito 4804cd
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
')