Chris PeBenito ce3145
Chris PeBenito aa5f87
policy_module(tor,1.0.2)
Chris PeBenito ce3145
Chris PeBenito ce3145
########################################
Chris PeBenito ce3145
#
Chris PeBenito ce3145
# Declarations
Chris PeBenito ce3145
#
Chris PeBenito ce3145
Chris PeBenito ce3145
type tor_t;
Chris PeBenito ce3145
type tor_exec_t;
Chris PeBenito ce3145
init_daemon_domain(tor_t, tor_exec_t)
Chris PeBenito ce3145
Chris PeBenito ce3145
# etc/tor
Chris PeBenito ce3145
type tor_etc_t;
Chris PeBenito ce3145
files_config_file(tor_etc_t)
Chris PeBenito ce3145
Chris PeBenito ce3145
# var/lib/tor
Chris PeBenito ce3145
type tor_var_lib_t;
Chris PeBenito ce3145
files_type(tor_var_lib_t)
Chris PeBenito ce3145
Chris PeBenito ce3145
# log files
Chris PeBenito ce3145
type tor_var_log_t;
Chris PeBenito ce3145
logging_log_file(tor_var_log_t)
Chris PeBenito ce3145
Chris PeBenito ce3145
# pid files
Chris PeBenito ce3145
type tor_var_run_t;
Chris PeBenito ce3145
files_pid_file(tor_var_run_t)
Chris PeBenito ce3145
Chris PeBenito ce3145
########################################
Chris PeBenito ce3145
#
Chris PeBenito ce3145
# tor local policy
Chris PeBenito ce3145
#
Chris PeBenito ce3145
Chris PeBenito ce3145
allow tor_t self:fifo_file { read write };
Chris PeBenito ce3145
allow tor_t self:unix_stream_socket create_stream_socket_perms;
Chris PeBenito ce3145
allow tor_t self:netlink_route_socket r_netlink_socket_perms;
Chris PeBenito aa5f87
allow tor_t self:tcp_socket create_stream_socket_perms;
Chris PeBenito ce3145
Chris PeBenito ce3145
# configuration files
Chris PeBenito ce3145
allow tor_t tor_etc_t:dir r_dir_perms;
Chris PeBenito ce3145
allow tor_t tor_etc_t:file r_file_perms;
Chris PeBenito ce3145
allow tor_t tor_etc_t:lnk_file { getattr read };
Chris PeBenito ce3145
Chris PeBenito ce3145
# var/lib/tor files
Chris PeBenito ce3145
allow tor_t tor_var_lib_t:file create_file_perms;
Chris PeBenito ce3145
allow tor_t tor_var_lib_t:sock_file create_file_perms;
Chris PeBenito ce3145
allow tor_t tor_var_lib_t:dir create_dir_perms;
Chris PeBenito ce3145
files_usr_filetrans(tor_t,tor_var_lib_t,file)
Chris PeBenito ce3145
files_var_filetrans(tor_t,tor_var_lib_t,{ file dir sock_file })
Chris PeBenito ce3145
files_var_lib_filetrans(tor_t,tor_var_lib_t,file)
Chris PeBenito ce3145
Chris PeBenito ce3145
# log files
Chris PeBenito ce3145
allow tor_t tor_var_log_t:file create_file_perms;
Chris PeBenito ce3145
allow tor_t tor_var_log_t:sock_file create_file_perms;
Chris PeBenito ce3145
allow tor_t tor_var_log_t:dir { rw_dir_perms setattr };
Chris PeBenito ce3145
logging_log_filetrans(tor_t,tor_var_log_t,{ sock_file file dir })
Chris PeBenito ce3145
Chris PeBenito ce3145
# pid file
Chris PeBenito ce3145
allow tor_t tor_var_run_t:file manage_file_perms;
Chris PeBenito ce3145
allow tor_t tor_var_run_t:sock_file manage_file_perms;
Chris PeBenito ce3145
allow tor_t tor_var_run_t:dir rw_dir_perms;
Chris PeBenito ce3145
files_pid_filetrans(tor_t,tor_var_run_t, { file sock_file })
Chris PeBenito ce3145
Chris PeBenito ce3145
# networking basics
Chris PeBenito ce3145
corenet_tcp_sendrecv_all_if(tor_t)
Chris PeBenito ce3145
corenet_tcp_sendrecv_all_nodes(tor_t)
Chris PeBenito ce3145
corenet_tcp_sendrecv_all_ports(tor_t)
Chris PeBenito ce3145
corenet_tcp_sendrecv_all_reserved_ports(tor_t)
Chris PeBenito ce3145
corenet_non_ipsec_sendrecv(tor_t)
Chris PeBenito ce3145
# TOR will need to connect to various ports
Chris PeBenito ce3145
corenet_tcp_connect_all_ports(tor_t)
Chris PeBenito ce3145
# ... especially including port 80 and other privileged ports
Chris PeBenito ce3145
corenet_tcp_connect_all_reserved_ports(tor_t)
Chris PeBenito 0c54fc
corenet_tcp_bind_tor_port(tor_t)
Chris PeBenito ce3145
corenet_tcp_bind_all_nodes(tor_t)
Chris PeBenito ce3145
Chris PeBenito ce3145
# tor uses crypto and needs random
Chris PeBenito ce3145
dev_read_urand(tor_t)
Chris PeBenito ce3145
Chris PeBenito ce3145
domain_use_interactive_fds(tor_t)
Chris PeBenito ce3145
Chris PeBenito ce3145
files_read_etc_files(tor_t)
Chris PeBenito ce3145
Chris PeBenito ce3145
# comm with init
Chris PeBenito ce3145
init_use_fds(tor_t)
Chris PeBenito ce3145
init_use_script_ptys(tor_t)
Chris PeBenito ce3145
Chris PeBenito ce3145
libs_use_ld_so(tor_t)
Chris PeBenito ce3145
libs_use_shared_libs(tor_t)
Chris PeBenito ce3145
Chris PeBenito ce3145
miscfiles_read_localization(tor_t)
Chris PeBenito ce3145
Chris PeBenito ce3145
sysnet_dns_name_resolve(tor_t)
Chris PeBenito ce3145
Chris PeBenito bb7170
optional_policy(`
Chris PeBenito ce3145
	seutil_sigchld_newrole(tor_t)
Chris PeBenito ce3145
')