Chris PeBenito 17de1b
Chris PeBenito a5e213
policy_module(postgresql,1.1.4)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
#################################
Chris PeBenito 17de1b
#
Chris PeBenito 17de1b
# Declarations
Chris PeBenito 17de1b
#
Chris PeBenito 17de1b
type postgresql_t;
Chris PeBenito 17de1b
type postgresql_exec_t;
Chris PeBenito 17de1b
init_daemon_domain(postgresql_t,postgresql_exec_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
type postgresql_db_t;
Chris PeBenito 17de1b
files_type(postgresql_db_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
type postgresql_etc_t;
Chris PeBenito 17de1b
files_config_file(postgresql_etc_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
type postgresql_lock_t;
Chris PeBenito 17de1b
files_lock_file(postgresql_lock_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
type postgresql_log_t;
Chris PeBenito 17de1b
logging_log_file(postgresql_log_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
type postgresql_tmp_t;
Chris PeBenito 17de1b
files_tmp_file(postgresql_tmp_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
type postgresql_var_run_t;
Chris PeBenito 17de1b
files_pid_file(postgresql_var_run_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
########################################
Chris PeBenito 17de1b
#
Chris PeBenito 17de1b
# postgresql Local policy
Chris PeBenito 17de1b
#
Chris PeBenito 17de1b
allow postgresql_t self:capability { kill dac_override dac_read_search chown fowner fsetid setuid setgid sys_nice sys_tty_config sys_admin };
Chris PeBenito 17de1b
dontaudit postgresql_t self:capability { sys_tty_config sys_admin };
Chris PeBenito 17de1b
allow postgresql_t self:process signal_perms;
Chris PeBenito 17de1b
allow postgresql_t self:fifo_file { getattr read write ioctl };
Chris PeBenito 17de1b
allow postgresql_t self:file { getattr read };
Chris PeBenito 17de1b
allow postgresql_t self:sem create_sem_perms;
Chris PeBenito 17de1b
allow postgresql_t self:shm create_shm_perms;
Chris PeBenito 17de1b
allow postgresql_t self:tcp_socket create_stream_socket_perms;
Chris PeBenito 17de1b
allow postgresql_t self:udp_socket create_stream_socket_perms;
Chris PeBenito 17de1b
allow postgresql_t self:unix_dgram_socket create_socket_perms;
Chris PeBenito 17de1b
allow postgresql_t self:unix_stream_socket create_stream_socket_perms;
Chris PeBenito 17de1b
allow postgresql_t self:netlink_route_socket r_netlink_socket_perms;
Chris PeBenito 17de1b
Chris PeBenito 17de1b
allow postgresql_t postgresql_db_t:dir create_dir_perms;
Chris PeBenito 17de1b
allow postgresql_t postgresql_db_t:fifo_file create_file_perms;
Chris PeBenito 17de1b
allow postgresql_t postgresql_db_t:file create_file_perms;
Chris PeBenito 17de1b
allow postgresql_t postgresql_db_t:lnk_file create_lnk_perms;
Chris PeBenito 17de1b
allow postgresql_t postgresql_db_t:sock_file create_file_perms;
Chris PeBenito 17de1b
files_var_lib_filetrans(postgresql_t, postgresql_db_t, { dir file lnk_file sock_file fifo_file })
Chris PeBenito 17de1b
Chris PeBenito 17de1b
allow postgresql_t postgresql_etc_t:dir r_dir_perms;
Chris PeBenito 17de1b
allow postgresql_t postgresql_etc_t:file r_file_perms;
Chris PeBenito 17de1b
allow postgresql_t postgresql_etc_t:lnk_file { getattr read };
Chris PeBenito 17de1b
Chris PeBenito 17de1b
allow postgresql_t postgresql_exec_t:lnk_file { getattr read };
Chris PeBenito 17de1b
can_exec(postgresql_t, postgresql_exec_t )
Chris PeBenito 17de1b
Chris PeBenito 17de1b
allow postgresql_t postgresql_lock_t:file create_file_perms;
Chris PeBenito 17de1b
files_lock_filetrans(postgresql_t,postgresql_lock_t,file)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
allow postgresql_t postgresql_log_t:dir rw_dir_perms;
Chris PeBenito 17de1b
allow postgresql_t postgresql_log_t:file create_file_perms;
Chris PeBenito 17de1b
logging_log_filetrans(postgresql_t,postgresql_log_t,{ file dir })
Chris PeBenito 17de1b
Chris PeBenito 17de1b
allow postgresql_t postgresql_tmp_t:dir create_dir_perms;
Chris PeBenito 17de1b
allow postgresql_t postgresql_tmp_t:fifo_file create_file_perms;
Chris PeBenito 17de1b
allow postgresql_t postgresql_tmp_t:file create_file_perms;
Chris PeBenito 17de1b
allow postgresql_t postgresql_tmp_t:lnk_file create_lnk_perms;
Chris PeBenito 17de1b
allow postgresql_t postgresql_tmp_t:sock_file create_file_perms;
Chris PeBenito 17de1b
files_tmp_filetrans(postgresql_t, postgresql_tmp_t, { dir file sock_file })
Chris PeBenito 17de1b
fs_tmpfs_filetrans(postgresql_t, postgresql_tmp_t, { dir file lnk_file sock_file fifo_file })
Chris PeBenito 17de1b
Chris PeBenito 17de1b
allow postgresql_t postgresql_var_run_t:dir rw_dir_perms;
Chris PeBenito 17de1b
allow postgresql_t postgresql_var_run_t:file create_file_perms;
Chris PeBenito 17de1b
allow postgresql_t postgresql_var_run_t:sock_file create_file_perms;
Chris PeBenito 17de1b
files_pid_filetrans(postgresql_t,postgresql_var_run_t,file)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
kernel_read_kernel_sysctls(postgresql_t)
Chris PeBenito 17de1b
kernel_read_system_state(postgresql_t)
Chris PeBenito 17de1b
kernel_list_proc(postgresql_t)
Chris PeBenito 17de1b
kernel_read_all_sysctls(postgresql_t)
Chris PeBenito 17de1b
kernel_read_proc_symlinks(postgresql_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
corenet_non_ipsec_sendrecv(postgresql_t)
Chris PeBenito 17de1b
corenet_tcp_sendrecv_all_if(postgresql_t)
Chris PeBenito 17de1b
corenet_udp_sendrecv_all_if(postgresql_t)
Chris PeBenito 17de1b
corenet_tcp_sendrecv_all_nodes(postgresql_t)
Chris PeBenito 17de1b
corenet_udp_sendrecv_all_nodes(postgresql_t)
Chris PeBenito 17de1b
corenet_tcp_sendrecv_all_ports(postgresql_t)
Chris PeBenito 17de1b
corenet_udp_sendrecv_all_ports(postgresql_t)
Chris PeBenito 17de1b
corenet_tcp_bind_all_nodes(postgresql_t)
Chris PeBenito 17de1b
corenet_tcp_bind_postgresql_port(postgresql_t)
Chris PeBenito 17de1b
corenet_tcp_connect_auth_port(postgresql_t)
Chris PeBenito 17de1b
corenet_sendrecv_postgresql_server_packets(postgresql_t)
Chris PeBenito 17de1b
corenet_sendrecv_auth_client_packets(postgresql_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
dev_read_sysfs(postgresql_t)
Chris PeBenito 17de1b
dev_read_urand(postgresql_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
fs_getattr_all_fs(postgresql_t)
Chris PeBenito 17de1b
fs_search_auto_mountpoints(postgresql_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
term_use_controlling_term(postgresql_t)
Chris PeBenito 17de1b
term_dontaudit_use_console(postgresql_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
corecmd_exec_bin(postgresql_t)
Chris PeBenito 17de1b
corecmd_exec_ls(postgresql_t)
Chris PeBenito 17de1b
corecmd_exec_sbin(postgresql_t)
Chris PeBenito 17de1b
corecmd_exec_shell(postgresql_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
domain_dontaudit_list_all_domains_state(postgresql_t)
Chris PeBenito 17de1b
domain_use_interactive_fds(postgresql_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
files_dontaudit_search_home(postgresql_t)
Chris PeBenito 17de1b
files_manage_etc_files(postgresql_t)
Chris PeBenito 17de1b
files_search_etc(postgresql_t)
Chris PeBenito 17de1b
files_read_etc_runtime_files(postgresql_t)
Chris PeBenito 17de1b
files_read_usr_files(postgresql_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
init_read_utmp(postgresql_t)
Chris PeBenito 17de1b
init_use_fds(postgresql_t)
Chris PeBenito 17de1b
init_use_script_ptys(postgresql_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
libs_use_ld_so(postgresql_t)
Chris PeBenito 17de1b
libs_use_shared_libs(postgresql_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
logging_send_syslog_msg(postgresql_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
miscfiles_read_localization(postgresql_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
seutil_dontaudit_search_config(postgresql_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
sysnet_read_config(postgresql_t)
Chris PeBenito a5e213
sysnet_use_ldap(postgresql_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
userdom_dontaudit_search_sysadm_home_dirs(postgresql_t)
Chris PeBenito 17de1b
userdom_dontaudit_use_sysadm_ttys(postgresql_t)
Chris PeBenito 17de1b
userdom_dontaudit_use_unpriv_user_fds(postgresql_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
mta_getattr_spool(postgresql_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
ifdef(`targeted_policy', `
Chris PeBenito 17de1b
	files_dontaudit_read_root_files(postgresql_t)
Chris PeBenito 17de1b
	term_dontaudit_use_generic_ptys(postgresql_t)
Chris PeBenito 17de1b
	term_dontaudit_use_unallocated_ttys(postgresql_t)
Chris PeBenito 17de1b
')
Chris PeBenito 17de1b
Chris PeBenito 17de1b
tunable_policy(`allow_execmem',`
Chris PeBenito 17de1b
	allow postgresql_t self:process execmem;
Chris PeBenito 17de1b
')
Chris PeBenito 17de1b
Chris PeBenito 17de1b
optional_policy(`
Chris PeBenito 17de1b
	consoletype_exec(postgresql_t)
Chris PeBenito 17de1b
')
Chris PeBenito 17de1b
Chris PeBenito 17de1b
optional_policy(`
Chris PeBenito 17de1b
	cron_search_spool(postgresql_t)
Chris PeBenito 17de1b
	cron_system_entry(postgresql_t,postgresql_exec_t)
Chris PeBenito 17de1b
')
Chris PeBenito 17de1b
Chris PeBenito 17de1b
optional_policy(`
Chris PeBenito 17de1b
	hostname_exec(postgresql_t)
Chris PeBenito 17de1b
')
Chris PeBenito 17de1b
Chris PeBenito 17de1b
optional_policy(`
Chris PeBenito 17de1b
	kerberos_use(postgresql_t)
Chris PeBenito 17de1b
')
Chris PeBenito 17de1b
Chris PeBenito 17de1b
optional_policy(`
Chris PeBenito 17de1b
	nis_use_ypbind(postgresql_t)
Chris PeBenito 17de1b
')
Chris PeBenito 17de1b
Chris PeBenito 17de1b
optional_policy(`
Chris PeBenito 17de1b
	seutil_sigchld_newrole(postgresql_t)
Chris PeBenito 17de1b
')
Chris PeBenito 17de1b
Chris PeBenito 17de1b
optional_policy(`
Chris PeBenito 17de1b
	udev_read_db(postgresql_t)
Chris PeBenito 17de1b
')
Chris PeBenito 17de1b
Chris PeBenito 17de1b
ifdef(`TODO',`
Chris PeBenito 17de1b
ifdef(`targeted_policy', `', `
Chris PeBenito 17de1b
bool allow_user_postgresql_connect false;
Chris PeBenito 17de1b
Chris PeBenito 17de1b
if (allow_user_postgresql_connect) {
Chris PeBenito 17de1b
# allow any user domain to connect to the database server
Chris PeBenito 17de1b
can_tcp_connect(userdomain, postgresql_t)
Chris PeBenito 17de1b
allow userdomain postgresql_t:unix_stream_socket connectto;
Chris PeBenito 17de1b
allow userdomain postgresql_var_run_t:sock_file write;
Chris PeBenito 17de1b
allow userdomain postgresql_tmp_t:sock_file write;
Chris PeBenito 17de1b
}
Chris PeBenito 17de1b
')
Chris PeBenito 17de1b
ifdef(`distro_debian', `
Chris PeBenito 17de1b
	init_exec_script_files(postgresql_t)
Chris PeBenito 17de1b
	# gross hack
Chris PeBenito 17de1b
	postgresql_domtrans(dpkg_t)
Chris PeBenito 17de1b
	can_exec(postgresql_t, dpkg_exec_t)
Chris PeBenito 17de1b
')
Chris PeBenito 17de1b
Chris PeBenito 17de1b
ifdef(`distro_gentoo', `
Chris PeBenito 17de1b
	allow postgresql_t initrc_su_t:process { sigchld };
Chris PeBenito 17de1b
	# "su - postgres ..." is called from initrc_t
Chris PeBenito 17de1b
	postgresql_search_db(initrc_su_t)
Chris PeBenito 17de1b
	dontaudit initrc_su_t sysadm_devpts_t:chr_file rw_file_perms;
Chris PeBenito 17de1b
')
Chris PeBenito 17de1b
')