Chris PeBenito 29af4c
policy_module(postgresql, 1.11.0)
Chris PeBenito e8cb08
Chris PeBenito e8cb08
gen_require(`
Chris PeBenito e8cb08
	class db_database all_db_database_perms;
Chris PeBenito e8cb08
	class db_table all_db_table_perms;
Chris PeBenito e8cb08
	class db_procedure all_db_procedure_perms;
Chris PeBenito e8cb08
	class db_column all_db_column_perms;
Chris PeBenito e8cb08
	class db_tuple all_db_tuple_perms;
Chris PeBenito e8cb08
	class db_blob all_db_blob_perms;
Chris PeBenito e8cb08
')
Chris PeBenito 17de1b
Chris PeBenito 17de1b
#################################
Chris PeBenito 17de1b
#
Chris PeBenito 17de1b
# Declarations
Chris PeBenito 17de1b
#
Chris PeBenito e8cb08
Chris PeBenito e8cb08
## <desc>
Chris PeBenito e8cb08
## 

Chris PeBenito e8cb08
## Allow unprived users to execute DDL statement
Chris PeBenito e8cb08
## 

Chris PeBenito e8cb08
## </desc>
Chris PeBenito e8cb08
gen_tunable(sepgsql_enable_users_ddl, true)
Chris PeBenito e8cb08
Chris PeBenito 22a287
## <desc>
Chris PeBenito 22a287
## 

Chris PeBenito 22a287
## Allow database admins to execute DML statement
Chris PeBenito 22a287
## 

Chris PeBenito 22a287
## </desc>
Chris PeBenito 22a287
gen_tunable(sepgsql_unconfined_dbadm, true)
Chris PeBenito 22a287
Chris PeBenito 17de1b
type postgresql_t;
Chris PeBenito 17de1b
type postgresql_exec_t;
Chris PeBenito 0bfccd
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 22a287
type postgresql_initrc_exec_t;
Chris PeBenito 22a287
init_script_file(postgresql_initrc_exec_t)
Chris PeBenito 22a287
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 e8cb08
# database clients attribute
Chris PeBenito 22a287
attribute sepgsql_admin_type;
Chris PeBenito e8cb08
attribute sepgsql_client_type;
Chris PeBenito e8cb08
attribute sepgsql_unconfined_type;
Chris PeBenito e8cb08
Chris PeBenito e8cb08
# database objects attribute
Chris PeBenito e8cb08
attribute sepgsql_database_type;
Chris PeBenito e8cb08
attribute sepgsql_table_type;
Chris PeBenito e8cb08
attribute sepgsql_sysobj_table_type;
Chris PeBenito e8cb08
attribute sepgsql_procedure_type;
Chris PeBenito e8cb08
attribute sepgsql_blob_type;
Chris PeBenito e8cb08
attribute sepgsql_module_type;
Chris PeBenito e8cb08
Chris PeBenito e8cb08
# database object types
Chris PeBenito e8cb08
type sepgsql_blob_t;
Chris PeBenito e8cb08
postgresql_blob_object(sepgsql_blob_t)
Chris PeBenito e8cb08
Chris PeBenito e8cb08
type sepgsql_db_t;
Chris PeBenito e8cb08
postgresql_database_object(sepgsql_db_t)
Chris PeBenito e8cb08
Chris PeBenito e8cb08
type sepgsql_fixed_table_t;
Chris PeBenito e8cb08
postgresql_table_object(sepgsql_fixed_table_t)
Chris PeBenito e8cb08
Chris PeBenito 350ed8
type sepgsql_proc_exec_t;
Chris PeBenito 350ed8
typealias sepgsql_proc_exec_t alias sepgsql_proc_t;
Chris PeBenito 350ed8
postgresql_procedure_object(sepgsql_proc_exec_t)
Chris PeBenito e8cb08
Chris PeBenito e8cb08
type sepgsql_ro_blob_t;
Chris PeBenito e8cb08
postgresql_blob_object(sepgsql_ro_blob_t)
Chris PeBenito e8cb08
Chris PeBenito e8cb08
type sepgsql_ro_table_t;
Chris PeBenito e8cb08
postgresql_table_object(sepgsql_ro_table_t)
Chris PeBenito e8cb08
Chris PeBenito e8cb08
type sepgsql_secret_blob_t;
Chris PeBenito e8cb08
postgresql_blob_object(sepgsql_secret_blob_t)
Chris PeBenito e8cb08
Chris PeBenito e8cb08
type sepgsql_secret_table_t;
Chris PeBenito e8cb08
postgresql_table_object(sepgsql_secret_table_t)
Chris PeBenito e8cb08
Chris PeBenito e8cb08
type sepgsql_sysobj_t;
Chris PeBenito e8cb08
postgresql_system_table_object(sepgsql_sysobj_t)
Chris PeBenito e8cb08
Chris PeBenito e8cb08
type sepgsql_table_t;
Chris PeBenito e8cb08
postgresql_table_object(sepgsql_table_t)
Chris PeBenito e8cb08
Chris PeBenito 7f4005
type sepgsql_trusted_proc_exec_t;
Chris PeBenito 7f4005
postgresql_procedure_object(sepgsql_trusted_proc_exec_t)
Chris PeBenito e8cb08
Chris PeBenito e8cb08
# Trusted Procedure Domain
Chris PeBenito 7f4005
type sepgsql_trusted_proc_t;
Chris PeBenito 7f4005
domain_type(sepgsql_trusted_proc_t)
Chris PeBenito 7f4005
postgresql_unconfined(sepgsql_trusted_proc_t)
Chris PeBenito 7f4005
role system_r types sepgsql_trusted_proc_t;
Chris PeBenito e8cb08
Chris PeBenito a01a4a
# Types for unprivileged client
Chris PeBenito a01a4a
type unpriv_sepgsql_blob_t;
Chris PeBenito a01a4a
postgresql_blob_object(unpriv_sepgsql_blob_t)
Chris PeBenito a01a4a
Chris PeBenito a01a4a
type unpriv_sepgsql_proc_exec_t;
Chris PeBenito a01a4a
postgresql_procedure_object(unpriv_sepgsql_proc_exec_t)
Chris PeBenito a01a4a
Chris PeBenito a01a4a
type unpriv_sepgsql_sysobj_t;
Chris PeBenito a01a4a
postgresql_system_table_object(unpriv_sepgsql_sysobj_t)
Chris PeBenito a01a4a
Chris PeBenito a01a4a
type unpriv_sepgsql_table_t;
Chris PeBenito a01a4a
postgresql_table_object(unpriv_sepgsql_table_t)
Chris PeBenito a01a4a
Chris PeBenito a01a4a
# Types for UBAC
Chris PeBenito 296273
type user_sepgsql_blob_t;
Chris PeBenito 296273
typealias user_sepgsql_blob_t alias { staff_sepgsql_blob_t sysadm_sepgsql_blob_t };
Chris PeBenito 296273
typealias user_sepgsql_blob_t alias { auditadm_sepgsql_blob_t secadm_sepgsql_blob_t };
Chris PeBenito 296273
postgresql_blob_object(user_sepgsql_blob_t)
Chris PeBenito 296273
Chris PeBenito 296273
type user_sepgsql_proc_exec_t;
Chris PeBenito 296273
typealias user_sepgsql_proc_exec_t alias { staff_sepgsql_proc_exec_t sysadm_sepgsql_proc_exec_t };
Chris PeBenito 296273
typealias user_sepgsql_proc_exec_t alias { auditadm_sepgsql_proc_exec_t secadm_sepgsql_proc_exec_t };
Chris PeBenito 296273
postgresql_procedure_object(user_sepgsql_proc_exec_t)
Chris PeBenito 296273
Chris PeBenito 296273
type user_sepgsql_sysobj_t;
Chris PeBenito 296273
typealias user_sepgsql_sysobj_t alias { staff_sepgsql_sysobj_t sysadm_sepgsql_sysobj_t };
Chris PeBenito 296273
typealias user_sepgsql_sysobj_t alias { auditadm_sepgsql_sysobj_t secadm_sepgsql_sysobj_t };
Chris PeBenito 296273
postgresql_system_table_object(user_sepgsql_sysobj_t)
Chris PeBenito 296273
Chris PeBenito 296273
type user_sepgsql_table_t;
Chris PeBenito 296273
typealias user_sepgsql_table_t alias { staff_sepgsql_table_t sysadm_sepgsql_table_t };
Chris PeBenito 296273
typealias user_sepgsql_table_t alias { auditadm_sepgsql_table_t secadm_sepgsql_table_t };
Chris PeBenito 296273
postgresql_table_object(user_sepgsql_table_t)
Chris PeBenito 296273
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 0b36a2
allow postgresql_t self:fifo_file rw_fifo_file_perms;
Jeremy Solt 9681df
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 e8cb08
allow postgresql_t self:netlink_selinux_socket create_socket_perms;
Chris PeBenito e8cb08
Chris PeBenito e8cb08
allow postgresql_t sepgsql_database_type:db_database *;
Chris PeBenito e8cb08
type_transition postgresql_t postgresql_t:db_database sepgsql_db_t;
Chris PeBenito e8cb08
Chris PeBenito e8cb08
allow postgresql_t sepgsql_module_type:db_database install_module;
Chris PeBenito e8cb08
# Database/Loadable module
Chris PeBenito e8cb08
allow sepgsql_database_type sepgsql_module_type:db_database load_module;
Chris PeBenito e8cb08
Chris PeBenito e8cb08
allow postgresql_t sepgsql_table_type:{ db_table db_column db_tuple } *;
Chris PeBenito e8cb08
type_transition postgresql_t sepgsql_database_type:db_table sepgsql_sysobj_t;
Chris PeBenito e8cb08
Chris PeBenito e8cb08
allow postgresql_t sepgsql_procedure_type:db_procedure *;
Chris PeBenito 350ed8
type_transition postgresql_t sepgsql_database_type:db_procedure sepgsql_proc_exec_t;
Chris PeBenito e8cb08
Chris PeBenito e8cb08
allow postgresql_t sepgsql_blob_type:db_blob *;
Chris PeBenito e8cb08
type_transition postgresql_t sepgsql_database_type:db_blob sepgsql_blob_t;
Chris PeBenito 17de1b
Chris PeBenito 0bfccd
manage_dirs_pattern(postgresql_t, postgresql_db_t, postgresql_db_t)
Chris PeBenito 0bfccd
manage_files_pattern(postgresql_t, postgresql_db_t, postgresql_db_t)
Chris PeBenito 0bfccd
manage_lnk_files_pattern(postgresql_t, postgresql_db_t, postgresql_db_t)
Chris PeBenito 0bfccd
manage_fifo_files_pattern(postgresql_t, postgresql_db_t, postgresql_db_t)
Chris PeBenito 0bfccd
manage_sock_files_pattern(postgresql_t, postgresql_db_t, postgresql_db_t)
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 c0868a
allow postgresql_t postgresql_etc_t:dir list_dir_perms;
Chris PeBenito 0bfccd
read_files_pattern(postgresql_t, postgresql_etc_t, postgresql_etc_t)
Chris PeBenito 0bfccd
read_lnk_files_pattern(postgresql_t, postgresql_etc_t, postgresql_etc_t)
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 c0868a
allow postgresql_t postgresql_lock_t:file manage_file_perms;
Chris PeBenito 3f67f7
files_lock_filetrans(postgresql_t, postgresql_lock_t, file)
Chris PeBenito 17de1b
Chris PeBenito 0bfccd
manage_files_pattern(postgresql_t, postgresql_log_t, postgresql_log_t)
Chris PeBenito 0bfccd
logging_log_filetrans(postgresql_t, postgresql_log_t, { file dir })
Chris PeBenito 17de1b
Chris PeBenito 0bfccd
manage_dirs_pattern(postgresql_t, postgresql_tmp_t, postgresql_tmp_t)
Chris PeBenito 0bfccd
manage_files_pattern(postgresql_t, postgresql_tmp_t, postgresql_tmp_t)
Chris PeBenito 0bfccd
manage_lnk_files_pattern(postgresql_t, postgresql_tmp_t, postgresql_tmp_t)
Chris PeBenito 0bfccd
manage_fifo_files_pattern(postgresql_t, postgresql_tmp_t, postgresql_tmp_t)
Chris PeBenito 0bfccd
manage_sock_files_pattern(postgresql_t, postgresql_tmp_t, postgresql_tmp_t)
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 0bfccd
manage_files_pattern(postgresql_t, postgresql_var_run_t, postgresql_var_run_t)
Chris PeBenito 0bfccd
manage_sock_files_pattern(postgresql_t, postgresql_var_run_t, postgresql_var_run_t)
Chris PeBenito 0bfccd
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 190066
corenet_all_recvfrom_unlabeled(postgresql_t)
Chris PeBenito 190066
corenet_all_recvfrom_netlabel(postgresql_t)
Chris PeBenito 668b30
corenet_tcp_sendrecv_generic_if(postgresql_t)
Chris PeBenito 668b30
corenet_udp_sendrecv_generic_if(postgresql_t)
Chris PeBenito c12621
corenet_tcp_sendrecv_generic_node(postgresql_t)
Chris PeBenito c12621
corenet_udp_sendrecv_generic_node(postgresql_t)
Chris PeBenito 17de1b
corenet_tcp_sendrecv_all_ports(postgresql_t)
Chris PeBenito 17de1b
corenet_udp_sendrecv_all_ports(postgresql_t)
Jeremy Solt 9681df
corenet_udp_bind_generic_node(postgresql_t)
Chris PeBenito c12621
corenet_tcp_bind_generic_node(postgresql_t)
Chris PeBenito 17de1b
corenet_tcp_bind_postgresql_port(postgresql_t)
Chris PeBenito 17de1b
corenet_tcp_connect_auth_port(postgresql_t)
Jeremy Solt 9681df
corenet_tcp_connect_postgresql_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 770c01
fs_rw_hugetlbfs_files(postgresql_t)
Chris PeBenito 17de1b
Chris PeBenito e8cb08
selinux_get_enforce_mode(postgresql_t)
Chris PeBenito e8cb08
selinux_validate_context(postgresql_t)
Chris PeBenito e8cb08
selinux_compute_access_vector(postgresql_t)
Chris PeBenito e8cb08
selinux_compute_create_context(postgresql_t)
Chris PeBenito e8cb08
selinux_compute_relabel_context(postgresql_t)
Chris PeBenito e8cb08
Chris PeBenito 17de1b
term_use_controlling_term(postgresql_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
corecmd_exec_bin(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
Jeremy Solt 9681df
auth_use_pam(postgresql_t)
Chris PeBenito 09e216
Chris PeBenito 17de1b
init_read_utmp(postgresql_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
logging_send_syslog_msg(postgresql_t)
Jeremy Solt 9681df
logging_send_audit_msgs(postgresql_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
miscfiles_read_localization(postgresql_t)
Chris PeBenito 17de1b
Chris PeBenito e8cb08
seutil_libselinux_linked(postgresql_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
userdom_dontaudit_use_unpriv_user_fds(postgresql_t)
Chris PeBenito 296273
userdom_dontaudit_search_user_home_dirs(postgresql_t)
Chris PeBenito 296273
userdom_dontaudit_use_user_terminals(postgresql_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
mta_getattr_spool(postgresql_t)
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 3f67f7
	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 0b6aca
	ipsec_match_default_spd(postgresql_t)
Chris PeBenito 0b6aca
')
Chris PeBenito 0b6aca
Chris PeBenito 0b6aca
optional_policy(`
Chris PeBenito 17de1b
	kerberos_use(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 e8cb08
Chris PeBenito e8cb08
########################################
Chris PeBenito e8cb08
#
Chris PeBenito e8cb08
# Rules common to all clients
Chris PeBenito e8cb08
#
Chris PeBenito e8cb08
Chris PeBenito e8cb08
allow sepgsql_client_type sepgsql_db_t:db_database { getattr access get_param set_param };
Chris PeBenito e8cb08
type_transition sepgsql_client_type sepgsql_client_type:db_database sepgsql_db_t;
Chris PeBenito e8cb08
Chris PeBenito 350ed8
allow sepgsql_client_type sepgsql_fixed_table_t:db_table { getattr use select insert lock };
Chris PeBenito e8cb08
allow sepgsql_client_type sepgsql_fixed_table_t:db_column { getattr use select insert };
Chris PeBenito e8cb08
allow sepgsql_client_type sepgsql_fixed_table_t:db_tuple { use select insert };
Chris PeBenito e8cb08
Chris PeBenito 350ed8
allow sepgsql_client_type sepgsql_table_t:db_table { getattr use select update insert delete lock };
Chris PeBenito e8cb08
allow sepgsql_client_type sepgsql_table_t:db_column { getattr use select update insert };
Chris PeBenito e8cb08
allow sepgsql_client_type sepgsql_table_t:db_tuple { use select update insert delete };
Chris PeBenito e8cb08
Chris PeBenito 350ed8
allow sepgsql_client_type sepgsql_ro_table_t:db_table { getattr use select lock };
Chris PeBenito e8cb08
allow sepgsql_client_type sepgsql_ro_table_t:db_column { getattr use select };
Chris PeBenito e8cb08
allow sepgsql_client_type sepgsql_ro_table_t:db_tuple { use select };
Chris PeBenito e8cb08
Chris PeBenito e8cb08
allow sepgsql_client_type sepgsql_secret_table_t:db_table getattr;
Chris PeBenito e8cb08
allow sepgsql_client_type sepgsql_secret_table_t:db_column getattr;
Chris PeBenito e8cb08
Chris PeBenito 350ed8
allow sepgsql_client_type sepgsql_sysobj_t:db_table { getattr use select lock };
Chris PeBenito e8cb08
allow sepgsql_client_type sepgsql_sysobj_t:db_column { getattr use select };
Chris PeBenito e8cb08
allow sepgsql_client_type sepgsql_sysobj_t:db_tuple { use select };
Chris PeBenito e8cb08
Chris PeBenito 350ed8
allow sepgsql_client_type sepgsql_proc_exec_t:db_procedure { getattr execute install };
Chris PeBenito 350ed8
allow sepgsql_client_type sepgsql_trusted_proc_exec_t:db_procedure { getattr execute entrypoint };
Chris PeBenito e8cb08
Chris PeBenito e8cb08
allow sepgsql_client_type sepgsql_blob_t:db_blob { create drop getattr setattr read write };
Chris PeBenito e8cb08
allow sepgsql_client_type sepgsql_ro_blob_t:db_blob { getattr read };
Chris PeBenito e8cb08
allow sepgsql_client_type sepgsql_secret_blob_t:db_blob getattr;
Chris PeBenito e8cb08
Chris PeBenito e8cb08
# The purpose of the dontaudit rule in row-level access control is to prevent a flood of logs.
Chris PeBenito e8cb08
# If a client tries to SELECT a table including violated tuples, these are filtered from
Chris PeBenito e8cb08
# the result set as if not exist, but its access denied longs can be recorded within log files.
Chris PeBenito e8cb08
# In generally, the number of tuples are much larger than the number of columns, tables and so on.
Chris PeBenito e8cb08
# So, it makes a flood of logs when many tuples are violated.
Chris PeBenito e8cb08
#
Chris PeBenito e8cb08
# The default policy does not prevent anything for sepgsql_client_type sepgsql_unconfined_type,
Chris PeBenito e8cb08
# so we don't need "dontaudit" rules in Type-Enforcement. However, MLS/MCS can prevent them
Chris PeBenito e8cb08
# to access classified tuples and can make a audit record.
Chris PeBenito e8cb08
#
Chris PeBenito e8cb08
# Therefore, the following rule is applied for any domains which can connect SE-PostgreSQL.
Chris PeBenito 22a287
dontaudit { postgresql_t sepgsql_admin_type sepgsql_client_type sepgsql_unconfined_type } { sepgsql_table_type -sepgsql_sysobj_table_type }:db_tuple { use select update insert delete };
Chris PeBenito 22a287
Chris PeBenito 22a287
Chris PeBenito 22a287
########################################
Chris PeBenito 22a287
#
Chris PeBenito 22a287
# Rules common to administrator clients
Chris PeBenito 22a287
#
Chris PeBenito 22a287
Chris PeBenito 22a287
allow sepgsql_admin_type sepgsql_database_type:db_database { create drop getattr setattr relabelfrom relabelto access };
Chris PeBenito 22a287
type_transition sepgsql_admin_type sepgsql_admin_type:db_database sepgsql_db_t;
Chris PeBenito 22a287
Chris PeBenito 22a287
allow sepgsql_admin_type sepgsql_table_type:db_table { create drop getattr setattr relabelfrom relabelto lock };
Chris PeBenito 22a287
allow sepgsql_admin_type sepgsql_table_type:db_column { create drop getattr setattr relabelfrom relabelto };
Chris PeBenito 22a287
allow sepgsql_admin_type sepgsql_sysobj_table_type:db_tuple { relabelfrom relabelto select update insert delete };
Chris PeBenito 22a287
KaiGai Kohei ec8d32
type_transition sepgsql_admin_type sepgsql_database_type:db_table sepgsql_table_t;
KaiGai Kohei ec8d32
Chris PeBenito 22a287
allow sepgsql_admin_type sepgsql_procedure_type:db_procedure { create drop getattr relabelfrom relabelto };
KaiGai Kohei ec8d32
allow sepgsql_admin_type sepgsql_proc_exec_t:db_procedure execute;
KaiGai Kohei ec8d32
KaiGai Kohei ec8d32
type_transition sepgsql_admin_type sepgsql_database_type:db_procedure sepgsql_proc_exec_t;
Chris PeBenito 22a287
Chris PeBenito 22a287
allow sepgsql_admin_type sepgsql_blob_type:db_blob { create drop getattr setattr relabelfrom relabelto };
Chris PeBenito 22a287
KaiGai Kohei ec8d32
type_transition sepgsql_admin_type sepgsql_database_type:db_blob sepgsql_blob_t;
KaiGai Kohei ec8d32
Chris PeBenito 22a287
allow sepgsql_admin_type sepgsql_module_type:db_database install_module;
Chris PeBenito 22a287
Chris PeBenito 22a287
kernel_relabelfrom_unlabeled_database(sepgsql_admin_type)
Chris PeBenito 22a287
Chris PeBenito 22a287
tunable_policy(`sepgsql_unconfined_dbadm',`
Chris PeBenito 22a287
	allow sepgsql_admin_type sepgsql_database_type:db_database *;
Chris PeBenito 22a287
Chris PeBenito 22a287
	allow sepgsql_admin_type sepgsql_table_type:{ db_table db_column db_tuple } *;
Chris PeBenito 22a287
Chris PeBenito 22a287
	allow sepgsql_admin_type sepgsql_proc_exec_t:db_procedure *;
Chris PeBenito 22a287
	allow sepgsql_admin_type sepgsql_trusted_proc_exec_t:db_procedure ~install;
Chris PeBenito 22a287
	allow sepgsql_admin_type sepgsql_procedure_type:db_procedure ~{ execute install };
Chris PeBenito 22a287
Chris PeBenito 22a287
	allow sepgsql_admin_type sepgsql_blob_type:db_blob *;
Chris PeBenito 22a287
')
Chris PeBenito e8cb08
Chris PeBenito e8cb08
########################################
Chris PeBenito e8cb08
#
Chris PeBenito e8cb08
# Unconfined access to this module
Chris PeBenito e8cb08
#
Chris PeBenito e8cb08
Chris PeBenito e8cb08
allow sepgsql_unconfined_type sepgsql_database_type:db_database *;
Chris PeBenito e8cb08
type_transition sepgsql_unconfined_type sepgsql_unconfined_type:db_database sepgsql_db_t;
Chris PeBenito e8cb08
Chris PeBenito e8cb08
type_transition sepgsql_unconfined_type sepgsql_database_type:db_table sepgsql_table_t;
Chris PeBenito 350ed8
type_transition sepgsql_unconfined_type sepgsql_database_type:db_procedure sepgsql_proc_exec_t;
Chris PeBenito e8cb08
type_transition sepgsql_unconfined_type sepgsql_database_type:db_blob sepgsql_blob_t;
Chris PeBenito e8cb08
Chris PeBenito e8cb08
allow sepgsql_unconfined_type sepgsql_table_type:{ db_table db_column db_tuple } *;
Chris PeBenito e8cb08
Chris PeBenito e8cb08
# unconfined domain is not allowed to invoke user defined procedure directly.
Chris PeBenito e8cb08
# They have to confirm and relabel it at first.
Chris PeBenito 350ed8
allow sepgsql_unconfined_type sepgsql_proc_exec_t:db_procedure *;
Chris PeBenito 350ed8
allow sepgsql_unconfined_type sepgsql_trusted_proc_exec_t:db_procedure ~install;
Chris PeBenito 350ed8
allow sepgsql_unconfined_type sepgsql_procedure_type:db_procedure ~{ execute install };
Chris PeBenito e8cb08
Chris PeBenito e8cb08
allow sepgsql_unconfined_type sepgsql_blob_type:db_blob *;
Chris PeBenito e8cb08
Chris PeBenito e8cb08
allow sepgsql_unconfined_type sepgsql_module_type:db_database install_module;
Chris PeBenito e8cb08
Chris PeBenito e8cb08
kernel_relabelfrom_unlabeled_database(sepgsql_unconfined_type)