Chris PeBenito 31b7c0
#DESC CLAM - Anti-virus program
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
# Author:  Brian May <bam@snoopy.apana.org.au>
Chris PeBenito 31b7c0
# X-Debian-Packages: clamav
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
#################################
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
# Rules for the clamscan_t domain.
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Virus database
Chris PeBenito 31b7c0
type clamav_var_lib_t, file_type, sysadmfile;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# clamscan_t is the domain of the clamscan virus scanner
Chris PeBenito 31b7c0
type clamscan_exec_t, file_type, sysadmfile, exec_type;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
##########
Chris PeBenito 31b7c0
##########
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
# Freshclam
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
daemon_base_domain(freshclam, `, web_client_domain')
Chris PeBenito 31b7c0
read_locale(freshclam_t)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# not sure why it needs this
Chris PeBenito 31b7c0
read_sysctl(freshclam_t)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
can_network_client_tcp(freshclam_t, http_port_t);
Chris PeBenito 31b7c0
allow freshclam_t http_port_t:tcp_socket name_connect;
Chris PeBenito 31b7c0
can_resolve(freshclam_t)
Chris PeBenito 31b7c0
can_ypbind(freshclam_t)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Access virus signatures
Chris PeBenito 31b7c0
allow freshclam_t { var_t var_lib_t }:dir search;
Chris PeBenito 31b7c0
rw_dir_create_file(freshclam_t, clamav_var_lib_t)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
allow freshclam_t devtty_t:chr_file { read write };
Chris PeBenito 31b7c0
allow freshclam_t devpts_t:dir search;
Chris PeBenito 31b7c0
allow freshclam_t etc_t:file { getattr read };
Chris PeBenito 31b7c0
allow freshclam_t proc_t:file { getattr read };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
allow freshclam_t urandom_device_t:chr_file { getattr read };
Chris PeBenito 31b7c0
dontaudit freshclam_t urandom_device_t:chr_file ioctl;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# for nscd
Chris PeBenito 31b7c0
dontaudit freshclam_t var_run_t:dir search;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# setuid/getuid used (although maybe not required...)
Chris PeBenito 31b7c0
allow freshclam_t self:capability { setgid setuid };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
allow freshclam_t sbin_t:dir search;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Allow notification to daemon that virus database has changed
Chris PeBenito 31b7c0
can_clamd_connect(freshclam)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
allow freshclam_t etc_runtime_t:file { read getattr };
Chris PeBenito 31b7c0
allow freshclam_t self:unix_stream_socket create_stream_socket_perms;
Chris PeBenito 31b7c0
allow freshclam_t self:unix_dgram_socket create_socket_perms;
Chris PeBenito 31b7c0
allow freshclam_t self:fifo_file rw_file_perms;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Log files for freshclam executable
Chris PeBenito 31b7c0
logdir_domain(freshclam)
Chris PeBenito 31b7c0
allow initrc_t freshclam_log_t:file append;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Pid files for freshclam
Chris PeBenito 31b7c0
allow initrc_t clamd_var_run_t:file { create setattr };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
system_crond_entry(freshclam_exec_t, freshclam_t)
Chris PeBenito 31b7c0
domain_auto_trans(logrotate_t, freshclam_exec_t, freshclam_t)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
domain_auto_trans(sysadm_t, freshclam_exec_t, freshclam_t)
Chris PeBenito 31b7c0
role sysadm_r types freshclam_t;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
create_dir_file(freshclam_t, clamd_var_run_t)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
##########
Chris PeBenito 31b7c0
##########
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
# Clamscan
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# macros/program/clamav_macros.te.
Chris PeBenito 31b7c0
user_clamscan_domain(sysadm)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
##########
Chris PeBenito 31b7c0
##########
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
# Clamd
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
type clamd_sock_t, file_type, sysadmfile;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# clamd executable
Chris PeBenito 31b7c0
daemon_domain(clamd)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
tmp_domain(clamd)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# The dir containing the clamd log files is labelled freshclam_t
Chris PeBenito 31b7c0
logdir_domain(clamd)
Chris PeBenito 31b7c0
allow clamd_t freshclam_log_t:dir search;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
allow clamd_t self:capability { kill setgid setuid dac_override };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Give the clamd local communications socket a unique type
Chris PeBenito 31b7c0
ifdef(`distro_debian', `
Chris PeBenito 31b7c0
file_type_auto_trans(clamd_t, var_run_t, clamd_sock_t, sock_file)
Chris PeBenito 31b7c0
')
Chris PeBenito 31b7c0
ifdef(`distro_redhat', `
Chris PeBenito 31b7c0
file_type_auto_trans(clamd_t, clamd_var_run_t, clamd_sock_t, sock_file)
Chris PeBenito 31b7c0
')
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Clamd can be configured to listen on a TCP port.
Chris PeBenito 31b7c0
can_network_server_tcp(clamd_t, clamd_port_t)
Chris PeBenito 31b7c0
allow clamd_t clamd_port_t:tcp_socket name_bind;
Chris PeBenito 31b7c0
can_resolve(clamd_t);
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
allow clamd_t var_lib_t:dir search;
Chris PeBenito 31b7c0
r_dir_file(clamd_t, clamav_var_lib_t)
Chris PeBenito 31b7c0
r_dir_file(clamd_t, etc_t)
Chris PeBenito 31b7c0
# allow access /proc/sys/kernel/version
Chris PeBenito 31b7c0
read_sysctl(clamd_t)
Chris PeBenito 31b7c0
allow clamd_t self:unix_stream_socket create_stream_socket_perms;
Chris PeBenito 31b7c0
allow clamd_t self:unix_dgram_socket create_stream_socket_perms;
Chris PeBenito 31b7c0
allow clamd_t self:fifo_file rw_file_perms;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
allow clamd_t { random_device_t urandom_device_t }:chr_file { getattr read };
Chris PeBenito 31b7c0
dontaudit clamd_t { random_device_t urandom_device_t }:chr_file ioctl;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
##########
Chris PeBenito 31b7c0
##########
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
# Interaction with external programs
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
ifdef(`amavis.te',`
Chris PeBenito 31b7c0
allow amavisd_t clamd_var_run_t:dir search;
Chris PeBenito 31b7c0
allow amavisd_t clamd_t:unix_stream_socket connectto;
Chris PeBenito 31b7c0
allow amavisd_t clamd_sock_t:sock_file write;
Chris PeBenito 31b7c0
')
Chris PeBenito 31b7c0