2006-03-07 18:07:15 +00:00
|
|
|
|
2009-08-05 14:59:21 +00:00
|
|
|
policy_module(tor, 1.6.0)
|
2006-03-07 18:07:15 +00:00
|
|
|
|
|
|
|
########################################
|
|
|
|
#
|
|
|
|
# Declarations
|
|
|
|
#
|
|
|
|
|
|
|
|
type tor_t;
|
|
|
|
type tor_exec_t;
|
|
|
|
init_daemon_domain(tor_t, tor_exec_t)
|
|
|
|
|
|
|
|
# etc/tor
|
|
|
|
type tor_etc_t;
|
|
|
|
files_config_file(tor_etc_t)
|
|
|
|
|
2008-10-08 15:50:03 +00:00
|
|
|
type tor_initrc_exec_t;
|
|
|
|
init_script_file(tor_initrc_exec_t)
|
|
|
|
|
2006-03-07 18:07:15 +00:00
|
|
|
# var/lib/tor
|
|
|
|
type tor_var_lib_t;
|
|
|
|
files_type(tor_var_lib_t)
|
|
|
|
|
|
|
|
# log files
|
|
|
|
type tor_var_log_t;
|
|
|
|
logging_log_file(tor_var_log_t)
|
|
|
|
|
|
|
|
# pid files
|
|
|
|
type tor_var_run_t;
|
|
|
|
files_pid_file(tor_var_run_t)
|
|
|
|
|
|
|
|
########################################
|
|
|
|
#
|
|
|
|
# tor local policy
|
|
|
|
#
|
|
|
|
|
2009-05-06 14:26:20 +00:00
|
|
|
allow tor_t self:capability { setgid setuid sys_tty_config };
|
2008-10-16 16:09:20 +00:00
|
|
|
allow tor_t self:fifo_file rw_fifo_file_perms;
|
2006-03-07 18:07:15 +00:00
|
|
|
allow tor_t self:unix_stream_socket create_stream_socket_perms;
|
|
|
|
allow tor_t self:netlink_route_socket r_netlink_socket_perms;
|
2006-03-16 18:53:55 +00:00
|
|
|
allow tor_t self:tcp_socket create_stream_socket_perms;
|
2006-03-07 18:07:15 +00:00
|
|
|
|
|
|
|
# configuration files
|
2006-12-12 20:08:08 +00:00
|
|
|
allow tor_t tor_etc_t:dir list_dir_perms;
|
2008-07-23 21:38:39 +00:00
|
|
|
read_files_pattern(tor_t, tor_etc_t, tor_etc_t)
|
|
|
|
read_lnk_files_pattern(tor_t, tor_etc_t, tor_etc_t)
|
2006-03-07 18:07:15 +00:00
|
|
|
|
|
|
|
# var/lib/tor files
|
2008-07-23 21:38:39 +00:00
|
|
|
manage_dirs_pattern(tor_t, tor_var_lib_t, tor_var_lib_t)
|
|
|
|
manage_files_pattern(tor_t, tor_var_lib_t, tor_var_lib_t)
|
|
|
|
manage_sock_files_pattern(tor_t, tor_var_lib_t, tor_var_lib_t)
|
|
|
|
files_usr_filetrans(tor_t, tor_var_lib_t, file)
|
|
|
|
files_var_filetrans(tor_t, tor_var_lib_t, { file dir sock_file })
|
|
|
|
files_var_lib_filetrans(tor_t, tor_var_lib_t, file)
|
2006-03-07 18:07:15 +00:00
|
|
|
|
|
|
|
# log files
|
2006-12-12 20:08:08 +00:00
|
|
|
allow tor_t tor_var_log_t:dir setattr;
|
2008-07-23 21:38:39 +00:00
|
|
|
manage_files_pattern(tor_t, tor_var_log_t, tor_var_log_t)
|
|
|
|
manage_sock_files_pattern(tor_t, tor_var_log_t, tor_var_log_t)
|
|
|
|
logging_log_filetrans(tor_t, tor_var_log_t, { sock_file file dir })
|
2006-03-07 18:07:15 +00:00
|
|
|
|
|
|
|
# pid file
|
2008-07-23 21:38:39 +00:00
|
|
|
manage_files_pattern(tor_t, tor_var_run_t, tor_var_run_t)
|
|
|
|
manage_sock_files_pattern(tor_t, tor_var_run_t, tor_var_run_t)
|
|
|
|
files_pid_filetrans(tor_t, tor_var_run_t, { file sock_file })
|
2006-03-07 18:07:15 +00:00
|
|
|
|
2006-09-04 18:22:12 +00:00
|
|
|
kernel_read_system_state(tor_t)
|
|
|
|
|
2006-03-07 18:07:15 +00:00
|
|
|
# networking basics
|
2007-06-27 15:23:21 +00:00
|
|
|
corenet_all_recvfrom_unlabeled(tor_t)
|
|
|
|
corenet_all_recvfrom_netlabel(tor_t)
|
2009-01-06 20:24:10 +00:00
|
|
|
corenet_tcp_sendrecv_generic_if(tor_t)
|
2009-01-09 19:48:02 +00:00
|
|
|
corenet_tcp_sendrecv_generic_node(tor_t)
|
2006-03-07 18:07:15 +00:00
|
|
|
corenet_tcp_sendrecv_all_ports(tor_t)
|
|
|
|
corenet_tcp_sendrecv_all_reserved_ports(tor_t)
|
2009-01-09 19:48:02 +00:00
|
|
|
corenet_tcp_bind_generic_node(tor_t)
|
2006-05-30 19:46:34 +00:00
|
|
|
corenet_tcp_bind_tor_port(tor_t)
|
|
|
|
corenet_sendrecv_tor_server_packets(tor_t)
|
2006-03-07 18:07:15 +00:00
|
|
|
# TOR will need to connect to various ports
|
|
|
|
corenet_tcp_connect_all_ports(tor_t)
|
2006-05-30 19:46:34 +00:00
|
|
|
corenet_sendrecv_all_client_packets(tor_t)
|
2006-03-07 18:07:15 +00:00
|
|
|
# ... especially including port 80 and other privileged ports
|
|
|
|
corenet_tcp_connect_all_reserved_ports(tor_t)
|
|
|
|
|
|
|
|
# tor uses crypto and needs random
|
|
|
|
dev_read_urand(tor_t)
|
|
|
|
|
|
|
|
domain_use_interactive_fds(tor_t)
|
|
|
|
|
|
|
|
files_read_etc_files(tor_t)
|
2006-09-04 18:22:12 +00:00
|
|
|
files_read_etc_runtime_files(tor_t)
|
|
|
|
|
2008-10-08 15:50:03 +00:00
|
|
|
auth_use_nsswitch(tor_t)
|
|
|
|
|
2006-03-07 18:07:15 +00:00
|
|
|
miscfiles_read_localization(tor_t)
|
|
|
|
|
2006-03-24 16:13:54 +00:00
|
|
|
optional_policy(`
|
2006-03-07 18:07:15 +00:00
|
|
|
seutil_sigchld_newrole(tor_t)
|
|
|
|
')
|