Skip to contentSkip to conversation

postmaster/postgres policy files

DISCUSSION A Almeida 2 participants 2 messages Aug 2, 2002 SELinux security module

lore
Share & tools
lore

A Almeida

author
#0 lore raw

Since the message quoted below was posted in February, has anyone written policy files for postgres/postmaster that you'd be willing to share?

If not, the thing to do seems to make a new label for the executable
postmaster (which is a symlink to postgres). It should be labelled
something like system_u:object_r:postgres_t instead of system_u:object_r:bin_t. Then, a TE file defining policy and transitioning initrc_t to postgres_t would be needed.

This seems to be the safe approach from studying the mail list. However, I'd not want to reinvent the wheel if someone has already written policy for postgres/postmaster.

If you have comments, thoughts, suggests, or would be willing to share an already written postmaster.te or postgres.te file, would be appreciated.

-Morgan

-- original message from Beth Meighan [email protected] --

The only dialogue I saw on this mail list about Postgres had ended with the Postgres system processes in initrc_t domain and the recommendation to move them into their own domain. Has anyone made domains and types for Postgres? If so, would you be willing to share your .te file and any other policy files you edited?

Thank you in advance,
Beth Meighan

_________________________________________________________________
Join the world�s largest e-mail service with MSN Hotmail. http://www.hotmail.com

--
You have received this message because you are subscribed to the selinux list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#1 lore raw
Quoted 2 lines · A Almeida

Since the message quoted below was posted in February, has anyone written policy files for postgres/postmaster that you'd be willing to share?

Yes, attached to this message. It's not finished, but it's probably easier than starting from nothing. Also you'll have to change your postgresql start scripts to not call su.

Quoted 5 lines

If not, the thing to do seems to make a new label for the executable postmaster (which is a symlink to postgres). It should be labelled something like system_u:object_r:postgres_t instead of system_u:object_r:bin_t. Then, a TE file defining policy and transitioning initrc_t to postgres_t would be needed.

Yes, use daemon_domain() for this.

Signature · 3 lines
I do not get viruses because I do not use MS software.
If you use Outlook then please do not put my email address in your
address-book so that WHEN you get a virus it won't use my address in the
Quoted 1 line

From field.

# postgresql - ldap server
/usr/lib/postgresql/bin/.*	system_u:object_r:postgresql_exec_t
/var/lib/postgres(|/.*)		system_u:object_r:postgresql_db_t
/var/run/postgresql(|/.*)	system_u:object_r:var_run_postgresql_t
/etc/postgresql(|/.*)		system_u:object_r:etc_postgresql_t
/var/log/postgres.log.*		system_u:object_r:postgresql_log_t

#
# Author: Russell Coker <[email protected]>
#

#################################
#
# Rules for the postgresql_t domain.
#

# postgresql_exec_t is the type of the postgresql executable.
#
daemon_domain(postgresql)
# gross hack
domain_auto_trans(dpkg_t, postgresql_exec_t, postgresql_t)
# a grosser hack
allow postgresql_t etc_t:file setattr;

auditdeny postgresql_t { sysadm_home_t var_spool_t }:dir ~search;

allow postgresql_t self:capability { dac_override dac_read_search chown fowner fsetid setuid setgid };

type etc_postgresql_t, file_type, sysadmfile;
type postgresql_db_t, file_type, sysadmfile;
type postgresql_log_t, file_type, sysadmfile;

file_type_auto_trans(postgresql_t, var_log_t, postgresql_log_t)

allow postgresql_t system_crond_script_t:file { getattr read };

tmp_domain(postgresql);
can_exec(postgresql_t, dpkg_exec_t)

# Use the network.
can_network(postgresql_t)
allow postgresql_t self:fifo_file { getattr read write ioctl }; allow postgresql_t self:unix_stream_socket create_socket_perms; allow postgresql_t self:unix_dgram_socket create_socket_perms;

# allow any domain to connect to the LDAP server
can_tcp_connect(domain, postgresql_t)

allow postgresql_t proc_t:file { getattr read };

# Allow access to the postgresql databases create_dir_file(postgresql_t, postgresql_db_t) allow postgresql_t var_lib_t:dir { getattr search };

# read config files
allow postgresql_t { etc_t etc_runtime_t }:{ file lnk_file } { read getattr };
r_dir_file(postgresql_t, etc_postgresql_t)

allow postgresql_t etc_t:dir rw_dir_perms;
allow postgresql_t etc_t:lnk_file create;

allow postgresql_t { sysctl_t sysctl_kernel_t }:dir search; allow postgresql_t sysctl_kernel_t:file read;

allow postgresql_t devtty_t:chr_file { read write }; allow postgresql_t devpts_t:dir search;

can_exec(postgresql_t, { postgresql_exec_t bin_t sbin_t ls_exec_t su_exec_t shell_exec_t etc_t }) allow postgresql_t { bin_t sbin_t }:dir search;
allow postgresql_t bin_t:lnk_file read;
allow postgresql_t postgresql_exec_t:lnk_file read;

allow postgresql_t initrc_var_run_t:file { read write lock };

allow postgresql_t self:sem rw_sem_perms;

allow postgresql_t self:udp_socket recvfrom; allow domain postgresql_t:unix_stream_socket connectto; allow domain var_run_postgresql_t:sock_file write;