Chris PeBenito a1fcff
Chris PeBenito a1fcff
policy_module(postgresql,1.0)
Chris PeBenito a1fcff
Chris PeBenito a1fcff
#################################
Chris PeBenito a1fcff
#
Chris PeBenito a1fcff
# Declarations
Chris PeBenito a1fcff
#
Chris PeBenito a1fcff
type postgresql_t;
Chris PeBenito a1fcff
type postgresql_exec_t;
Chris PeBenito a1fcff
init_daemon_domain(postgresql_t,postgresql_exec_t)
Chris PeBenito a1fcff
Chris PeBenito a1fcff
type postgresql_db_t;
Chris PeBenito a1fcff
files_type(postgresql_db_t)
Chris PeBenito a1fcff
Chris PeBenito a1fcff
type postgresql_etc_t; #, usercanread;
Chris PeBenito a1fcff
files_type(postgresql_etc_t)
Chris PeBenito a1fcff
Chris PeBenito a1fcff
type postgresql_lock_t;
Chris PeBenito a1fcff
files_lock_file(postgresql_lock_t)
Chris PeBenito a1fcff
Chris PeBenito a1fcff
type postgresql_log_t;
Chris PeBenito a1fcff
logging_log_file(postgresql_log_t)
Chris PeBenito a1fcff
Chris PeBenito a1fcff
type postgresql_tmp_t;
Chris PeBenito a1fcff
files_tmp_file(postgresql_tmp_t)
Chris PeBenito a1fcff
Chris PeBenito a1fcff
type postgresql_var_run_t;
Chris PeBenito a1fcff
files_pid_file(postgresql_var_run_t)
Chris PeBenito a1fcff
Chris PeBenito a1fcff
########################################
Chris PeBenito a1fcff
#
Chris PeBenito a1fcff
# postgresql Local policy
Chris PeBenito a1fcff
#
Chris PeBenito a1fcff
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 a1fcff
allow postgresql_t self:fifo_file { getattr read write ioctl };
Chris PeBenito a1fcff
allow postgresql_t self:file { getattr read };
Chris PeBenito a1fcff
allow postgresql_t self:sem create_sem_perms;
Chris PeBenito a1fcff
allow postgresql_t self:shm create_shm_perms;
Chris PeBenito a1fcff
allow postgresql_t self:tcp_socket create_stream_socket_perms;
Chris PeBenito a1fcff
allow postgresql_t self:udp_socket create_stream_socket_perms;
Chris PeBenito a1fcff
allow postgresql_t self:unix_dgram_socket create_socket_perms;
Chris PeBenito a1fcff
allow postgresql_t self:unix_stream_socket create_stream_socket_perms;
Chris PeBenito a1fcff
dontaudit postgresql_t self:capability { sys_tty_config sys_admin };
Chris PeBenito a1fcff
Chris PeBenito a1fcff
allow postgresql_t postgresql_db_t:dir create_dir_perms;
Chris PeBenito a1fcff
allow postgresql_t postgresql_db_t:fifo_file create_file_perms;
Chris PeBenito a1fcff
allow postgresql_t postgresql_db_t:file create_file_perms;
Chris PeBenito a1fcff
allow postgresql_t postgresql_db_t:lnk_file create_lnk_perms;
Chris PeBenito a1fcff
allow postgresql_t postgresql_db_t:sock_file create_file_perms;
Chris PeBenito a1fcff
files_create_var_lib(postgresql_t, postgresql_db_t, { dir file lnk_file sock_file fifo_file })
Chris PeBenito a1fcff
Chris PeBenito a1fcff
allow postgresql_t postgresql_etc_t:dir r_dir_perms;
Chris PeBenito a1fcff
allow postgresql_t postgresql_etc_t:file r_file_perms;
Chris PeBenito a1fcff
allow postgresql_t postgresql_etc_t:lnk_file { getattr read };
Chris PeBenito a1fcff
Chris PeBenito a1fcff
allow postgresql_t postgresql_exec_t:lnk_file { getattr read };
Chris PeBenito a1fcff
can_exec(postgresql_t, postgresql_exec_t )
Chris PeBenito a1fcff
Chris PeBenito a1fcff
allow postgresql_t postgresql_lock_t:file create_file_perms;
Chris PeBenito a1fcff
files_create_lock(postgresql_t,postgresql_lock_t)
Chris PeBenito a1fcff
Chris PeBenito a1fcff
allow postgresql_t postgresql_log_t:dir rw_dir_perms;
Chris PeBenito a1fcff
allow postgresql_t postgresql_log_t:file create_file_perms;
Chris PeBenito a1fcff
logging_create_log(postgresql_t,postgresql_log_t,{ file dir })
Chris PeBenito a1fcff
Chris PeBenito a1fcff
allow postgresql_t postgresql_tmp_t:dir create_dir_perms;
Chris PeBenito a1fcff
allow postgresql_t postgresql_tmp_t:fifo_file create_file_perms;
Chris PeBenito a1fcff
allow postgresql_t postgresql_tmp_t:file create_file_perms;
Chris PeBenito a1fcff
allow postgresql_t postgresql_tmp_t:lnk_file create_lnk_perms;
Chris PeBenito a1fcff
allow postgresql_t postgresql_tmp_t:sock_file create_file_perms;
Chris PeBenito a1fcff
files_create_tmp_files(postgresql_t, postgresql_tmp_t, { dir file sock_file })
Chris PeBenito a1fcff
fs_create_tmpfs_data(postgresql_t, postgresql_tmp_t, { dir file lnk_file sock_file fifo_file })
Chris PeBenito a1fcff
Chris PeBenito a1fcff
allow postgresql_t postgresql_var_run_t:dir rw_dir_perms;
Chris PeBenito a1fcff
allow postgresql_t postgresql_var_run_t:file create_file_perms;
Chris PeBenito a1fcff
allow postgresql_t postgresql_var_run_t:sock_file create_file_perms;
Chris PeBenito a1fcff
files_create_pid(postgresql_t,postgresql_var_run_t)
Chris PeBenito a1fcff
Chris PeBenito a1fcff
kernel_read_kernel_sysctl(postgresql_t)
Chris PeBenito a1fcff
kernel_read_system_state(postgresql_t)
Chris PeBenito a1fcff
kernel_list_proc(postgresql_t)
Chris PeBenito a1fcff
kernel_read_all_sysctl(postgresql_t)
Chris PeBenito a1fcff
kernel_read_proc_symlinks(postgresql_t)
Chris PeBenito a1fcff
kernel_tcp_recvfrom(postgresql_t)
Chris PeBenito a1fcff
Chris PeBenito a1fcff
corenet_tcp_sendrecv_all_if(postgresql_t)
Chris PeBenito a1fcff
corenet_udp_sendrecv_all_if(postgresql_t)
Chris PeBenito a1fcff
corenet_raw_sendrecv_all_if(postgresql_t)
Chris PeBenito a1fcff
corenet_tcp_sendrecv_all_nodes(postgresql_t)
Chris PeBenito a1fcff
corenet_udp_sendrecv_all_nodes(postgresql_t)
Chris PeBenito a1fcff
corenet_raw_sendrecv_all_nodes(postgresql_t)
Chris PeBenito a1fcff
corenet_tcp_sendrecv_all_ports(postgresql_t)
Chris PeBenito a1fcff
corenet_udp_sendrecv_all_ports(postgresql_t)
Chris PeBenito a1fcff
corenet_tcp_bind_all_nodes(postgresql_t)
Chris PeBenito a1fcff
corenet_udp_bind_all_nodes(postgresql_t)
Chris PeBenito a1fcff
corenet_tcp_bind_postgresql_port(postgresql_t)
Chris PeBenito a1fcff
corenet_tcp_connect_auth_port(postgresql_t)
Chris PeBenito a1fcff
Chris PeBenito a1fcff
dev_read_sysfs(postgresql_t)
Chris PeBenito a1fcff
dev_read_urand(postgresql_t)
Chris PeBenito a1fcff
Chris PeBenito a1fcff
fs_getattr_all_fs(postgresql_t)
Chris PeBenito a1fcff
fs_search_auto_mountpoints(postgresql_t)
Chris PeBenito a1fcff
Chris PeBenito a1fcff
term_use_controlling_term(postgresql_t)
Chris PeBenito a1fcff
term_dontaudit_use_console(postgresql_t)
Chris PeBenito a1fcff
Chris PeBenito a1fcff
corecmd_exec_bin(postgresql_t)
Chris PeBenito a1fcff
corecmd_exec_ls(postgresql_t)
Chris PeBenito a1fcff
corecmd_exec_sbin(postgresql_t)
Chris PeBenito a1fcff
corecmd_exec_shell(postgresql_t)
Chris PeBenito a1fcff
Chris PeBenito a1fcff
domain_dontaudit_list_all_domains_proc(postgresql_t)
Chris PeBenito a1fcff
domain_use_wide_inherit_fd(postgresql_t)
Chris PeBenito a1fcff
Chris PeBenito a1fcff
files_dontaudit_search_home(postgresql_t)
Chris PeBenito a1fcff
files_manage_etc_files(postgresql_t)
Chris PeBenito a1fcff
files_search_etc(postgresql_t)
Chris PeBenito a1fcff
files_read_etc_runtime_files(postgresql_t)
Chris PeBenito a1fcff
files_read_usr_files(postgresql_t)
Chris PeBenito a1fcff
Chris PeBenito a1fcff
init_read_script_pid(postgresql_t)
Chris PeBenito a1fcff
init_use_fd(postgresql_t)
Chris PeBenito a1fcff
init_use_script_pty(postgresql_t)
Chris PeBenito a1fcff
Chris PeBenito a1fcff
libs_use_ld_so(postgresql_t)
Chris PeBenito a1fcff
libs_use_shared_libs(postgresql_t)
Chris PeBenito a1fcff
Chris PeBenito a1fcff
logging_send_syslog_msg(postgresql_t)
Chris PeBenito a1fcff
Chris PeBenito a1fcff
miscfiles_read_localization(postgresql_t)
Chris PeBenito a1fcff
Chris PeBenito a1fcff
seutil_dontaudit_search_config(postgresql_t)
Chris PeBenito a1fcff
Chris PeBenito a1fcff
sysnet_read_config(postgresql_t)
Chris PeBenito a1fcff
Chris PeBenito a1fcff
userdom_dontaudit_search_sysadm_home_dir(postgresql_t)
Chris PeBenito a1fcff
userdom_dontaudit_use_sysadm_tty(postgresql_t)
Chris PeBenito a1fcff
userdom_dontaudit_use_unpriv_user_fd(postgresql_t)
Chris PeBenito a1fcff
Chris PeBenito a1fcff
mta_getattr_spool(postgresql_t)
Chris PeBenito a1fcff
Chris PeBenito a1fcff
ifdef(`targeted_policy', `
Chris PeBenito a1fcff
	files_dontaudit_read_root_file(postgresql_t)
Chris PeBenito a1fcff
	term_dontaudit_use_generic_pty(postgresql_t)
Chris PeBenito a1fcff
	term_dontaudit_use_unallocated_tty(postgresql_t)
Chris PeBenito a1fcff
')
Chris PeBenito a1fcff
Chris PeBenito a1fcff
tunable_policy(`allow_execmem',`
Chris PeBenito a1fcff
	allow postgresql_t self:process execmem;
Chris PeBenito a1fcff
')
Chris PeBenito a1fcff
Chris PeBenito a1fcff
optional_policy(`consoletype.te', `
Chris PeBenito a1fcff
	consoletype_exec(postgresql_t)
Chris PeBenito a1fcff
')
Chris PeBenito a1fcff
Chris PeBenito a1fcff
optional_policy(`cron.te',`
Chris PeBenito a1fcff
	cron_search_spool(postgresql_t)
Chris PeBenito a1fcff
	cron_system_entry(postgresql_t,postgresql_exec_t)
Chris PeBenito a1fcff
')
Chris PeBenito a1fcff
Chris PeBenito a1fcff
optional_policy(`hostname.te', `
Chris PeBenito a1fcff
	hostname_exec(postgresql_t)
Chris PeBenito a1fcff
')
Chris PeBenito a1fcff
Chris PeBenito a1fcff
optional_policy(`kerberos.te',`
Chris PeBenito a1fcff
	kerberos_use(postgresql_t)
Chris PeBenito a1fcff
')
Chris PeBenito a1fcff
Chris PeBenito a1fcff
optional_policy(`mount.te',`
Chris PeBenito a1fcff
	mount_send_nfs_client_request(postgresql_t)
Chris PeBenito a1fcff
')
Chris PeBenito a1fcff
Chris PeBenito a1fcff
optional_policy(`nis.te',`
Chris PeBenito a1fcff
	nis_use_ypbind(postgresql_t)
Chris PeBenito a1fcff
')
Chris PeBenito a1fcff
Chris PeBenito a1fcff
optional_policy(`rhgb.te',`
Chris PeBenito a1fcff
	rhgb_domain(postgresql_t)
Chris PeBenito a1fcff
')
Chris PeBenito a1fcff
Chris PeBenito a1fcff
optional_policy(`selinuxutil.te',`
Chris PeBenito a1fcff
	seutil_sigchld_newrole(postgresql_t)
Chris PeBenito a1fcff
')
Chris PeBenito a1fcff
Chris PeBenito a1fcff
optional_policy(`udev.te', `
Chris PeBenito a1fcff
	udev_read_db(postgresql_t)
Chris PeBenito a1fcff
')
Chris PeBenito a1fcff
Chris PeBenito a1fcff
ifdef(`TODO',`
Chris PeBenito a1fcff
ifdef(`targeted_policy', `', `
Chris PeBenito a1fcff
bool allow_user_postgresql_connect false;
Chris PeBenito a1fcff
Chris PeBenito a1fcff
if (allow_user_postgresql_connect) {
Chris PeBenito a1fcff
# allow any user domain to connect to the database server
Chris PeBenito a1fcff
can_tcp_connect(userdomain, postgresql_t)
Chris PeBenito a1fcff
allow userdomain postgresql_t:unix_stream_socket connectto;
Chris PeBenito a1fcff
allow userdomain postgresql_var_run_t:sock_file write;
Chris PeBenito a1fcff
allow userdomain postgresql_tmp_t:sock_file write;
Chris PeBenito a1fcff
}
Chris PeBenito a1fcff
')
Chris PeBenito a1fcff
ifdef(`distro_debian', `
Chris PeBenito a1fcff
	init_exec_script(postgresql_t)
Chris PeBenito a1fcff
	# gross hack
Chris PeBenito a1fcff
	postgresql_domtrans(dpkg_t)
Chris PeBenito a1fcff
	can_exec(postgresql_t, dpkg_exec_t)
Chris PeBenito a1fcff
')
Chris PeBenito a1fcff
Chris PeBenito a1fcff
ifdef(`distro_gentoo', `
Chris PeBenito a1fcff
	allow postgresql_t initrc_su_t:process { sigchld };
Chris PeBenito a1fcff
	# "su - postgres ..." is called from initrc_t
Chris PeBenito a1fcff
	postgresql_search_db_dir(initrc_su_t)
Chris PeBenito a1fcff
	dontaudit initrc_su_t sysadm_devpts_t:chr_file rw_file_perms;
Chris PeBenito a1fcff
')
Chris PeBenito a1fcff
Chris PeBenito a1fcff
# Goes to apache.te:
Chris PeBenito a1fcff
# Allow httpd to work with postgresql
Chris PeBenito a1fcff
optional_policy(`postgresql.te', ` 
Chris PeBenito a1fcff
	# Original policy had apache connecting to postgresql_tmp_t:sock_file
Chris PeBenito a1fcff
	# instead of what is assumed to be correct: postgresql_var_run_t. -Don
Chris PeBenito a1fcff
	postgresql_unix_connect(httpd_t)
Chris PeBenito a1fcff
')
Chris PeBenito a1fcff
')