policy_module(gitosis, 1.6.0)

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

## <desc>
##	<p>
##	Determine whether Gitosis can send mail.
##	</p>
## </desc>
gen_tunable(gitosis_can_sendmail, false)

attribute_role gitosis_roles;
roleattribute system_r gitosis_roles;

type gitosis_t;
type gitosis_exec_t;
application_domain(gitosis_t, gitosis_exec_t)
role gitosis_roles types gitosis_t;

type gitosis_var_lib_t;
files_type(gitosis_var_lib_t)

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

allow gitosis_t self:fifo_file rw_fifo_file_perms;

exec_files_pattern(gitosis_t, gitosis_var_lib_t, gitosis_var_lib_t)
manage_files_pattern(gitosis_t, gitosis_var_lib_t, gitosis_var_lib_t)
manage_lnk_files_pattern(gitosis_t, gitosis_var_lib_t, gitosis_var_lib_t)
manage_dirs_pattern(gitosis_t, gitosis_var_lib_t, gitosis_var_lib_t)

kernel_read_system_state(gitosis_t)

corenet_all_recvfrom_netlabel(gitosis_t)
corenet_tcp_sendrecv_generic_if(gitosis_t)
corenet_tcp_sendrecv_generic_node(gitosis_t)
corenet_tcp_bind_generic_node(gitosis_t)

corenet_sendrecv_ssh_server_packets(gitosis_t)
corenet_tcp_bind_ssh_port(gitosis_t)

corecmd_exec_bin(gitosis_t)
corecmd_exec_shell(gitosis_t)

dev_read_urand(gitosis_t)

files_read_etc_files(gitosis_t)
files_read_usr_files(gitosis_t)
files_search_var_lib(gitosis_t)

miscfiles_read_localization(gitosis_t)

sysnet_read_config(gitosis_t)

tunable_policy(`gitosis_can_sendmail',`
	mta_send_mail(gitosis_t)
')
