policy_module(blueman, 1.1.0)

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

type blueman_t;
type blueman_exec_t;
init_daemon_domain(blueman_t, blueman_exec_t)

type blueman_var_lib_t;
files_type(blueman_var_lib_t)

type blueman_var_run_t;
files_pid_file(blueman_var_run_t)

type blueman_tmp_t;
files_tmp_file(blueman_tmp_t)

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

allow blueman_t self:capability { net_admin sys_nice };
allow blueman_t self:process { execmem signal_perms setsched };

allow blueman_t self:fifo_file rw_fifo_file_perms;

manage_dirs_pattern(blueman_t, blueman_var_lib_t, blueman_var_lib_t)
manage_files_pattern(blueman_t, blueman_var_lib_t, blueman_var_lib_t)
files_var_lib_filetrans(blueman_t, blueman_var_lib_t, dir)

manage_dirs_pattern(blueman_t, blueman_var_run_t, blueman_var_run_t)
manage_files_pattern(blueman_t, blueman_var_run_t, blueman_var_run_t)
files_pid_filetrans(blueman_t, blueman_var_run_t, { dir file })

manage_dirs_pattern(blueman_t, blueman_tmp_t, blueman_tmp_t)
manage_files_pattern(blueman_t, blueman_tmp_t, blueman_tmp_t)
exec_files_pattern(blueman_t, blueman_tmp_t, blueman_tmp_t)
files_tmp_filetrans(blueman_t, blueman_tmp_t, { file dir })

kernel_rw_net_sysctls(blueman_t)
kernel_read_system_state(blueman_t)
kernel_request_load_module(blueman_t)

corecmd_exec_bin(blueman_t)

dev_read_rand(blueman_t)
dev_read_urand(blueman_t)
dev_rw_wireless(blueman_t)
dev_rwx_zero(blueman_t)

domain_use_interactive_fds(blueman_t)
domain_dontaudit_ptrace_all_domains(blueman_t)
domain_dontaudit_read_all_domains_state(blueman_t)

files_list_tmp(blueman_t)
files_dontaudit_write_all_mountpoints(blueman_t)

auth_use_nsswitch(blueman_t)

libs_exec_ldconfig(blueman_t)

logging_send_syslog_msg(blueman_t)

sysnet_domtrans_ifconfig(blueman_t)
sysnet_dns_name_resolve(blueman_t)

optional_policy(`
	avahi_domtrans(blueman_t)
')

optional_policy(`
    bluetooth_read_config(blueman_t)
')

optional_policy(`
	dbus_system_domain(blueman_t, blueman_exec_t)
')

optional_policy(`
	dnsmasq_domtrans(blueman_t)
	dnsmasq_read_pid_files(blueman_t)
')

optional_policy(`
	gnome_search_gconf(blueman_t)
')

optional_policy(`
	iptables_domtrans(blueman_t)
')

optional_policy(`
	xserver_read_state_xdm(blueman_t)
')
