policy_module(postgrey)

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

type postgrey_t;
type postgrey_exec_t;
init_daemon_domain(postgrey_t, postgrey_exec_t)

type postgrey_etc_t;
files_config_file(postgrey_etc_t)

type postgrey_initrc_exec_t;
init_script_file(postgrey_initrc_exec_t)

type postgrey_runtime_t alias postgrey_var_run_t;
files_runtime_file(postgrey_runtime_t)

type postgrey_spool_t;
files_type(postgrey_spool_t)

type postgrey_var_lib_t;
files_type(postgrey_var_lib_t)

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

allow postgrey_t self:capability { chown dac_override setgid setuid };
dontaudit postgrey_t self:capability sys_tty_config;
allow postgrey_t self:process signal_perms;
allow postgrey_t self:fifo_file create_fifo_file_perms;
allow postgrey_t self:tcp_socket create_stream_socket_perms;
allow postgrey_t self:netlink_route_socket r_netlink_socket_perms;
allow postgrey_t self:udp_socket { connect connected_socket_perms };

allow postgrey_t postgrey_etc_t:dir list_dir_perms;
allow postgrey_t postgrey_etc_t:file read_file_perms;
allow postgrey_t postgrey_etc_t:lnk_file read_lnk_file_perms;

manage_dirs_pattern(postgrey_t, postgrey_spool_t, postgrey_spool_t)
manage_files_pattern(postgrey_t, postgrey_spool_t, postgrey_spool_t)
manage_fifo_files_pattern(postgrey_t, postgrey_spool_t, postgrey_spool_t)
manage_sock_files_pattern(postgrey_t, postgrey_spool_t, postgrey_spool_t)

mmap_manage_files_pattern(postgrey_t, postgrey_var_lib_t, postgrey_var_lib_t)
files_var_lib_filetrans(postgrey_t, postgrey_var_lib_t, file)

manage_dirs_pattern(postgrey_t, postgrey_runtime_t, postgrey_runtime_t)
manage_files_pattern(postgrey_t, postgrey_runtime_t, postgrey_runtime_t)
manage_sock_files_pattern(postgrey_t, postgrey_runtime_t, postgrey_runtime_t)
files_runtime_filetrans(postgrey_t, postgrey_runtime_t, { dir file sock_file })

kernel_read_system_state(postgrey_t)
kernel_read_kernel_sysctls(postgrey_t)

corecmd_read_bin_files(postgrey_t)
corecmd_exec_bin(postgrey_t)

corenet_all_recvfrom_netlabel(postgrey_t)
corenet_tcp_sendrecv_generic_if(postgrey_t)
corenet_tcp_sendrecv_generic_node(postgrey_t)
corenet_tcp_bind_generic_node(postgrey_t)

corenet_sendrecv_postgrey_server_packets(postgrey_t)
corenet_tcp_bind_postgrey_port(postgrey_t)

dev_read_urand(postgrey_t)
dev_read_sysfs(postgrey_t)

domain_use_interactive_fds(postgrey_t)

files_read_etc_files(postgrey_t)
files_read_etc_runtime_files(postgrey_t)
files_read_usr_files(postgrey_t)
files_getattr_tmp_dirs(postgrey_t)

fs_getattr_all_fs(postgrey_t)
fs_search_auto_mountpoints(postgrey_t)

logging_send_syslog_msg(postgrey_t)

miscfiles_read_localization(postgrey_t)

sysnet_read_config(postgrey_t)

userdom_dontaudit_use_unpriv_user_fds(postgrey_t)
userdom_dontaudit_search_user_home_dirs(postgrey_t)

optional_policy(`
	nis_use_ypbind(postgrey_t)
')

optional_policy(`
	postfix_read_config(postgrey_t)
	postfix_manage_spool_files(postgrey_t)
')

optional_policy(`
	seutil_sigchld_newrole(postgrey_t)
')

