Dan Walsh 3eaa99
policy_module(nsplugin, 1.0.0)
Dan Walsh 3eaa99
Dan Walsh 3eaa99
########################################
Dan Walsh 3eaa99
#
Dan Walsh 3eaa99
# Declarations
Dan Walsh 3eaa99
#
Dan Walsh 3eaa99
Dan Walsh 3eaa99
## <desc>
Dan Walsh 3eaa99
## 

Dan Walsh 3eaa99
## Allow nsplugin code to execmem/execstack
Dan Walsh 3eaa99
## 

Dan Walsh 3eaa99
## </desc>
Dan Walsh 3eaa99
gen_tunable(allow_nsplugin_execmem, false)
Dan Walsh 3eaa99
Dan Walsh 3eaa99
## <desc>
Dan Walsh 3eaa99
## 

Dan Walsh 3eaa99
## Allow nsplugin code to connect to unreserved ports
Dan Walsh 3eaa99
## 

Dan Walsh 3eaa99
## </desc>
Dan Walsh 3eaa99
gen_tunable(nsplugin_can_network, true)
Dan Walsh 3eaa99
Dan Walsh 3eaa99
type nsplugin_exec_t;
Dan Walsh 3eaa99
application_executable_file(nsplugin_exec_t)
Dan Walsh 3eaa99
Dan Walsh 3eaa99
type nsplugin_config_exec_t;
Dan Walsh 3eaa99
application_executable_file(nsplugin_config_exec_t)
Dan Walsh 3eaa99
Dan Walsh 3eaa99
type nsplugin_rw_t;
Dan Walsh 3eaa99
files_poly_member(nsplugin_rw_t)
Dan Walsh 3eaa99
files_type(nsplugin_rw_t)
Dan Walsh 3eaa99
Dan Walsh 3eaa99
type nsplugin_tmp_t;
Dan Walsh 3eaa99
files_tmp_file(nsplugin_tmp_t)
Dan Walsh 3eaa99
Dan Walsh 3eaa99
type nsplugin_home_t;
Dan Walsh 3eaa99
files_poly_member(nsplugin_home_t)
Dan Walsh 3eaa99
userdom_user_home_content(nsplugin_home_t)
Dan Walsh 3eaa99
typealias nsplugin_home_t alias user_nsplugin_home_t;
Dan Walsh 3eaa99
Dan Walsh 3eaa99
type nsplugin_t;
Dan Walsh 3eaa99
domain_type(nsplugin_t)
Dan Walsh 3eaa99
domain_entry_file(nsplugin_t, nsplugin_exec_t)
Dan Walsh 3eaa99
Dan Walsh 3eaa99
type nsplugin_config_t;
Dan Walsh 3eaa99
domain_type(nsplugin_config_t)
Dan Walsh 3eaa99
domain_entry_file(nsplugin_config_t, nsplugin_config_exec_t)
Dan Walsh 3eaa99
Dan Walsh 3eaa99
application_executable_file(nsplugin_exec_t)
Dan Walsh 3eaa99
application_executable_file(nsplugin_config_exec_t)
Dan Walsh 3eaa99
Dan Walsh 3eaa99
Dan Walsh 3eaa99
########################################
Dan Walsh 3eaa99
#
Dan Walsh 3eaa99
# nsplugin local policy
Dan Walsh 3eaa99
#
Dan Walsh 3eaa99
dontaudit nsplugin_t self:capability { sys_nice sys_tty_config };
Dan Walsh 3eaa99
allow nsplugin_t self:fifo_file rw_file_perms;
Dan Walsh 3eaa99
allow nsplugin_t self:process { ptrace setpgid getsched setsched signal_perms };
Dan Walsh 3eaa99
Dan Walsh 3eaa99
allow nsplugin_t self:sem create_sem_perms;
Dan Walsh 3eaa99
allow nsplugin_t self:shm create_shm_perms;
Dan Walsh 3eaa99
allow nsplugin_t self:msgq create_msgq_perms;
Dan Walsh 3eaa99
allow nsplugin_t self:unix_stream_socket { connectto create_stream_socket_perms };
Dan Walsh 3eaa99
allow nsplugin_t self:unix_dgram_socket create_socket_perms;
Dan Walsh 3eaa99
allow nsplugin_t nsplugin_rw_t:dir search_dir_perms;
Dan Walsh 3eaa99
Dan Walsh 3eaa99
tunable_policy(`allow_nsplugin_execmem',`
Dan Walsh 3eaa99
	allow nsplugin_t self:process { execstack execmem };
Dan Walsh 3eaa99
	allow nsplugin_config_t self:process { execstack execmem };
Dan Walsh 3eaa99
')
Dan Walsh 3eaa99
	
Dan Walsh 3eaa99
tunable_policy(`nsplugin_can_network',`
Dan Walsh 3eaa99
	corenet_tcp_connect_all_unreserved_ports(nsplugin_t)
Dan Walsh 3eaa99
')
Dan Walsh 3eaa99
Dan Walsh 3eaa99
manage_dirs_pattern(nsplugin_t, nsplugin_home_t, nsplugin_home_t)
Dan Walsh 3eaa99
exec_files_pattern(nsplugin_t, nsplugin_home_t, nsplugin_home_t)
Dan Walsh 3eaa99
manage_files_pattern(nsplugin_t, nsplugin_home_t, nsplugin_home_t)
Dan Walsh 3eaa99
manage_fifo_files_pattern(nsplugin_t, nsplugin_home_t, nsplugin_home_t)
Dan Walsh 3eaa99
manage_sock_files_pattern(nsplugin_t, nsplugin_home_t, nsplugin_home_t)
Dan Walsh 3eaa99
manage_lnk_files_pattern(nsplugin_t, nsplugin_home_t, nsplugin_home_t)
Dan Walsh 3eaa99
userdom_user_home_dir_filetrans(nsplugin_t, nsplugin_home_t, {file dir})
Dan Walsh 3eaa99
userdom_user_home_content_filetrans(nsplugin_t, nsplugin_home_t, {file dir})
Dan Walsh 3eaa99
userdom_dontaudit_getattr_user_home_content(nsplugin_t)
Dan Walsh 3eaa99
userdom_dontaudit_search_user_bin_dirs(nsplugin_t)
Dan Walsh 3eaa99
userdom_dontaudit_write_user_home_content_files(nsplugin_t)
Dan Walsh 3eaa99
userdom_dontaudit_search_admin_dir(nsplugin_t)
Dan Walsh 3eaa99
Dan Walsh 3eaa99
corecmd_exec_bin(nsplugin_t)
Dan Walsh 3eaa99
corecmd_exec_shell(nsplugin_t)
Dan Walsh 3eaa99
Dan Walsh 3eaa99
corenet_all_recvfrom_unlabeled(nsplugin_t)
Dan Walsh 3eaa99
corenet_all_recvfrom_netlabel(nsplugin_t)
Dan Walsh 3eaa99
corenet_tcp_connect_flash_port(nsplugin_t)
Dan Walsh 3eaa99
corenet_tcp_connect_streaming_port(nsplugin_t)
Dan Walsh 3eaa99
corenet_tcp_connect_pulseaudio_port(nsplugin_t)
Dan Walsh 3eaa99
corenet_tcp_connect_http_port(nsplugin_t)
Dan Walsh 3eaa99
corenet_tcp_connect_http_cache_port(nsplugin_t)
Dan Walsh 3eaa99
corenet_tcp_connect_squid_port(nsplugin_t)
Dan Walsh 3eaa99
corenet_tcp_sendrecv_generic_if(nsplugin_t)
Dan Walsh 3eaa99
corenet_tcp_sendrecv_generic_node(nsplugin_t)
Dan Walsh 3eaa99
corenet_tcp_connect_ipp_port(nsplugin_t)
Dan Walsh 3eaa99
corenet_tcp_connect_speech_port(nsplugin_t)
Dan Walsh 3eaa99
Dan Walsh 3eaa99
domain_dontaudit_read_all_domains_state(nsplugin_t)
Dan Walsh 3eaa99
Dan Walsh 3eaa99
dev_read_rand(nsplugin_t)
Dan Walsh 3eaa99
dev_read_sound(nsplugin_t)
Dan Walsh 3eaa99
dev_write_sound(nsplugin_t)
Dan Walsh 3eaa99
dev_read_video_dev(nsplugin_t)
Dan Walsh 3eaa99
dev_write_video_dev(nsplugin_t)
Dan Walsh 3eaa99
dev_getattr_dri_dev(nsplugin_t)
Dan Walsh 3eaa99
dev_rwx_zero(nsplugin_t)
Dan Walsh 3eaa99
dev_search_sysfs(nsplugin_t)
Dan Walsh 3eaa99
Dan Walsh 3eaa99
kernel_read_kernel_sysctls(nsplugin_t)
Dan Walsh 3eaa99
kernel_read_system_state(nsplugin_t)
Dan Walsh 3eaa99
Dan Walsh 3eaa99
files_dontaudit_getattr_lost_found_dirs(nsplugin_t)
Dan Walsh 3eaa99
files_dontaudit_list_home(nsplugin_t)
Dan Walsh 3eaa99
files_read_etc_files(nsplugin_t)
Dan Walsh 3eaa99
files_read_usr_files(nsplugin_t)
Dan Walsh 3eaa99
files_read_config_files(nsplugin_t)
Dan Walsh 3eaa99
Dan Walsh 3eaa99
fs_getattr_tmpfs(nsplugin_t)
Dan Walsh 3eaa99
fs_getattr_xattr_fs(nsplugin_t)
Dan Walsh 3eaa99
fs_search_auto_mountpoints(nsplugin_t)
Dan Walsh 3eaa99
fs_rw_anon_inodefs_files(nsplugin_t)
Dan Walsh 3eaa99
fs_list_inotifyfs(nsplugin_t)
Dan Walsh 3eaa99
Dan Walsh 3eaa99
storage_dontaudit_getattr_fixed_disk_dev(nsplugin_t)
Dan Walsh 3eaa99
Dan Walsh 3eaa99
term_dontaudit_getattr_all_ptys(nsplugin_t)
Dan Walsh 3eaa99
term_dontaudit_getattr_all_ttys(nsplugin_t)
Dan Walsh 3eaa99
Dan Walsh 3eaa99
auth_use_nsswitch(nsplugin_t)
Dan Walsh 3eaa99
Dan Walsh 3eaa99
libs_exec_ld_so(nsplugin_t)
Dan Walsh 3eaa99
Dan Walsh 3eaa99
miscfiles_read_localization(nsplugin_t)
Dan Walsh 3eaa99
miscfiles_read_fonts(nsplugin_t)
Dan Walsh 3eaa99
miscfiles_dontaudit_write_fonts(nsplugin_t)
Dan Walsh 3eaa99
miscfiles_setattr_fonts_cache_dirs(nsplugin_t)
Dan Walsh 3eaa99
Dan Walsh 3eaa99
userdom_manage_user_tmp_dirs(nsplugin_t)
Dan Walsh 3eaa99
userdom_manage_user_tmp_files(nsplugin_t)
Dan Walsh 3eaa99
userdom_manage_user_tmp_sockets(nsplugin_t)
Dan Walsh 3eaa99
userdom_tmp_filetrans_user_tmp(nsplugin_t, { file dir sock_file })
Dan Walsh 3eaa99
userdom_rw_semaphores(nsplugin_t)
Dan Walsh 3eaa99
userdom_dontaudit_rw_user_tmp_pipes(nsplugin_t)
Dan Walsh 3eaa99
Dan Walsh 3eaa99
userdom_read_user_home_content_symlinks(nsplugin_t)
Dan Walsh 3eaa99
userdom_read_user_home_content_files(nsplugin_t)
Dan Walsh 3eaa99
userdom_read_user_tmp_files(nsplugin_t)
Dan Walsh 3eaa99
userdom_write_user_tmp_sockets(nsplugin_t)
Dan Walsh 3eaa99
userdom_dontaudit_append_user_home_content_files(nsplugin_t)
Dan Walsh 3eaa99
Dan Walsh 3eaa99
optional_policy(`
Dan Walsh 3eaa99
	alsa_read_rw_config(nsplugin_t)
Dan Walsh 3eaa99
	alsa_read_home_files(nsplugin_t)
Dan Walsh 3eaa99
')
Dan Walsh 3eaa99
Dan Walsh 3eaa99
optional_policy(`
Dan Walsh 3eaa99
	cups_stream_connect(nsplugin_t)
Dan Walsh 3eaa99
')
Dan Walsh 3eaa99
Dan Walsh 3eaa99
optional_policy(`
Dan Walsh 3eaa99
	dbus_session_bus_client(nsplugin_t)
Dan Walsh 3eaa99
	dbus_connect_session_bus(nsplugin_t)
Dan Walsh 3eaa99
	dbus_system_bus_client(nsplugin_t)
Dan Walsh 3eaa99
')
Dan Walsh 3eaa99
Dan Walsh 3eaa99
optional_policy(`
Dan Walsh 3eaa99
	gnome_exec_gconf(nsplugin_t)
Dan Walsh 3eaa99
	gnome_manage_config(nsplugin_t)
Dan Walsh 3eaa99
	gnome_read_gconf_home_files(nsplugin_t)
Dan Walsh 3eaa99
')
Dan Walsh 3eaa99
Dan Walsh 3eaa99
optional_policy(`
Dan Walsh 3eaa99
	mozilla_read_user_home_files(nsplugin_t)
Dan Walsh 3eaa99
	mozilla_write_user_home_files(nsplugin_t)
Dan Walsh 3eaa99
')
Dan Walsh 3eaa99
Dan Walsh 3eaa99
optional_policy(`
Dan Walsh 3eaa99
	mplayer_exec(nsplugin_t)
Dan Walsh 3eaa99
	mplayer_read_user_home_files(nsplugin_t)
Dan Walsh 3eaa99
')
Dan Walsh 3eaa99
Dan Walsh 3eaa99
optional_policy(`
Dan Walsh 3eaa99
	unconfined_execmem_signull(nsplugin_t)
Dan Walsh 3eaa99
')
Dan Walsh 3eaa99
Dan Walsh 3eaa99
optional_policy(`
Dan Walsh 3eaa99
	sandbox_read_tmpfs_files(nsplugin_t)
Dan Walsh 3eaa99
')
Dan Walsh 3eaa99
Dan Walsh 3eaa99
optional_policy(`
Dan Walsh 3eaa99
	gen_require(`
Dan Walsh 3eaa99
		type user_tmpfs_t;
Dan Walsh 3eaa99
	')
Dan Walsh 3eaa99
	xserver_user_x_domain_template(nsplugin, nsplugin_t, user_tmpfs_t)
Dan Walsh 3eaa99
	xserver_rw_shm(nsplugin_t)
Dan Walsh 3eaa99
	xserver_read_xdm_pid(nsplugin_t)
Dan Walsh 3eaa99
	xserver_read_xdm_tmp_files(nsplugin_t)
Dan Walsh 3eaa99
	xserver_read_user_xauth(nsplugin_t)
Dan Walsh 3eaa99
	xserver_read_user_iceauth(nsplugin_t)
Dan Walsh 3eaa99
	xserver_use_user_fonts(nsplugin_t)
Dan Walsh 3eaa99
	xserver_rw_inherited_user_fonts(nsplugin_t)
Dan Walsh 3eaa99
')
Dan Walsh 3eaa99
Dan Walsh 3eaa99
########################################
Dan Walsh 3eaa99
#
Dan Walsh 3eaa99
# nsplugin_config local policy
Dan Walsh 3eaa99
#
Dan Walsh 3eaa99
Dan Walsh 3eaa99
allow nsplugin_config_t self:capability { dac_override dac_read_search sys_nice setuid setgid };
Dan Walsh 3eaa99
allow nsplugin_config_t self:process { setsched signal_perms getsched execmem };
Dan Walsh 3eaa99
#execing pulseaudio
Dan Walsh 3eaa99
dontaudit nsplugin_t self:process { getcap setcap };
Dan Walsh 3eaa99
Dan Walsh 3eaa99
allow nsplugin_config_t self:fifo_file rw_file_perms;
Dan Walsh 3eaa99
allow nsplugin_config_t self:unix_stream_socket create_stream_socket_perms;
Dan Walsh 3eaa99
Dan Walsh 3eaa99
dev_dontaudit_read_rand(nsplugin_config_t)
Dan Walsh 3eaa99
Dan Walsh 3eaa99
fs_search_auto_mountpoints(nsplugin_config_t)
Dan Walsh 3eaa99
fs_list_inotifyfs(nsplugin_config_t)
Dan Walsh 3eaa99
Dan Walsh 3eaa99
can_exec(nsplugin_config_t, nsplugin_rw_t)
Dan Walsh 3eaa99
manage_dirs_pattern(nsplugin_config_t, nsplugin_rw_t, nsplugin_rw_t)
Dan Walsh 3eaa99
manage_files_pattern(nsplugin_config_t, nsplugin_rw_t, nsplugin_rw_t)
Dan Walsh 3eaa99
manage_lnk_files_pattern(nsplugin_config_t, nsplugin_rw_t, nsplugin_rw_t)
Dan Walsh 3eaa99
Dan Walsh 3eaa99
manage_dirs_pattern(nsplugin_config_t, nsplugin_home_t, nsplugin_home_t)
Dan Walsh 3eaa99
manage_files_pattern(nsplugin_config_t, nsplugin_home_t, nsplugin_home_t)
Dan Walsh 3eaa99
manage_lnk_files_pattern(nsplugin_config_t, nsplugin_home_t, nsplugin_home_t)
Dan Walsh 3eaa99
Dan Walsh 3eaa99
corecmd_exec_bin(nsplugin_config_t)
Dan Walsh 3eaa99
corecmd_exec_shell(nsplugin_config_t)
Dan Walsh 3eaa99
Dan Walsh 3eaa99
kernel_read_system_state(nsplugin_config_t)
Dan Walsh 3eaa99
Dan Walsh 3eaa99
files_read_etc_files(nsplugin_config_t)
Dan Walsh 3eaa99
files_read_usr_files(nsplugin_config_t)
Dan Walsh 3eaa99
files_dontaudit_search_home(nsplugin_config_t)
Dan Walsh 3eaa99
files_list_tmp(nsplugin_config_t)
Dan Walsh 3eaa99
Dan Walsh 3eaa99
auth_use_nsswitch(nsplugin_config_t)
Dan Walsh 3eaa99
Dan Walsh 3eaa99
miscfiles_read_localization(nsplugin_config_t)
Dan Walsh 3eaa99
miscfiles_read_fonts(nsplugin_config_t)
Dan Walsh 3eaa99
Dan Walsh 3eaa99
userdom_search_user_home_content(nsplugin_config_t)
Dan Walsh 3eaa99
userdom_read_user_home_content_symlinks(nsplugin_config_t)
Dan Walsh 3eaa99
userdom_read_user_home_content_files(nsplugin_config_t)
Dan Walsh 3eaa99
userdom_dontaudit_search_admin_dir(nsplugin_config_t)
Dan Walsh 3eaa99
Dan Walsh 3eaa99
tunable_policy(`use_nfs_home_dirs',`
Dan Walsh 3eaa99
	fs_getattr_nfs(nsplugin_t)
Dan Walsh 3eaa99
	fs_manage_nfs_dirs(nsplugin_t)
Dan Walsh 3eaa99
	fs_manage_nfs_files(nsplugin_t)
Dan Walsh 3eaa99
	fs_read_nfs_symlinks(nsplugin_t)
Dan Walsh 3eaa99
	fs_manage_nfs_named_pipes(nsplugin_t)
Dan Walsh 3eaa99
	fs_manage_nfs_dirs(nsplugin_config_t)
Dan Walsh 3eaa99
	fs_manage_nfs_files(nsplugin_config_t)
Dan Walsh 3eaa99
	fs_manage_nfs_named_pipes(nsplugin_config_t)
Dan Walsh 3eaa99
	fs_read_nfs_symlinks(nsplugin_config_t)
Dan Walsh 3eaa99
')
Dan Walsh 3eaa99
Dan Walsh 3eaa99
tunable_policy(`use_samba_home_dirs',`
Dan Walsh 3eaa99
	fs_getattr_cifs(nsplugin_t)
Dan Walsh 3eaa99
	fs_manage_cifs_dirs(nsplugin_t)
Dan Walsh 3eaa99
	fs_manage_cifs_files(nsplugin_t)
Dan Walsh 3eaa99
	fs_read_cifs_symlinks(nsplugin_t)
Dan Walsh 3eaa99
	fs_manage_cifs_named_pipes(nsplugin_t)
Dan Walsh 3eaa99
	fs_manage_cifs_dirs(nsplugin_config_t)
Dan Walsh 3eaa99
	fs_manage_cifs_files(nsplugin_config_t)
Dan Walsh 3eaa99
	fs_manage_cifs_named_pipes(nsplugin_config_t)
Dan Walsh 3eaa99
	fs_read_cifs_symlinks(nsplugin_config_t)
Dan Walsh 3eaa99
')
Dan Walsh 3eaa99
Dan Walsh 3eaa99
domtrans_pattern(nsplugin_config_t, nsplugin_exec_t, nsplugin_t)
Dan Walsh 3eaa99
Dan Walsh 3eaa99
optional_policy(`
Dan Walsh 3eaa99
	xserver_use_user_fonts(nsplugin_config_t)
Dan Walsh 3eaa99
')
Dan Walsh 3eaa99
Dan Walsh 3eaa99
optional_policy(`
Dan Walsh 3eaa99
	mozilla_read_user_home_files(nsplugin_config_t)
Dan Walsh 3eaa99
	mozilla_write_user_home_files(nsplugin_config_t)
Dan Walsh 3eaa99
')
Dan Walsh 3eaa99
Dan Walsh 3eaa99
application_signull(nsplugin_t)
Dan Walsh 3eaa99
Dan Walsh 3eaa99
optional_policy(`
Dan Walsh 3eaa99
	pulseaudio_exec(nsplugin_t)
Dan Walsh 3eaa99
	pulseaudio_stream_connect(nsplugin_t)
Dan Walsh 3eaa99
	pulseaudio_manage_home_files(nsplugin_t)
Dan Walsh 3eaa99
	pulseaudio_setattr_home_dir(nsplugin_t)
Dan Walsh 3eaa99
')
Dan Walsh 3eaa99
Dan Walsh 3eaa99
optional_policy(`
Dan Walsh 3eaa99
	unconfined_execmem_exec(nsplugin_t)
Dan Walsh 3eaa99
')
Dan Walsh 3eaa99
Dan Walsh 3eaa99