policy_module(mozilla, 2.8.0)

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

## <desc>
## <p>
## Allow mozilla plugin domain to connect to the network using TCP.
## </p>
## </desc>
gen_tunable(mozilla_plugin_can_network_connect, true)

## <desc>
## <p>
## Allow mozilla plugin domain to bind unreserved tcp/udp ports.
## </p>
## </desc>

gen_tunable(mozilla_plugin_bind_unreserved_ports, false)

## <desc>
## <p>
## Allow mozilla plugin to support spice protocols.
## </p>
## </desc>
gen_tunable(mozilla_plugin_use_spice, false)

## <desc>
## <p>
## Allow mozilla plugin to support GPS.
## </p>
## </desc>
gen_tunable(mozilla_plugin_use_gps, false)

## <desc>
## <p>
## Allow mozilla plugin to use Bluejeans.
## </p>
## </desc>
gen_tunable(mozilla_plugin_use_bluejeans, false)

## <desc>
## <p>
## Allow confined web browsers to read home directory content
## </p>
## </desc>
gen_tunable(mozilla_read_content, false)

attribute_role mozilla_roles;
attribute_role mozilla_plugin_roles;
attribute_role mozilla_plugin_config_roles;

roleattribute system_r mozilla_roles;
roleattribute system_r mozilla_plugin_roles;
roleattribute system_r mozilla_plugin_config_roles;

type mozilla_t;
type mozilla_exec_t;
typealias mozilla_t alias { user_mozilla_t staff_mozilla_t sysadm_mozilla_t };
typealias mozilla_t alias { auditadm_mozilla_t secadm_mozilla_t };
userdom_user_application_domain(mozilla_t, mozilla_exec_t)
role mozilla_roles types mozilla_t;

type mozilla_conf_t;
files_config_file(mozilla_conf_t)

type mozilla_home_t;
typealias mozilla_home_t alias { user_mozilla_home_t staff_mozilla_home_t sysadm_mozilla_home_t };
typealias mozilla_home_t alias { auditadm_mozilla_home_t secadm_mozilla_home_t };
userdom_user_home_content(mozilla_home_t)

type mozilla_plugin_t;
type mozilla_plugin_exec_t;
application_domain(mozilla_plugin_t, mozilla_plugin_exec_t)
role mozilla_plugin_roles types mozilla_plugin_t;

type mozilla_plugin_tmp_t;
userdom_user_tmp_content(mozilla_plugin_tmp_t)
userdom_user_tmp_file(mozilla_plugin_tmp_t)

type mozilla_plugin_tmpfs_t;
userdom_user_tmpfs_content(mozilla_plugin_tmpfs_t)
userdom_user_tmpfs_file(mozilla_plugin_tmpfs_t)

type mozilla_plugin_rw_t;
files_type(mozilla_plugin_rw_t)

type mozilla_plugin_config_t;
type mozilla_plugin_config_exec_t;
application_domain(mozilla_plugin_config_t, mozilla_plugin_config_exec_t)
role mozilla_roles types mozilla_plugin_config_t;
role mozilla_plugin_config_roles types mozilla_plugin_config_t;

type mozilla_tmp_t;
userdom_user_tmp_file(mozilla_tmp_t)

type mozilla_tmpfs_t;
typealias mozilla_tmpfs_t alias { user_mozilla_tmpfs_t staff_mozilla_tmpfs_t sysadm_mozilla_tmpfs_t };
typealias mozilla_tmpfs_t alias { auditadm_mozilla_tmpfs_t secadm_mozilla_tmpfs_t };
userdom_user_tmpfs_file(mozilla_tmpfs_t)

########################################
#
# Local policy
#

allow mozilla_t self:capability { sys_nice setgid setuid };
allow mozilla_t self:process { sigkill signal setsched getsched setrlimit };
allow mozilla_t self:fifo_file rw_fifo_file_perms;
allow mozilla_t self:shm { unix_read unix_write read write destroy create };
allow mozilla_t self:sem create_sem_perms;
allow mozilla_t self:socket create_socket_perms;
allow mozilla_t self:unix_stream_socket { listen accept };
# Browse the web, connect to printer
allow mozilla_t self:tcp_socket create_socket_perms;
allow mozilla_t self:netlink_route_socket r_netlink_socket_perms;

# for bash - old mozilla binary
can_exec(mozilla_t, mozilla_exec_t)

# X access, Home files
manage_dirs_pattern(mozilla_t, mozilla_home_t, mozilla_home_t)
manage_files_pattern(mozilla_t, mozilla_home_t, mozilla_home_t)
manage_lnk_files_pattern(mozilla_t, mozilla_home_t, mozilla_home_t)
userdom_search_user_home_dirs(mozilla_t)

# Mozpluggerrc
allow mozilla_t mozilla_conf_t:file read_file_perms;

manage_files_pattern(mozilla_t, mozilla_tmp_t, mozilla_tmp_t)
manage_dirs_pattern(mozilla_t, mozilla_tmp_t, mozilla_tmp_t)
# mozilla will manage user_tmp_t, so it will transition to it.
#files_tmp_filetrans(mozilla_t, mozilla_tmp_t, { file dir })

manage_files_pattern(mozilla_t, mozilla_tmpfs_t, mozilla_tmpfs_t)
manage_lnk_files_pattern(mozilla_t, mozilla_tmpfs_t, mozilla_tmpfs_t)
manage_fifo_files_pattern(mozilla_t, mozilla_tmpfs_t, mozilla_tmpfs_t)
manage_sock_files_pattern(mozilla_t, mozilla_tmpfs_t, mozilla_tmpfs_t)
fs_tmpfs_filetrans(mozilla_t, mozilla_tmpfs_t, { file lnk_file sock_file fifo_file })
allow mozilla_plugin_t mozilla_tmpfs_t:file map;

kernel_read_kernel_sysctls(mozilla_t)
kernel_read_network_state(mozilla_t)
# Access /proc, sysctl
kernel_read_system_state(mozilla_t)
kernel_read_net_sysctls(mozilla_t)

# Look for plugins
corecmd_list_bin(mozilla_t)
# for bash - old mozilla binary
corecmd_exec_shell(mozilla_t)
corecmd_exec_bin(mozilla_t)

# Browse the web, connect to printer
corenet_all_recvfrom_netlabel(mozilla_t)
corenet_tcp_sendrecv_generic_if(mozilla_t)
corenet_raw_sendrecv_generic_if(mozilla_t)
corenet_tcp_sendrecv_generic_node(mozilla_t)
corenet_raw_sendrecv_generic_node(mozilla_t)
corenet_tcp_sendrecv_http_port(mozilla_t)
corenet_tcp_sendrecv_http_cache_port(mozilla_t)
corenet_tcp_sendrecv_squid_port(mozilla_t)
corenet_tcp_sendrecv_ftp_port(mozilla_t)
corenet_tcp_connect_all_ephemeral_ports(mozilla_t)
corenet_tcp_sendrecv_ipp_port(mozilla_t)
corenet_tcp_connect_http_port(mozilla_t)
corenet_tcp_connect_http_cache_port(mozilla_t)
corenet_tcp_connect_squid_port(mozilla_t)
corenet_tcp_connect_ftp_port(mozilla_t)
corenet_tcp_connect_ipp_port(mozilla_t)
corenet_tcp_connect_generic_port(mozilla_t)
corenet_tcp_connect_soundd_port(mozilla_t)
corenet_sendrecv_http_client_packets(mozilla_t)
corenet_sendrecv_http_cache_client_packets(mozilla_t)
corenet_sendrecv_squid_client_packets(mozilla_t)
corenet_sendrecv_ftp_client_packets(mozilla_t)
corenet_sendrecv_ipp_client_packets(mozilla_t)
corenet_sendrecv_generic_client_packets(mozilla_t)
# Should not need other ports
corenet_dontaudit_tcp_sendrecv_generic_port(mozilla_t)
corenet_dontaudit_tcp_bind_generic_port(mozilla_t)
corenet_tcp_connect_speech_port(mozilla_t)

dev_read_urand(mozilla_t)
dev_read_rand(mozilla_t)
dev_write_sound(mozilla_t)
dev_read_sound(mozilla_t)
dev_dontaudit_rw_dri(mozilla_t)
dev_getattr_sysfs_dirs(mozilla_t)

domain_dontaudit_read_all_domains_state(mozilla_t)

files_read_etc_runtime_files(mozilla_t)
# /var/lib
files_read_var_lib_files(mozilla_t)
# interacting with gstreamer
files_read_var_files(mozilla_t)
files_read_var_symlinks(mozilla_t)
files_dontaudit_getattr_boot_dirs(mozilla_t)

fs_dontaudit_getattr_all_fs(mozilla_t)
fs_search_auto_mountpoints(mozilla_t)
fs_list_inotifyfs(mozilla_t)
fs_rw_inherited_tmpfs_files(mozilla_t)

term_dontaudit_getattr_pty_dirs(mozilla_t)

auth_use_nsswitch(mozilla_t)

logging_send_syslog_msg(mozilla_t)

miscfiles_read_fonts(mozilla_t)
miscfiles_dontaudit_setattr_fonts_dirs(mozilla_t)

userdom_use_inherited_user_ptys(mozilla_t)

#mozilla_run_plugin(mozilla_t, mozilla_roles)

xserver_user_x_domain_template(mozilla, mozilla_t, mozilla_tmpfs_t)
xserver_dontaudit_read_xdm_tmp_files(mozilla_t)
xserver_dontaudit_getattr_xdm_tmp_sockets(mozilla_t)

tunable_policy(`selinuxuser_execstack',`
	allow mozilla_t self:process execstack;
')

tunable_policy(`deny_execmem',`',`
	allow mozilla_t self:process execmem;
')

userdom_home_manager(mozilla_t)

# Uploads, local html
tunable_policy(`mozilla_read_content && use_nfs_home_dirs',`
	fs_list_auto_mountpoints(mozilla_t)
	files_list_home(mozilla_t)
	fs_read_nfs_files(mozilla_t)
	fs_read_nfs_symlinks(mozilla_t)

',`
	files_dontaudit_list_home(mozilla_t)
	fs_dontaudit_list_auto_mountpoints(mozilla_t)
	fs_dontaudit_read_nfs_files(mozilla_t)
	fs_dontaudit_list_nfs(mozilla_t)
')

tunable_policy(`mozilla_read_content && use_samba_home_dirs',`
	fs_list_auto_mountpoints(mozilla_t)
	files_list_home(mozilla_t)
	fs_read_cifs_files(mozilla_t)
	fs_read_cifs_symlinks(mozilla_t)
',`
	files_dontaudit_list_home(mozilla_t)
	fs_dontaudit_list_auto_mountpoints(mozilla_t)
	fs_dontaudit_read_cifs_files(mozilla_t)
	fs_dontaudit_list_cifs(mozilla_t)
')

tunable_policy(`mozilla_read_content',`
	userdom_list_user_tmp(mozilla_t)
	userdom_read_user_tmp_files(mozilla_t)
	userdom_read_user_tmp_symlinks(mozilla_t)
	userdom_read_user_home_content_files(mozilla_t)
	userdom_read_user_home_content_symlinks(mozilla_t)

	ifndef(`enable_mls',`
		fs_search_removable(mozilla_t)
		fs_read_removable_files(mozilla_t)
		fs_read_removable_symlinks(mozilla_t)
	')
',`
	files_dontaudit_list_tmp(mozilla_t)
	files_dontaudit_list_home(mozilla_t)
	fs_dontaudit_list_removable(mozilla_t)
	fs_dontaudit_read_removable_files(mozilla_t)
	userdom_dontaudit_list_user_tmp(mozilla_t)
	userdom_dontaudit_read_user_tmp_files(mozilla_t)
	userdom_dontaudit_list_user_home_dirs(mozilla_t)
	userdom_dontaudit_read_user_home_content_files(mozilla_t)
')

optional_policy(`
	apache_read_user_scripts(mozilla_t)
	apache_read_user_content(mozilla_t)
')

optional_policy(`
	automount_dontaudit_getattr_tmp_dirs(mozilla_t)
')

optional_policy(`
	cups_read_rw_config(mozilla_t)
	cups_dbus_chat(mozilla_t)
')

optional_policy(`
	dbus_system_bus_client(mozilla_t)
	dbus_session_bus_client(mozilla_t)

	optional_policy(`
		networkmanager_dbus_chat(mozilla_t)
	')
')

optional_policy(`
	gnome_stream_connect_gconf(mozilla_t)
	gnome_manage_config(mozilla_t)
	gnome_manage_gconf_home_files(mozilla_t)
')

optional_policy(`
	java_domtrans(mozilla_t)
')

optional_policy(`
	lpd_domtrans_lpr(mozilla_t)
')

optional_policy(`
	mplayer_domtrans(mozilla_t)
	mplayer_read_user_home_files(mozilla_t)
')

optional_policy(`
	nscd_socket_use(mozilla_t)
')

optional_policy(`
	#pulseaudio_role(mozilla_roles, mozilla_t)
	pulseaudio_exec(mozilla_t)
	pulseaudio_stream_connect(mozilla_t)
	pulseaudio_manage_home_files(mozilla_t)
')

optional_policy(`
	thunderbird_domtrans(mozilla_t)
')

########################################
#
# mozilla_plugin local policy
#

dontaudit mozilla_plugin_t self:capability { sys_ptrace sys_admin ipc_lock sys_nice sys_tty_config };
dontaudit mozilla_plugin_t self:capability2 block_suspend;
dontaudit mozilla_plugin_t self:cap_userns {sys_ptrace };
dontaudit mozilla_plugin_t self:rawip_socket create_socket_perms;


allow mozilla_plugin_t self:cap_userns {sys_admin sys_chroot};
allow mozilla_plugin_t self:process { getsession setcap setpgid getsched setsched signal_perms execmem execstack setrlimit transition };
allow mozilla_plugin_t self:netlink_route_socket r_netlink_socket_perms;
allow mozilla_plugin_t self:netlink_socket create_socket_perms;
allow mozilla_plugin_t self:tcp_socket create_stream_socket_perms;
allow mozilla_plugin_t self:udp_socket create_socket_perms;
allow mozilla_plugin_t self:netlink_kobject_uevent_socket create_socket_perms;

allow mozilla_plugin_t self:sem create_sem_perms;
allow mozilla_plugin_t self:shm create_shm_perms;
allow mozilla_plugin_t self:msgq create_msgq_perms;
allow mozilla_plugin_t self:fifo_file manage_fifo_file_perms;
allow mozilla_plugin_t self:unix_dgram_socket sendto;
allow mozilla_plugin_t self:unix_stream_socket { connectto create_stream_socket_perms };

can_exec(mozilla_plugin_t, mozilla_home_t)
manage_dirs_pattern(mozilla_plugin_t, mozilla_home_t, mozilla_home_t)
manage_files_pattern(mozilla_plugin_t, mozilla_home_t, mozilla_home_t)
manage_lnk_files_pattern(mozilla_plugin_t, mozilla_home_t, mozilla_home_t)
manage_fifo_files_pattern(mozilla_plugin_t, mozilla_home_t, mozilla_home_t)

manage_dirs_pattern(mozilla_plugin_t, mozilla_plugin_tmp_t, mozilla_plugin_tmp_t)
manage_files_pattern(mozilla_plugin_t, mozilla_plugin_tmp_t, mozilla_plugin_tmp_t)
manage_lnk_files_pattern(mozilla_plugin_t, mozilla_plugin_tmp_t, mozilla_plugin_tmp_t)
manage_fifo_files_pattern(mozilla_plugin_t, mozilla_plugin_tmp_t, mozilla_plugin_tmp_t)
manage_sock_files_pattern(mozilla_plugin_t, mozilla_plugin_tmp_t, mozilla_plugin_tmp_t)
files_tmp_filetrans(mozilla_plugin_t, mozilla_plugin_tmp_t, { dir file fifo_file sock_file lnk_file })
userdom_user_tmp_filetrans(mozilla_plugin_t, mozilla_plugin_tmp_t, { dir file fifo_file sock_file })
can_exec(mozilla_plugin_t, mozilla_plugin_tmp_t)

manage_files_pattern(mozilla_plugin_t, mozilla_plugin_tmpfs_t, mozilla_plugin_tmpfs_t)
manage_dirs_pattern(mozilla_plugin_t, mozilla_plugin_tmpfs_t, mozilla_plugin_tmpfs_t)
manage_lnk_files_pattern(mozilla_plugin_t, mozilla_plugin_tmpfs_t, mozilla_plugin_tmpfs_t)
manage_fifo_files_pattern(mozilla_plugin_t, mozilla_plugin_tmpfs_t, mozilla_plugin_tmpfs_t)
manage_sock_files_pattern(mozilla_plugin_t, mozilla_plugin_tmpfs_t, mozilla_plugin_tmpfs_t)
fs_tmpfs_filetrans(mozilla_plugin_t, mozilla_plugin_tmpfs_t, { file dir lnk_file sock_file fifo_file })
userdom_manage_home_texlive(mozilla_plugin_t)
allow mozilla_plugin_t mozilla_plugin_tmpfs_t:file map;


allow mozilla_plugin_t mozilla_plugin_rw_t:dir list_dir_perms;
read_lnk_files_pattern(mozilla_plugin_t, mozilla_plugin_rw_t, mozilla_plugin_rw_t)
read_files_pattern(mozilla_plugin_t, mozilla_plugin_rw_t, mozilla_plugin_rw_t)

can_exec(mozilla_plugin_t, mozilla_exec_t)

kernel_read_all_sysctls(mozilla_plugin_t)
kernel_read_system_state(mozilla_plugin_t)
kernel_read_network_state(mozilla_plugin_t)
kernel_request_load_module(mozilla_plugin_t)
kernel_dontaudit_getattr_core_if(mozilla_plugin_t)
files_dontaudit_read_root_files(mozilla_plugin_t)
kernel_dontaudit_list_all_proc(mozilla_plugin_t)
kernel_dontaudit_list_all_sysctls(mozilla_plugin_t)

corecmd_exec_bin(mozilla_plugin_t)
corecmd_exec_shell(mozilla_plugin_t)
corecmd_dontaudit_access_all_executables(mozilla_plugin_t)
corecmd_getattr_all_executables(mozilla_plugin_t)

corenet_tcp_bind_generic_node(mozilla_plugin_t)
corenet_tcp_connect_all_ephemeral_ports(mozilla_plugin_t)
corenet_tcp_connect_aol_port(mozilla_plugin_t)
corenet_tcp_connect_asterisk_port(mozilla_plugin_t)
corenet_tcp_connect_commplex_link_port(mozilla_plugin_t)
corenet_tcp_connect_couchdb_port(mozilla_plugin_t)
corenet_tcp_connect_flash_port(mozilla_plugin_t)
corenet_tcp_connect_ftp_port(mozilla_plugin_t)
corenet_tcp_connect_gatekeeper_port(mozilla_plugin_t)
corenet_tcp_connect_generic_port(mozilla_plugin_t)
corenet_tcp_connect_http_cache_port(mozilla_plugin_t)
corenet_tcp_connect_http_port(mozilla_plugin_t)
corenet_tcp_connect_ipp_port(mozilla_plugin_t)
corenet_tcp_connect_ipsecnat_port(mozilla_plugin_t)
corenet_tcp_connect_ircd_port(mozilla_plugin_t)
corenet_tcp_connect_jabber_client_port(mozilla_plugin_t)
corenet_tcp_connect_jboss_management_port(mozilla_plugin_t)
corenet_tcp_connect_mmcc_port(mozilla_plugin_t)
corenet_tcp_connect_monopd_port(mozilla_plugin_t)
corenet_tcp_connect_msnp_port(mozilla_plugin_t)
corenet_tcp_connect_ms_streaming_port(mozilla_plugin_t)
corenet_tcp_connect_pulseaudio_port(mozilla_plugin_t)
corenet_tcp_connect_rtsp_port(mozilla_plugin_t)
corenet_tcp_connect_soundd_port(mozilla_plugin_t)
corenet_tcp_connect_speech_port(mozilla_plugin_t)
corenet_tcp_connect_squid_port(mozilla_plugin_t)
corenet_tcp_connect_tor_port(mozilla_plugin_t)
corenet_tcp_connect_transproxy_port(mozilla_plugin_t)
corenet_tcp_connect_vnc_port(mozilla_plugin_t)
corenet_tcp_connect_whois_port(mozilla_plugin_t)
corenet_tcp_bind_generic_node(mozilla_plugin_t)
corenet_udp_bind_generic_node(mozilla_plugin_t)
corenet_tcp_bind_jboss_debug_port(mozilla_plugin_t)
corenet_dontaudit_udp_bind_ssdp_port(mozilla_plugin_t)

dev_dontaudit_append_rand(mozilla_plugin_t)
dev_read_rand(mozilla_plugin_t)
dev_read_urand(mozilla_plugin_t)
dev_read_generic_usb_dev(mozilla_plugin_t)
dev_read_video_dev(mozilla_plugin_t)
dev_write_video_dev(mozilla_plugin_t)
dev_read_realtime_clock(mozilla_plugin_t)
dev_read_sysfs(mozilla_plugin_t)
dev_read_sound(mozilla_plugin_t)
dev_write_sound(mozilla_plugin_t)
# for nvidia driver
dev_rw_xserver_misc(mozilla_plugin_t)
dev_rwx_zero(mozilla_plugin_t)
dev_dontaudit_read_mtrr(mozilla_plugin_t)
dev_map_video_dev(mozilla_plugin_t)
xserver_dri_domain(mozilla_plugin_t)

dev_dontaudit_getattr_all(mozilla_plugin_t)
dev_dontaudit_leaked_xserver_misc(mozilla_plugin_t)

domain_use_interactive_fds(mozilla_plugin_t)
domain_dontaudit_read_all_domains_state(mozilla_plugin_t)

files_read_config_files(mozilla_plugin_t)
files_list_mnt(mozilla_plugin_t)
files_exec_usr_files(mozilla_plugin_t)
fs_rw_inherited_tmpfs_files(mozilla_plugin_t)
files_dontaudit_all_access_check(mozilla_plugin_t)

fs_getattr_all_fs(mozilla_plugin_t)
fs_list_dos(mozilla_plugin_t)
fs_read_noxattr_fs_files(mozilla_plugin_t)
fs_read_hugetlbfs_files(mozilla_plugin_t)
fs_exec_hugetlbfs_files(mozilla_plugin_t)

storage_raw_read_removable_device(mozilla_plugin_t)
fs_read_removable_files(mozilla_plugin_t)
fs_read_removable_symlinks(mozilla_plugin_t)

application_exec(mozilla_plugin_t)
application_dontaudit_signull(mozilla_plugin_t)

auth_use_nsswitch(mozilla_plugin_t)

init_dontaudit_getattr_initctl(mozilla_plugin_t)
init_read_all_script_files(mozilla_plugin_t)

libs_exec_ld_so(mozilla_plugin_t)
libs_exec_lib_files(mozilla_plugin_t)
libs_legacy_use_shared_libs(mozilla_plugin_t)

logging_send_syslog_msg(mozilla_plugin_t)

miscfiles_read_fonts(mozilla_plugin_t)
miscfiles_read_generic_certs(mozilla_plugin_t)
miscfiles_dontaudit_write_generic_cert_files(mozilla_plugin_t)
miscfiles_dontaudit_setattr_fonts_dirs(mozilla_plugin_t)
miscfiles_dontaudit_setattr_fonts_cache_dirs(mozilla_plugin_t)

systemd_read_logind_sessions_files(mozilla_plugin_t)

term_getattr_all_ttys(mozilla_plugin_t)
term_getattr_all_ptys(mozilla_plugin_t)
term_getattr_ptmx(mozilla_plugin_t)
term_dontaudit_use_ptmx(mozilla_plugin_t)

userdom_dontaudit_setattr_user_tmpfs(mozilla_plugin_t)
userdom_dontaudit_use_user_terminals(mozilla_plugin_t)
userdom_manage_user_tmp_sockets(mozilla_plugin_t)
userdom_manage_user_tmp_dirs(mozilla_plugin_t)
userdom_rw_inherited_user_tmp_files(mozilla_plugin_t)
userdom_delete_user_tmp_files(mozilla_plugin_t)
userdom_rw_inherited_user_home_sock_files(mozilla_plugin_t)
userdom_manage_home_certs(mozilla_plugin_t)
userdom_read_user_tmp_symlinks(mozilla_plugin_t)
userdom_stream_connect(mozilla_plugin_t)
userdom_dontaudit_rw_user_tmp_pipes(mozilla_plugin_t)
userdom_map_user_home_files(mozilla_plugin_t)

userdom_read_user_home_content_files(mozilla_plugin_t)
userdom_read_user_home_content_symlinks(mozilla_plugin_t)
userdom_read_home_certs(mozilla_plugin_t)
userdom_read_home_audio_files(mozilla_plugin_t)
userdom_exec_user_tmp_files(mozilla_plugin_t)

userdom_home_manager(mozilla_plugin_t)

tunable_policy(`mozilla_plugin_can_network_connect',`
	corenet_tcp_connect_all_ports(mozilla_plugin_t)
')

optional_policy(`
    abrt_stream_connect(mozilla_plugin_t)
')

optional_policy(`
	alsa_read_rw_config(mozilla_plugin_t)
	alsa_read_rw_config(mozilla_plugin_config_t)
	alsa_read_home_files(mozilla_plugin_t)
')

optional_policy(`
	apache_list_modules(mozilla_plugin_t)
')

optional_policy(`
	bluetooth_stream_connect(mozilla_plugin_t)
')

optional_policy(`
	bumblebee_stream_connect(mozilla_plugin_t)
')

optional_policy(`
	cups_stream_connect(mozilla_plugin_t)
')

optional_policy(`
	dbus_system_bus_client(mozilla_plugin_t)
	dbus_session_bus_client(mozilla_plugin_t)
	dbus_connect_session_bus(mozilla_plugin_t)
	dbus_read_lib_files(mozilla_plugin_t)
')

optional_policy(`
    devicekit_dbus_chat_disk(mozilla_plugin_t)
')

optional_policy(`
	gnome_manage_config(mozilla_plugin_t)
	gnome_read_usr_config(mozilla_plugin_t)
	gnome_filetrans_home_content(mozilla_plugin_t)
	gnome_exec_gstreamer_home_files(mozilla_plugin_t)
')

optional_policy(`
	gpm_dontaudit_getattr_gpmctl(mozilla_plugin_t)
')

optional_policy(`
	java_exec(mozilla_plugin_t)
')

optional_policy(`
    mplayer_exec(mozilla_plugin_t)
    mplayer_manage_generic_home_content(mozilla_plugin_t)
    mplayer_home_filetrans_mplayer_home(mozilla_plugin_t, dir, ".mplayer")
')

optional_policy(`
	pulseaudio_exec(mozilla_plugin_t)
	pulseaudio_stream_connect(mozilla_plugin_t)
	pulseaudio_setattr_home_dir(mozilla_plugin_t)
	pulseaudio_manage_home_dirs(mozilla_plugin_t)
	pulseaudio_manage_home_files(mozilla_plugin_t)
	pulseaudio_manage_home_symlinks(mozilla_plugin_t)
')

optional_policy(`
	pcscd_stream_connect(mozilla_plugin_t)
')

optional_policy(`
	policykit_dbus_chat(mozilla_plugin_t)
')

optional_policy(`
	rtkit_scheduled(mozilla_plugin_t)
')

optional_policy(`
	udev_read_db(mozilla_plugin_t)
')

optional_policy(`
	xserver_xdm_tmp_filetrans(mozilla_plugin_t, mozilla_plugin_tmp_t, { dir file fifo_file sock_file })
	xserver_dontaudit_read_xdm_tmp_files(mozilla_plugin_t)
	xserver_read_xdm_pid(mozilla_plugin_t)
	xserver_stream_connect(mozilla_plugin_t)
	xserver_use_user_fonts(mozilla_plugin_t)
	xserver_read_user_iceauth(mozilla_plugin_t)
	xserver_read_user_xauth(mozilla_plugin_t)
	xserver_append_xdm_home_files(mozilla_plugin_t)
	xserver_dontaudit_xdm_tmp_dirs(mozilla_plugin_t)
	xserver_dontaudit_xdm_rw_stream_sockets(mozilla_plugin_t)
	xserver_filetrans_fonts_cache_home_content(mozilla_plugin_t)
')

########################################
#
# mozilla_plugin_config local policy
#

allow mozilla_plugin_config_t self:capability {  dac_read_search sys_nice setuid setgid };
allow mozilla_plugin_config_t self:process { setsched signal_perms getsched execmem execstack };

allow mozilla_plugin_config_t self:fifo_file rw_file_perms;
allow mozilla_plugin_config_t self:unix_stream_socket create_stream_socket_perms;

ps_process_pattern(mozilla_plugin_config_t,mozilla_plugin_t)

dev_read_sysfs(mozilla_plugin_config_t)
dev_read_urand(mozilla_plugin_config_t)
dev_dontaudit_read_rand(mozilla_plugin_config_t)
dev_dontaudit_rw_dri(mozilla_plugin_config_t)

fs_search_auto_mountpoints(mozilla_plugin_config_t)
fs_list_inotifyfs(mozilla_plugin_config_t)

can_exec(mozilla_plugin_config_t, mozilla_plugin_rw_t)
manage_dirs_pattern(mozilla_plugin_config_t, mozilla_plugin_rw_t, mozilla_plugin_rw_t)
manage_files_pattern(mozilla_plugin_config_t, mozilla_plugin_rw_t, mozilla_plugin_rw_t)
manage_lnk_files_pattern(mozilla_plugin_config_t, mozilla_plugin_rw_t, mozilla_plugin_rw_t)

manage_dirs_pattern(mozilla_plugin_config_t, mozilla_home_t, mozilla_home_t)
manage_files_pattern(mozilla_plugin_config_t, mozilla_home_t, mozilla_home_t)
manage_lnk_files_pattern(mozilla_plugin_config_t, mozilla_home_t, mozilla_home_t)
manage_fifo_files_pattern(mozilla_plugin_config_t, mozilla_home_t, mozilla_home_t)
mozilla_filetrans_home_content(mozilla_plugin_t)

manage_dirs_pattern(mozilla_plugin_config_t, mozilla_plugin_tmp_t, mozilla_plugin_tmp_t)
manage_files_pattern(mozilla_plugin_config_t, mozilla_plugin_tmp_t, mozilla_plugin_tmp_t)
manage_lnk_files_pattern(mozilla_plugin_config_t, mozilla_plugin_tmp_t, mozilla_plugin_tmp_t)
files_tmp_filetrans(mozilla_plugin_config_t, mozilla_plugin_tmp_t, { dir file fifo_file sock_file lnk_file })
userdom_user_tmp_filetrans(mozilla_plugin_config_t, mozilla_plugin_tmp_t, { dir file })
mozilla_filetrans_home_content(mozilla_plugin_config_t)
dontaudit mozilla_plugin_t mozilla_plugin_tmp_t:file relabelfrom;

corecmd_exec_bin(mozilla_plugin_config_t)
corecmd_exec_shell(mozilla_plugin_config_t)

kernel_read_system_state(mozilla_plugin_config_t)
kernel_request_load_module(mozilla_plugin_config_t)

domain_use_interactive_fds(mozilla_plugin_config_t)

files_dontaudit_search_home(mozilla_plugin_config_t)
files_list_tmp(mozilla_plugin_config_t)

fs_getattr_all_fs(mozilla_plugin_config_t)

term_dontaudit_use_ptmx(mozilla_plugin_config_t)

auth_use_nsswitch(mozilla_plugin_config_t)

miscfiles_read_fonts(mozilla_plugin_config_t)

userdom_search_user_home_content(mozilla_plugin_config_t)
userdom_read_user_home_content_symlinks(mozilla_plugin_config_t)
userdom_read_user_home_content_files(mozilla_plugin_config_t)
userdom_dontaudit_search_admin_dir(mozilla_plugin_config_t)
userdom_use_inherited_user_ptys(mozilla_plugin_config_t)
userdom_dontaudit_use_user_terminals(mozilla_plugin_config_t)
userdom_dontaudit_rw_user_tmp_pipes(mozilla_plugin_config_t)
userdom_dontaudit_write_all_user_home_content_files(mozilla_plugin_config_t)
userdom_dontaudit_write_all_user_tmp_content_files(mozilla_plugin_config_t)

domtrans_pattern(mozilla_plugin_config_t, mozilla_plugin_exec_t, mozilla_plugin_t)

tunable_policy(`use_ecryptfs_home_dirs',`
        fs_read_ecryptfs_files(mozilla_plugin_config_t)
')

optional_policy(`
	gnome_dontaudit_rw_inherited_config(mozilla_plugin_config_t)
')

optional_policy(`
	xserver_use_user_fonts(mozilla_plugin_config_t)
')

ifdef(`distro_redhat',`
	typealias mozilla_plugin_t  alias nsplugin_t;
	typealias mozilla_plugin_exec_t  alias nsplugin_exec_t;
	typealias mozilla_plugin_rw_t alias nsplugin_rw_t;
	typealias mozilla_plugin_tmp_t  alias nsplugin_tmp_t;
	typealias mozilla_home_t alias nsplugin_home_t;
	typealias mozilla_plugin_config_t  alias nsplugin_config_t;
	typealias mozilla_plugin_config_exec_t  alias nsplugin_config_exec_t;
')

#tunable_policy(`mozilla_plugin_enable_homedirs',`
#	userdom_user_home_dir_filetrans(mozilla_plugin_t, mozilla_home_t, { dir file })
#', `

	#userdom_user_home_dir_filetrans_pattern(mozilla_plugin_t, file)
  	#userdom_user_home_dir_filetrans_pattern(mozilla_plugin_t, dir)
#')

tunable_policy(`selinuxuser_execmod',`
	userdom_execmod_user_home_files(mozilla_plugin_t)
')

tunable_policy(`mozilla_plugin_use_spice',`
	dev_rw_generic_usb_dev(mozilla_plugin_t)
	dev_setattr_generic_usb_dev(mozilla_plugin_t)
	corenet_tcp_bind_vnc_port(mozilla_plugin_t)
')

tunable_policy(`mozilla_plugin_use_gps',`
    fs_manage_dos_dirs(mozilla_plugin_t)
    fs_manage_dos_files(mozilla_plugin_t)
')

tunable_policy(`mozilla_plugin_use_bluejeans',`
    corenet_tcp_bind_unreserved_ports(mozilla_plugin_t)
    corenet_dontaudit_tcp_bind_all_defined_ports(mozilla_plugin_t)
    corenet_tcp_connect_commplex_main_port(mozilla_plugin_t)
    corenet_dontaudit_udp_bind_all_ports(mozilla_plugin_t)
    corenet_udp_bind_all_unreserved_ports(mozilla_plugin_t)
')

tunable_policy(`mozilla_plugin_bind_unreserved_ports',`
    corenet_tcp_bind_unreserved_ports(mozilla_plugin_t)
    corenet_udp_bind_all_unreserved_ports(mozilla_plugin_t)
')
