Chris PeBenito eb3cb6
Chris PeBenito 18cc01
policy_module(portmap,1.1.1)
Chris PeBenito eb3cb6
Chris PeBenito eb3cb6
########################################
Chris PeBenito eb3cb6
#
Chris PeBenito eb3cb6
# Declarations
Chris PeBenito eb3cb6
#
Chris PeBenito eb3cb6
Chris PeBenito eb3cb6
type portmap_t;
Chris PeBenito eb3cb6
type portmap_exec_t;
Chris PeBenito eb3cb6
init_daemon_domain(portmap_t,portmap_exec_t)
Chris PeBenito eb3cb6
Chris PeBenito eb3cb6
type portmap_helper_t;
Chris PeBenito eb3cb6
type portmap_helper_exec_t;
Chris PeBenito eb3cb6
init_system_domain(portmap_helper_t,portmap_helper_exec_t)
Chris PeBenito eb3cb6
role system_r types portmap_helper_t;
Chris PeBenito eb3cb6
Chris PeBenito eb3cb6
type portmap_tmp_t;
Chris PeBenito eb3cb6
files_tmp_file(portmap_tmp_t)
Chris PeBenito eb3cb6
Chris PeBenito eb3cb6
type portmap_var_run_t;
Chris PeBenito eb3cb6
files_pid_file(portmap_var_run_t)
Chris PeBenito eb3cb6
Chris PeBenito eb3cb6
########################################
Chris PeBenito eb3cb6
#
Chris PeBenito eb3cb6
# Portmap local policy
Chris PeBenito eb3cb6
#
Chris PeBenito eb3cb6
Chris PeBenito eb3cb6
allow portmap_t self:capability { setuid setgid };
Chris PeBenito eb3cb6
dontaudit portmap_t self:capability sys_tty_config;
Chris PeBenito eb3cb6
allow portmap_t self:netlink_route_socket r_netlink_socket_perms;
Chris PeBenito eb3cb6
allow portmap_t self:unix_dgram_socket create_socket_perms;
Chris PeBenito eb3cb6
allow portmap_t self:unix_stream_socket create_stream_socket_perms;
Chris PeBenito eb3cb6
allow portmap_t self:tcp_socket create_stream_socket_perms;
Chris PeBenito eb3cb6
allow portmap_t self:udp_socket create_socket_perms;
Chris PeBenito eb3cb6
Chris PeBenito eb3cb6
allow portmap_t portmap_tmp_t:dir create_dir_perms;
Chris PeBenito eb3cb6
allow portmap_t portmap_tmp_t:file create_file_perms;
Chris PeBenito 103fe2
files_tmp_filetrans(portmap_t, portmap_tmp_t, { file dir })
Chris PeBenito eb3cb6
Chris PeBenito eb3cb6
allow portmap_t portmap_var_run_t:file create_file_perms;
Chris PeBenito b9ea0f
allow portmap_t portmap_var_run_t:dir rw_dir_perms;
Chris PeBenito 103fe2
files_pid_filetrans(portmap_t,portmap_var_run_t)
Chris PeBenito eb3cb6
Chris PeBenito 445522
kernel_read_kernel_sysctls(portmap_t)
Chris PeBenito eb3cb6
kernel_list_proc(portmap_t)
Chris PeBenito eb3cb6
kernel_read_proc_symlinks(portmap_t)
Chris PeBenito 43989f
kernel_tcp_recvfrom(portmap_t) 
Chris PeBenito eb3cb6
Chris PeBenito eb3cb6
corenet_tcp_sendrecv_all_if(portmap_t)
Chris PeBenito eb3cb6
corenet_udp_sendrecv_all_if(portmap_t)
Chris PeBenito eb3cb6
corenet_raw_sendrecv_all_if(portmap_t)
Chris PeBenito eb3cb6
corenet_tcp_sendrecv_all_nodes(portmap_t)
Chris PeBenito eb3cb6
corenet_udp_sendrecv_all_nodes(portmap_t)
Chris PeBenito eb3cb6
corenet_raw_sendrecv_all_nodes(portmap_t)
Chris PeBenito eb3cb6
corenet_tcp_sendrecv_all_ports(portmap_t)
Chris PeBenito eb3cb6
corenet_udp_sendrecv_all_ports(portmap_t)
Chris PeBenito bd7037
corenet_non_ipsec_sendrecv(portmap_t)
Chris PeBenito eb3cb6
corenet_tcp_bind_all_nodes(portmap_t)
Chris PeBenito eb3cb6
corenet_udp_bind_all_nodes(portmap_t)
Chris PeBenito eb3cb6
corenet_tcp_bind_portmap_port(portmap_t)
Chris PeBenito eb3cb6
corenet_udp_bind_portmap_port(portmap_t)
Chris PeBenito 0907bd
corenet_tcp_connect_all_ports(portmap_t)
Chris PeBenito eb3cb6
# portmap binds to arbitary ports
Chris PeBenito eb3cb6
corenet_tcp_bind_generic_port(portmap_t)
Chris PeBenito eb3cb6
corenet_udp_bind_generic_port(portmap_t)
Chris PeBenito eb3cb6
corenet_tcp_bind_reserved_port(portmap_t)
Chris PeBenito eb3cb6
corenet_udp_bind_reserved_port(portmap_t)
Chris PeBenito eb3cb6
corenet_dontaudit_tcp_bind_all_reserved_ports(portmap_t)
Chris PeBenito eb3cb6
corenet_dontaudit_udp_bind_all_reserved_ports(portmap_t)
Chris PeBenito eb3cb6
Chris PeBenito eb3cb6
dev_read_sysfs(portmap_t)
Chris PeBenito eb3cb6
Chris PeBenito eb3cb6
fs_getattr_all_fs(portmap_t)
Chris PeBenito eb3cb6
fs_search_auto_mountpoints(portmap_t)
Chris PeBenito eb3cb6
Chris PeBenito eb3cb6
term_dontaudit_use_console(portmap_t)
Chris PeBenito eb3cb6
Chris PeBenito 15722e
domain_use_interactive_fds(portmap_t)
Chris PeBenito eb3cb6
Chris PeBenito eb3cb6
files_read_etc_files(portmap_t)
Chris PeBenito eb3cb6
Chris PeBenito eb3cb6
init_use_fd(portmap_t)
Chris PeBenito 1815ba
init_use_script_ptys(portmap_t)
Chris PeBenito 1815ba
init_udp_send(portmap_t)
Chris PeBenito 1815ba
init_udp_send_script(portmap_t)
Chris PeBenito eb3cb6
Chris PeBenito eb3cb6
libs_use_ld_so(portmap_t)
Chris PeBenito eb3cb6
libs_use_shared_libs(portmap_t)
Chris PeBenito eb3cb6
Chris PeBenito eb3cb6
logging_send_syslog_msg(portmap_t)
Chris PeBenito eb3cb6
Chris PeBenito eb3cb6
miscfiles_read_localization(portmap_t)
Chris PeBenito eb3cb6
Chris PeBenito eb3cb6
sysnet_read_config(portmap_t)
Chris PeBenito eb3cb6
Chris PeBenito 15722e
userdom_dontaudit_use_unpriv_user_fds(portmap_t)
Chris PeBenito 103fe2
userdom_dontaudit_search_sysadm_home_dirs(portmap_t)
Chris PeBenito eb3cb6
Chris PeBenito eb3cb6
ifdef(`targeted_policy', `
Chris PeBenito 1815ba
	term_dontaudit_use_unallocated_ttys(portmap_t)
Chris PeBenito 1815ba
	term_dontaudit_use_generic_ptys(portmap_t)
Chris PeBenito 9e04f5
	files_dontaudit_read_root_files(portmap_t)
Chris PeBenito eb3cb6
')
Chris PeBenito eb3cb6
Chris PeBenito 132880
optional_policy(`inetd',`
Chris PeBenito eb3cb6
	inetd_udp_sendto(portmap_t)
Chris PeBenito eb3cb6
')
Chris PeBenito eb3cb6
Chris PeBenito 132880
optional_policy(`mount',`
Chris PeBenito eb3cb6
	mount_send_nfs_client_request(portmap_t)
Chris PeBenito eb3cb6
')
Chris PeBenito eb3cb6
Chris PeBenito 132880
optional_policy(`nis',`
Chris PeBenito eb3cb6
	nis_use_ypbind(portmap_t)
Chris PeBenito 1815ba
	nis_udp_send_ypbind(portmap_t)
Chris PeBenito eb3cb6
')
Chris PeBenito eb3cb6
Chris PeBenito 132880
optional_policy(`nscd',`
Chris PeBenito 1815ba
	nscd_socket_use(portmap_t)
Chris PeBenito eb3cb6
')
Chris PeBenito eb3cb6
Chris PeBenito 132880
optional_policy(`rpc',`
Chris PeBenito 1815ba
	rpc_udp_send_nfs(portmap_t)
Chris PeBenito 43989f
') 
Chris PeBenito 43989f
Chris PeBenito 132880
optional_policy(`selinuxutil',`
Chris PeBenito eb3cb6
	seutil_sigchld_newrole(portmap_t)
Chris PeBenito eb3cb6
')
Chris PeBenito eb3cb6
Chris PeBenito 132880
optional_policy(`udev',`
Chris PeBenito eb3cb6
	udev_read_db(portmap_t)
Chris PeBenito eb3cb6
')
Chris PeBenito eb3cb6
Chris PeBenito eb3cb6
ifdef(`TODO',`
Chris PeBenito eb3cb6
ifdef(`rpcd.te',`can_udp_send(portmap_t, rpcd_t)')
Chris PeBenito eb3cb6
allow portmap_t rpcd_t:udp_socket sendto;
Chris PeBenito eb3cb6
allow rpcd_t portmap_t:udp_socket recvfrom;
Chris PeBenito eb3cb6
Chris PeBenito eb3cb6
ifdef(`lpd.te',`can_udp_send(portmap_t, lpd_t)')
Chris PeBenito eb3cb6
allow portmap_t lpd_t:udp_socket sendto;
Chris PeBenito eb3cb6
allow lpd_t portmap_t:udp_socket recvfrom;
Chris PeBenito eb3cb6
Chris PeBenito eb3cb6
can_udp_send(portmap_t, kernel_t)
Chris PeBenito eb3cb6
allow portmap_t kernel_t:udp_socket sendto;
Chris PeBenito eb3cb6
allow kernel_t portmap_t:udp_socket recvfrom;
Chris PeBenito eb3cb6
Chris PeBenito eb3cb6
can_udp_send(kernel_t, portmap_t)
Chris PeBenito eb3cb6
allow kernel_t portmap_t:udp_socket sendto;
Chris PeBenito eb3cb6
allow portmap_t kernel_t:udp_socket recvfrom;
Chris PeBenito eb3cb6
Chris PeBenito eb3cb6
') dnl end TODO
Chris PeBenito eb3cb6
Chris PeBenito eb3cb6
########################################
Chris PeBenito eb3cb6
#
Chris PeBenito eb3cb6
# Portmap helper local policy
Chris PeBenito eb3cb6
#
Chris PeBenito eb3cb6
Chris PeBenito eb3cb6
dontaudit portmap_helper_t self:capability net_admin;
Chris PeBenito eb3cb6
allow portmap_helper_t self:netlink_route_socket r_netlink_socket_perms;
Chris PeBenito eb3cb6
allow portmap_helper_t self:tcp_socket create_stream_socket_perms;
Chris PeBenito eb3cb6
allow portmap_helper_t self:udp_socket create_socket_perms;
Chris PeBenito eb3cb6
Chris PeBenito 0907bd
allow portmap_helper_t portmap_var_run_t:file create_file_perms;
Chris PeBenito 103fe2
files_pid_filetrans(portmap_helper_t,portmap_var_run_t)
Chris PeBenito 0907bd
Chris PeBenito eb3cb6
corenet_tcp_sendrecv_all_if(portmap_helper_t)
Chris PeBenito eb3cb6
corenet_udp_sendrecv_all_if(portmap_helper_t)
Chris PeBenito eb3cb6
corenet_raw_sendrecv_all_if(portmap_helper_t)
Chris PeBenito eb3cb6
corenet_tcp_sendrecv_all_nodes(portmap_helper_t)
Chris PeBenito eb3cb6
corenet_udp_sendrecv_all_nodes(portmap_helper_t)
Chris PeBenito eb3cb6
corenet_raw_sendrecv_all_nodes(portmap_helper_t)
Chris PeBenito eb3cb6
corenet_tcp_sendrecv_all_ports(portmap_helper_t)
Chris PeBenito eb3cb6
corenet_udp_sendrecv_all_ports(portmap_helper_t)
Chris PeBenito bd7037
corenet_non_ipsec_sendrecv(portmap_helper_t)
Chris PeBenito eb3cb6
corenet_tcp_bind_all_nodes(portmap_helper_t)
Chris PeBenito eb3cb6
corenet_udp_bind_all_nodes(portmap_helper_t)
Chris PeBenito eb3cb6
corenet_tcp_bind_reserved_port(portmap_helper_t)
Chris PeBenito eb3cb6
corenet_udp_bind_reserved_port(portmap_helper_t)
Chris PeBenito eb3cb6
corenet_dontaudit_tcp_bind_all_reserved_ports(portmap_helper_t)
Chris PeBenito eb3cb6
corenet_dontaudit_udp_bind_all_reserved_ports(portmap_helper_t)
Chris PeBenito 0907bd
corenet_tcp_connect_all_ports(portmap_helper_t)
Chris PeBenito eb3cb6
Chris PeBenito 15722e
domain_dontaudit_use_interactive_fds(portmap_helper_t)
Chris PeBenito b7e182
Chris PeBenito eb3cb6
files_read_etc_files(portmap_helper_t)
Chris PeBenito eb3cb6
files_rw_generic_pids(portmap_helper_t)
Chris PeBenito eb3cb6
Chris PeBenito 68228b
init_rw_utmp(portmap_helper_t)
Chris PeBenito eb3cb6
Chris PeBenito eb3cb6
libs_use_ld_so(portmap_helper_t)
Chris PeBenito eb3cb6
libs_use_shared_libs(portmap_helper_t)
Chris PeBenito eb3cb6
Chris PeBenito 2526a4
logging_send_syslog_msg(portmap_helper_t)
Chris PeBenito 2526a4
Chris PeBenito eb3cb6
sysnet_read_config(portmap_helper_t)
Chris PeBenito eb3cb6
Chris PeBenito 15722e
userdom_dontaudit_use_all_users_fds(portmap_helper_t)
Chris PeBenito eb3cb6
Chris PeBenito 725926
ifdef(`targeted_policy', `
Chris PeBenito 1815ba
	term_dontaudit_use_unallocated_ttys(portmap_helper_t)
Chris PeBenito 1815ba
	term_dontaudit_use_generic_ptys(portmap_helper_t)
Chris PeBenito 725926
')
Chris PeBenito 725926
Chris PeBenito 132880
optional_policy(`mount',`
Chris PeBenito eb3cb6
	mount_send_nfs_client_request(portmap_helper_t)
Chris PeBenito eb3cb6
')
Chris PeBenito eb3cb6
Chris PeBenito 132880
optional_policy(`nis',`
Chris PeBenito eb3cb6
	nis_use_ypbind(portmap_helper_t)
Chris PeBenito eb3cb6
')
Chris PeBenito 28e730
Chris PeBenito 28e730
# temporary:
Chris PeBenito 28e730
gen_require(`
Chris PeBenito 28e730
	type rpcd_t, nfsd_t;
Chris PeBenito 28e730
')
Chris PeBenito 28e730
# rpcd_t needs to talk to the portmap_t domain
Chris PeBenito 1815ba
portmap_udp_chat(rpcd_t) 
Chris PeBenito 28e730
portmap_tcp_connect(nfsd_t) 
Chris PeBenito 1815ba
portmap_udp_chat(nfsd_t)