policy_module(thunderbird)

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

attribute_role thunderbird_roles;

type thunderbird_t;
type thunderbird_exec_t;
userdom_user_application_domain(thunderbird_t, thunderbird_exec_t)
role thunderbird_roles types thunderbird_t;

type thunderbird_home_t;
userdom_user_home_content(thunderbird_home_t)

type thunderbird_tmp_t;
userdom_user_tmp_file(thunderbird_tmp_t)

type thunderbird_tmpfs_t;
userdom_user_tmpfs_file(thunderbird_tmpfs_t)

type thunderbird_xdg_cache_t;
xdg_cache_content(thunderbird_xdg_cache_t)

optional_policy(`
	wm_application_domain(thunderbird_t, thunderbird_exec_t)
')

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

allow thunderbird_t self:capability sys_nice;
allow thunderbird_t self:process { execheap execmem execstack getsched setsched signal_perms };
allow thunderbird_t self:fifo_file rw_fifo_file_perms;
allow thunderbird_t self:unix_dgram_socket create_socket_perms;
allow thunderbird_t self:unix_stream_socket create_stream_socket_perms;
allow thunderbird_t self:shm create_shm_perms;

manage_dirs_pattern(thunderbird_t, thunderbird_home_t, thunderbird_home_t)
manage_files_pattern(thunderbird_t, thunderbird_home_t, thunderbird_home_t)
manage_lnk_files_pattern(thunderbird_t, thunderbird_home_t, thunderbird_home_t)
userdom_user_home_dir_filetrans(thunderbird_t, thunderbird_home_t, dir, ".thunderbird")

manage_dirs_pattern(thunderbird_t, thunderbird_tmp_t, thunderbird_tmp_t)
manage_files_pattern(thunderbird_t, thunderbird_tmp_t, thunderbird_tmp_t)
manage_lnk_files_pattern(thunderbird_t, thunderbird_tmp_t, thunderbird_tmp_t)
files_tmp_filetrans(thunderbird_t, thunderbird_tmp_t, { dir file lnk_file })

manage_files_pattern(thunderbird_t, thunderbird_tmpfs_t, thunderbird_tmpfs_t)
manage_lnk_files_pattern(thunderbird_t, thunderbird_tmpfs_t, thunderbird_tmpfs_t)
manage_fifo_files_pattern(thunderbird_t, thunderbird_tmpfs_t, thunderbird_tmpfs_t)
manage_sock_files_pattern(thunderbird_t, thunderbird_tmpfs_t, thunderbird_tmpfs_t)
fs_tmpfs_filetrans(thunderbird_t, thunderbird_tmpfs_t,{ dir file lnk_file sock_file fifo_file })

manage_files_pattern(thunderbird_t, thunderbird_xdg_cache_t, thunderbird_xdg_cache_t)
manage_dirs_pattern(thunderbird_t, thunderbird_xdg_cache_t, thunderbird_xdg_cache_t)
xdg_cache_filetrans(thunderbird_t, thunderbird_xdg_cache_t, dir, "thunderbird")

kernel_read_network_state(thunderbird_t)
kernel_read_net_sysctls(thunderbird_t)
kernel_read_system_state(thunderbird_t)

corecmd_exec_shell(thunderbird_t)

corenet_all_recvfrom_netlabel(thunderbird_t)
corenet_tcp_sendrecv_generic_if(thunderbird_t)
corenet_tcp_sendrecv_generic_node(thunderbird_t)

corenet_sendrecv_ipp_client_packets(thunderbird_t)
corenet_tcp_connect_ipp_port(thunderbird_t)

corenet_sendrecv_innd_client_packets(thunderbird_t)
corenet_tcp_connect_innd_port(thunderbird_t)

corenet_sendrecv_smtp_client_packets(thunderbird_t)
corenet_tcp_connect_smtp_port(thunderbird_t)

corenet_sendrecv_pop_client_packets(thunderbird_t)
corenet_tcp_connect_pop_port(thunderbird_t)

corenet_sendrecv_http_client_packets(thunderbird_t)
corenet_tcp_connect_http_port(thunderbird_t)

dev_read_urand(thunderbird_t)
dev_dontaudit_search_sysfs(thunderbird_t)

files_list_tmp(thunderbird_t)
files_map_usr_files(thunderbird_t)
files_read_usr_files(thunderbird_t)
files_read_etc_runtime_files(thunderbird_t)
files_read_var_files(thunderbird_t)
files_read_var_symlinks(thunderbird_t)
files_dontaudit_getattr_all_tmp_files(thunderbird_t)
files_dontaudit_getattr_boot_dirs(thunderbird_t)
files_dontaudit_getattr_lost_found_dirs(thunderbird_t)
files_dontaudit_search_mnt(thunderbird_t)

fs_getattr_all_fs(thunderbird_t)
fs_list_inotifyfs(thunderbird_t)
fs_search_auto_mountpoints(thunderbird_t)

auth_use_nsswitch(thunderbird_t)

miscfiles_read_fonts(thunderbird_t)
miscfiles_read_localization(thunderbird_t)

userdom_write_user_tmp_sockets(thunderbird_t)
userdom_manage_user_tmp_dirs(thunderbird_t)
userdom_manage_user_tmp_files(thunderbird_t)
userdom_user_content_access_template(thunderbird, thunderbird_t)

xdg_read_data_files(thunderbird_t)
xdg_manage_downloads(thunderbird_t)

xserver_user_x_domain_template(thunderbird, thunderbird_t, thunderbird_tmpfs_t)
xserver_read_xdm_tmp_files(thunderbird_t)
xserver_dontaudit_getattr_xdm_tmp_sockets(thunderbird_t)

tunable_policy(`use_nfs_home_dirs',`
	fs_manage_nfs_dirs(thunderbird_t)
	fs_manage_nfs_files(thunderbird_t)
	fs_manage_nfs_symlinks(thunderbird_t)
')

tunable_policy(`use_samba_home_dirs',`
	fs_manage_cifs_dirs(thunderbird_t)
	fs_manage_cifs_files(thunderbird_t)
	fs_manage_cifs_symlinks(thunderbird_t)
')

ifndef(`enable_mls',`
	fs_search_removable(thunderbird_t)
	fs_read_removable_files(thunderbird_t)
	fs_read_removable_symlinks(thunderbird_t)
')

optional_policy(`
	dbus_system_bus_client(thunderbird_t)
	dbus_all_session_bus_client(thunderbird_t)

	optional_policy(`
		cups_dbus_chat(thunderbird_t)
	')

	optional_policy(`
		mozilla_dbus_chat(thunderbird_t)
	')
')

optional_policy(`
	cups_read_rw_config(thunderbird_t)
	cups_stream_connect(thunderbird_t)
')

optional_policy(`
	gnome_stream_connect_gconf(thunderbird_t)
	gnome_domtrans_gconfd(thunderbird_t)
	gnome_manage_generic_home_content(thunderbird_t)
')

optional_policy(`
	gpg_domtrans(thunderbird_t)
')

optional_policy(`
	lpd_run_lpr(thunderbird_t, thunderbird_roles)
')

optional_policy(`
	mozilla_read_user_home_files(thunderbird_t)
	mozilla_domtrans(thunderbird_t)
')

optional_policy(`
	ooffice_domtrans(thunderbird_t)
	ooffice_rw_tmp_files(thunderbird_t)
')
