policy_module(quantum)

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

type quantum_t;
type quantum_exec_t;
init_daemon_domain(quantum_t, quantum_exec_t)

type quantum_initrc_exec_t;
init_script_file(quantum_initrc_exec_t)

type quantum_log_t;
logging_log_file(quantum_log_t)

type quantum_tmp_t;
files_tmp_file(quantum_tmp_t)

type quantum_var_lib_t;
files_type(quantum_var_lib_t)

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

allow quantum_t self:capability { setgid setuid sys_resource };
allow quantum_t self:process { setrlimit setsched };
allow quantum_t self:fifo_file rw_fifo_file_perms;
allow quantum_t self:key manage_key_perms;
allow quantum_t self:tcp_socket { accept listen };
allow quantum_t self:unix_stream_socket { accept listen };

manage_dirs_pattern(quantum_t, quantum_log_t, quantum_log_t)
append_files_pattern(quantum_t, quantum_log_t, quantum_log_t)
create_files_pattern(quantum_t, quantum_log_t, quantum_log_t)
setattr_files_pattern(quantum_t, quantum_log_t, quantum_log_t)
logging_log_filetrans(quantum_t, quantum_log_t, dir)

manage_files_pattern(quantum_t, quantum_tmp_t, quantum_tmp_t)
files_tmp_filetrans(quantum_t, quantum_tmp_t, file)

manage_dirs_pattern(quantum_t, quantum_var_lib_t, quantum_var_lib_t)
manage_files_pattern(quantum_t, quantum_var_lib_t, quantum_var_lib_t)
files_var_lib_filetrans(quantum_t, quantum_var_lib_t, dir)

can_exec(quantum_t, quantum_tmp_t)

kernel_read_kernel_sysctls(quantum_t)
kernel_read_system_state(quantum_t)

corecmd_exec_shell(quantum_t)
corecmd_exec_bin(quantum_t)

corenet_all_recvfrom_netlabel(quantum_t)
corenet_tcp_sendrecv_generic_if(quantum_t)
corenet_tcp_sendrecv_generic_node(quantum_t)
corenet_tcp_bind_generic_node(quantum_t)

dev_list_sysfs(quantum_t)
dev_read_urand(quantum_t)

files_read_usr_files(quantum_t)

auth_use_nsswitch(quantum_t)

libs_exec_ldconfig(quantum_t)

logging_send_audit_msgs(quantum_t)
logging_send_syslog_msg(quantum_t)

miscfiles_read_localization(quantum_t)

sysnet_domtrans_ifconfig(quantum_t)

optional_policy(`
	brctl_domtrans(quantum_t)
')

optional_policy(`
	mysql_stream_connect(quantum_t)
	mysql_read_config(quantum_t)

	mysql_tcp_connect(quantum_t)
')

optional_policy(`
	postgresql_stream_connect(quantum_t)
	postgresql_unpriv_client(quantum_t)

	postgresql_tcp_connect(quantum_t)
')
