policy_module(remotelogin, 1.8.0)

########################################
#
# Declarations
#

type remote_login_t;
domain_interactive_fd(remote_login_t)
auth_login_pgm_domain(remote_login_t)
auth_login_entry_type(remote_login_t)

########################################
#
# Remote login remote policy
#

allow remote_login_t self:capability { dac_override dac_read_search chown fowner fsetid kill setgid setuid net_bind_service sys_nice sys_resource sys_tty_config };
allow remote_login_t self:process ~{ ptrace setcurrent setexec setfscreate setrlimit execmem execstack execheap };
allow remote_login_t self:process { setrlimit setexec };
allow remote_login_t self:fd use;
allow remote_login_t self:fifo_file rw_fifo_file_perms;
allow remote_login_t self:sock_file read_sock_file_perms;
allow remote_login_t self:unix_dgram_socket create_socket_perms;
allow remote_login_t self:unix_stream_socket create_stream_socket_perms;
allow remote_login_t self:unix_dgram_socket sendto;
allow remote_login_t self:unix_stream_socket connectto;
allow remote_login_t self:shm create_shm_perms;
allow remote_login_t self:sem create_sem_perms;
allow remote_login_t self:msgq create_msgq_perms;
allow remote_login_t self:msg { send receive };
allow remote_login_t self:key write;

kernel_read_system_state(remote_login_t)
kernel_read_kernel_sysctls(remote_login_t)

dev_getattr_mouse_dev(remote_login_t)
dev_setattr_mouse_dev(remote_login_t)
dev_dontaudit_search_sysfs(remote_login_t)

fs_getattr_xattr_fs(remote_login_t)
fs_search_auto_mountpoints(remote_login_t)

term_relabel_all_ptys(remote_login_t)
term_use_all_ptys(remote_login_t)
term_setattr_all_ptys(remote_login_t)

auth_rw_login_records(remote_login_t)
auth_rw_faillog(remote_login_t)
auth_manage_pam_console_data(remote_login_t)
auth_domtrans_pam_console(remote_login_t)

corecmd_list_bin(remote_login_t)
corecmd_read_bin_symlinks(remote_login_t)
# cjp: these are probably not needed:
corecmd_read_bin_files(remote_login_t)
corecmd_read_bin_pipes(remote_login_t)
corecmd_read_bin_sockets(remote_login_t)

domain_read_all_entry_files(remote_login_t)

files_read_etc_runtime_files(remote_login_t)
files_list_home(remote_login_t)
files_list_world_readable(remote_login_t)
files_read_world_readable_files(remote_login_t)
files_read_world_readable_symlinks(remote_login_t)
files_read_world_readable_pipes(remote_login_t)
files_read_world_readable_sockets(remote_login_t)
files_list_mnt(remote_login_t)
# for when /var/mail is a sym-link
files_read_var_symlinks(remote_login_t)

auth_use_nsswitch(remote_login_t)


userdom_use_unpriv_users_fds(remote_login_t)
userdom_search_user_home_content(remote_login_t)
# Only permit unprivileged user domains to be entered via rlogin,
# since very weak authentication is used.
userdom_signal_unpriv_users(remote_login_t)
userdom_spec_domtrans_unpriv_users(remote_login_t)
userdom_use_user_ptys(remote_login_t)

userdom_manage_user_tmp_dirs(remote_login_t)
userdom_manage_user_tmp_files(remote_login_t)
userdom_tmp_filetrans_user_tmp(remote_login_t, { file dir })

userdom_home_reader(remote_login_t)

optional_policy(`
	alsa_domtrans(remote_login_t)
')

optional_policy(`
	# Search for mail spool file.
	mta_getattr_spool(remote_login_t)
')

optional_policy(`
	telnet_use_ptys(remote_login_t)
')

optional_policy(`
	unconfined_shell_domtrans(remote_login_t)
')

optional_policy(`
	usermanage_read_crack_db(remote_login_t)
')
