Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 49279 - postgresql policy files
Summary: postgresql policy files
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Hardened (show other bugs)
Hardware: All All
: High normal (vote)
Assignee: petre rodan (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-04-28 07:11 UTC by petre rodan (RETIRED)
Modified: 2007-09-22 23:17 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
file_contexts (postgresql.fc,3.24 KB, text/plain)
2004-04-28 07:12 UTC, petre rodan (RETIRED)
Details
type enforcement (postgresql.te,3.14 KB, text/plain)
2004-04-28 07:13 UTC, petre rodan (RETIRED)
Details
type enforcement (postgresql.te,3.29 KB, text/plain)
2004-09-24 11:10 UTC, petre rodan (RETIRED)
Details

Note You need to log in before you can comment on or make changes to this bug.
Description petre rodan (RETIRED) gentoo-dev 2004-04-28 07:11:33 UTC
Chris, please advise me how to overcome a small problem here.

postgresql is started like this:

start() {
        checkconfig || return 1

        ebegin "Starting PostgreSQL"
        if [ -f $PGDATA/postmaster.pid ]; then
                rm $PGDATA/postmaster.pid
        fi
        su - $PGUSER -c "/usr/bin/pg_ctl start -D '$PGDATA' -s -l '$PGLOG' -o '$PGOPTS'"


is there a documented way of using su - from initrc_t? 

I've tried with su_restricted_domain(initrc, system), but I got in a dark corner given by:

security_compute_sid:  invalid context system_u:system_r:initrc_su_t for scontext=system_u:system_r:initrc_t tcontext=system_u:object_r:su_exec_t tclass=process

avc:  denied  { read write } for  pid=14418 exe=/bin/su path=/dev/pts/0 dev=00:06 ino=2 scontext=system_u:system_r:initrc_su_t tcontext=prodan:object_r:sysadm_devpts_t tclass=chr_file

avc:  denied  { ioctl } for  pid=14418 exe=/bin/su path=/dev/pts/0 dev=00:06 ino=2 scontext=system_u:system_r:initrc_su_t tcontext=prodan:object_r:sysadm_devpts_t tclass=chr_file

avc:  denied  { search } for  pid=14418 exe=/bin/su name=postgresql dev=08:08 ino=129451 scontext=system_u:system_r:initrc_su_t tcontext=system_u:object_r:postgresql_db_t tclass=dir

avc:  denied  { sigchld } for  pid=14418 exe=/bin/su scontext=system_u:system_r:postgresql_t tcontext=system_u:system_r:initrc_su_t tclass=process

avc:  denied  { sigchld } for  pid=14418 exe=/bin/su scontext=system_u:system_r:postgresql_t tcontext=system_u:system_r:initrc_su_t tclass=process



tested with postgresql-7.4.x for a few weeks in a permissive environment.
Comment 1 petre rodan (RETIRED) gentoo-dev 2004-04-28 07:12:49 UTC
Created attachment 30237 [details]
file_contexts
Comment 2 petre rodan (RETIRED) gentoo-dev 2004-04-28 07:13:43 UTC
Created attachment 30239 [details]
type enforcement
Comment 3 Chris PeBenito (RETIRED) gentoo-dev 2004-07-03 13:27:23 UTC
I'm not sure about this one, I haven't done anything special with su.  It seems like you might need this:

role system_r types initrc_su_t;
Comment 4 Ciprian Ciubotariu 2004-09-22 15:20:56 UTC
Hello. I added this to the .te, for obvious reasons:

# if postgresql is configured to dump through syslogd to /var/log/postgresql.log
allow syslogd_t postgresql_log_t:file rw_file_perms;

C-MoH
Comment 5 Ciprian Ciubotariu 2004-09-22 15:37:53 UTC
About the startup/shutdown of postgres... i've typed this at the bottom of the policy and it worked:

su_restricted_domain(initrc, system)
role system_r types initrc_su_t;
allow initrc_su_t sysadm_devpts_t:chr_file { read write ioctl };
allow initrc_su_t postgresql_db_t:dir { search };
allow postgresql_t initrc_su_t:process sigchld;

C-MoH
Comment 6 petre rodan (RETIRED) gentoo-dev 2004-09-24 11:10:27 UTC
Created attachment 40311 [details]
type enforcement

the cvs version of selinux-base-policy has all ingredients needed for the init
script to run su.

if you have the currently stable  policy you will have to add

#
#  These rules are here to allow init scripts to su
#
ifdef(`su.te', `
su_restricted_domain(initrc,system)
role system_r types initrc_su_t;
')
allow initrc_t self:passwd rootok;

to a cutom .te until the cvs version will be rolled to stable.
Comment 7 petre rodan (RETIRED) gentoo-dev 2004-10-08 04:28:18 UTC
in cvs