policy_module(rshd, 1.8.1)

########################################
#
# Declarations
#
type rshd_t;
type rshd_exec_t;
inetd_tcp_service_domain(rshd_t, rshd_exec_t)
init_abstract_socket_activation(rshd_t)
domain_subj_id_change_exemption(rshd_t)
domain_role_change_exemption(rshd_t)
role system_r types rshd_t;

type rshd_keytab_t;
files_type(rshd_keytab_t)

########################################
#
# Local policy
#
allow rshd_t self:capability { kill setuid setgid fowner fsetid chown dac_read_search  };
allow rshd_t self:process { signal_perms fork setsched setpgid setexec };
allow rshd_t self:fifo_file rw_fifo_file_perms;
allow rshd_t self:tcp_socket create_stream_socket_perms;

allow rshd_t rshd_keytab_t:file read_file_perms;

kernel_read_kernel_sysctls(rshd_t)
kernel_read_net_sysctls(rshd_t)

corenet_all_recvfrom_netlabel(rshd_t)
corenet_tcp_sendrecv_generic_if(rshd_t)
corenet_udp_sendrecv_generic_if(rshd_t)
corenet_tcp_sendrecv_generic_node(rshd_t)
corenet_udp_sendrecv_generic_node(rshd_t)
corenet_tcp_sendrecv_all_ports(rshd_t)
corenet_udp_sendrecv_all_ports(rshd_t)
corenet_tcp_bind_generic_node(rshd_t)
corenet_tcp_bind_rsh_port(rshd_t)
corenet_tcp_bind_all_rpc_ports(rshd_t)
corenet_tcp_connect_all_ports(rshd_t)
corenet_tcp_connect_all_rpc_ports(rshd_t)
corenet_sendrecv_rsh_server_packets(rshd_t)

dev_read_urand(rshd_t)

domain_interactive_fd(rshd_t)

selinux_get_fs_mount(rshd_t)
selinux_validate_context(rshd_t)
selinux_compute_access_vector(rshd_t)
selinux_compute_create_context(rshd_t)
selinux_compute_relabel_context(rshd_t)
selinux_compute_user_contexts(rshd_t)

corecmd_read_bin_symlinks(rshd_t)

files_list_home(rshd_t)
files_search_tmp(rshd_t)

auth_login_pgm_domain(rshd_t)
auth_write_login_records(rshd_t)

init_rw_utmp(rshd_t)

logging_send_syslog_msg(rshd_t)
logging_search_logs(rshd_t)

seutil_read_config(rshd_t)
seutil_read_default_contexts(rshd_t)

userdom_search_user_home_content(rshd_t)
userdom_manage_tmp_role(system_r, rshd_t)

userdom_home_reader(rshd_t)

optional_policy(`
	kerberos_manage_host_rcache(rshd_t)
	kerberos_read_keytab(rshd_t)
	kerberos_tmp_filetrans_host_rcache(rshd_t, "host_0")
	kerberos_use(rshd_t)
')

optional_policy(`
	rlogin_read_home_content(rshd_t)
')

optional_policy(`
	tcpd_wrapped_domain(rshd_t, rshd_exec_t)
')

optional_policy(`
	unconfined_shell_domtrans(rshd_t)
	unconfined_signal(rshd_t)
')
