Chris PeBenito ab58ad
#DESC Squid - Web cache
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Author:  Russell Coker <russell@coker.com.au>
Chris PeBenito ab58ad
# X-Debian-Packages: squid
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#################################
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Rules for the squid_t domain.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# squid_t is the domain the squid process runs in
Chris PeBenito ab58ad
ifdef(`apache.te',`
Chris PeBenito ab58ad
can_tcp_connect(squid_t, httpd_t)
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
bool squid_connect_any false;
Chris PeBenito ab58ad
daemon_domain(squid, `, web_client_domain, nscd_client_domain')
Chris PeBenito ab58ad
type squid_conf_t, file_type, sysadmfile;
Chris PeBenito ab58ad
general_domain_access(squid_t)
Chris PeBenito ab58ad
allow { squid_t initrc_t } squid_conf_t:file r_file_perms;
Chris PeBenito ab58ad
allow squid_t squid_conf_t:dir r_dir_perms;
Chris PeBenito ab58ad
allow squid_t squid_conf_t:lnk_file read;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
logdir_domain(squid)
Chris PeBenito ab58ad
rw_dir_create_file(initrc_t, squid_log_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
allow squid_t usr_t:file { getattr read };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# type for /var/cache/squid
Chris PeBenito ab58ad
type squid_cache_t, file_type, sysadmfile;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
allow squid_t self:capability { setgid setuid net_bind_service dac_override };
Chris PeBenito ab58ad
allow squid_t { etc_t etc_runtime_t }:file r_file_perms;
Chris PeBenito ab58ad
allow squid_t etc_t:lnk_file read;
Chris PeBenito ab58ad
allow squid_t self:unix_stream_socket create_socket_perms;
Chris PeBenito ab58ad
allow squid_t self:unix_dgram_socket create_socket_perms;
Chris PeBenito ab58ad
allow squid_t self:fifo_file rw_file_perms;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
read_sysctl(squid_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
allow squid_t devtty_t:chr_file rw_file_perms;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
allow squid_t { self proc_t }:file { read getattr };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# for when we use /var/spool/cache
Chris PeBenito ab58ad
allow squid_t var_spool_t:dir search;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Grant permissions to create, access, and delete cache files.
Chris PeBenito ab58ad
# No type transitions required, as the files inherit the parent directory type.
Chris PeBenito ab58ad
create_dir_file(squid_t, squid_cache_t)
Chris PeBenito ab58ad
ifdef(`logrotate.te',
Chris PeBenito ab58ad
`domain_auto_trans(logrotate_t, squid_exec_t, squid_t)')
Chris PeBenito ab58ad
ifdef(`crond.te', `domain_auto_trans(system_crond_t, squid_exec_t, squid_t)')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Use the network
Chris PeBenito ab58ad
can_network(squid_t)
Chris PeBenito ab58ad
if (squid_connect_any) {
Chris PeBenito ab58ad
allow squid_t port_type:tcp_socket name_connect;
Chris PeBenito ab58ad
} 
Chris PeBenito ab58ad
can_ypbind(squid_t)
Chris PeBenito ab58ad
can_tcp_connect(web_client_domain, squid_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# tcp port 8080 and udp port 3130 is http_cache_port_t (see net_contexts)
Chris PeBenito ab58ad
allow squid_t { gopher_port_t ftp_port_t http_port_t http_cache_port_t }:{ tcp_socket udp_socket } name_bind;
Chris PeBenito ab58ad
allow squid_t { gopher_port_t ftp_port_t http_port_t http_cache_port_t }:tcp_socket name_connect;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# to allow running programs from /usr/lib/squid (IE unlinkd)
Chris PeBenito ab58ad
# also allow exec()ing itself
Chris PeBenito ab58ad
can_exec(squid_t, { lib_t squid_exec_t bin_t sbin_t shell_exec_t } )
Chris PeBenito ab58ad
allow squid_t { bin_t sbin_t }:dir search;
Chris PeBenito ab58ad
allow squid_t { bin_t sbin_t }:lnk_file read;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
dontaudit squid_t { boot_t tmp_t home_root_t security_t devpts_t }:dir getattr;
Chris PeBenito ab58ad
ifdef(`targeted_policy', `
Chris PeBenito ab58ad
dontaudit squid_t tty_device_t:chr_file { read write };
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
allow squid_t urandom_device_t:chr_file { getattr read };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#squid requires the following when run in diskd mode, the recommended setting
Chris PeBenito ab58ad
allow squid_t tmpfs_t:file { read write };
Chris PeBenito ab58ad
r_dir_file(squid_t, cert_t)
Chris PeBenito ab58ad
ifdef(`winbind.te', `
Chris PeBenito ab58ad
domain_auto_trans(squid_t, winbind_helper_exec_t, winbind_helper_t)
Chris PeBenito ab58ad
allow winbind_helper_t squid_t:tcp_socket rw_socket_perms;
Chris PeBenito ab58ad
allow winbind_helper_t squid_log_t:file ra_file_perms;
Chris PeBenito ab58ad
')