policy_module(certmonger, 1.8.0)

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

type certmonger_t;
type certmonger_exec_t;
init_daemon_domain(certmonger_t, certmonger_exec_t)

type certmonger_initrc_exec_t;
init_script_file(certmonger_initrc_exec_t)

type certmonger_runtime_t alias certmonger_var_run_t;
files_runtime_file(certmonger_runtime_t)

type certmonger_var_lib_t;
files_type(certmonger_var_lib_t)

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

allow certmonger_t self:capability { chown dac_override dac_read_search kill setgid setuid sys_nice };
dontaudit certmonger_t self:capability sys_tty_config;
allow certmonger_t self:capability2 block_suspend;
allow certmonger_t self:process { getsched setsched sigkill signal };
allow certmonger_t self:fifo_file rw_fifo_file_perms;
allow certmonger_t self:unix_stream_socket { accept listen };
allow certmonger_t self:tcp_socket { accept listen };

manage_dirs_pattern(certmonger_t, certmonger_var_lib_t, certmonger_var_lib_t)
manage_files_pattern(certmonger_t, certmonger_var_lib_t, certmonger_var_lib_t)
files_var_lib_filetrans(certmonger_t, certmonger_var_lib_t, dir)

manage_dirs_pattern(certmonger_t, certmonger_runtime_t, certmonger_runtime_t)
manage_files_pattern(certmonger_t, certmonger_runtime_t, certmonger_runtime_t)
files_runtime_filetrans(certmonger_t, certmonger_runtime_t, { dir file })

kernel_read_kernel_sysctls(certmonger_t)
kernel_read_system_state(certmonger_t)

corenet_all_recvfrom_netlabel(certmonger_t)
corenet_tcp_sendrecv_generic_if(certmonger_t)
corenet_tcp_sendrecv_generic_node(certmonger_t)

corenet_sendrecv_certmaster_client_packets(certmonger_t)
corenet_tcp_connect_certmaster_port(certmonger_t)

corecmd_exec_bin(certmonger_t)
corecmd_exec_shell(certmonger_t)

dev_read_urand(certmonger_t)

domain_use_interactive_fds(certmonger_t)

files_read_usr_files(certmonger_t)
files_list_tmp(certmonger_t)

fs_search_cgroup_dirs(certmonger_t)

auth_use_nsswitch(certmonger_t)
auth_rw_cache(certmonger_t)

init_getattr_all_script_files(certmonger_t)

logging_send_syslog_msg(certmonger_t)

miscfiles_read_localization(certmonger_t)
miscfiles_manage_generic_cert_files(certmonger_t)

userdom_search_user_home_content(certmonger_t)

optional_policy(`
	apache_initrc_domtrans(certmonger_t)
	apache_search_config(certmonger_t)
	apache_signal(certmonger_t)
	apache_signull(certmonger_t)
')

optional_policy(`
	bind_search_cache(certmonger_t)
')

optional_policy(`
	dbus_connect_system_bus(certmonger_t)
	dbus_system_bus_client(certmonger_t)
')

optional_policy(`
	kerberos_read_keytab(certmonger_t)
	kerberos_use(certmonger_t)
')

optional_policy(`
	pcscd_read_runtime_files(certmonger_t)
	pcscd_stream_connect(certmonger_t)
')
