Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 328297 - sec-policy/selinux-postgresql-2.20091215 doesn't label directories from split dev-db/postgresql-{base,docs,server} correctly
Summary: sec-policy/selinux-postgresql-2.20091215 doesn't label directories from split...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Hardened (show other bugs)
Hardware: All Linux
: High normal
Assignee: SE Linux Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-07-14 19:34 UTC by Karl-Johan Karlsson
Modified: 2011-06-03 09:22 UTC (History)
3 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Karl-Johan Karlsson 2010-07-14 19:34:39 UTC
sec-policy/selinux-postgresql-2.20091215 has the following file context rules for postgresql_exec_t:

/usr/bin/initdb(\.sepgsql)?     --      gen_context(system_u:object_r:postgresql_exec_t,s0)
/usr/bin/(se)?postgres          --      gen_context(system_u:object_r:postgresql_exec_t,s0)
/usr/lib/pgsql/test/regress/pg_regress -- gen_context(system_u:object_r:postgresql_exec_t,s0)
/usr/lib(64)?/postgresql/bin/.* --      gen_context(system_u:object_r:postgresql_exec_t,s0)
/usr/lib/postgresql/.*/bin/.*   --      gen_context(system_u:object_r:postgresql_exec_t,s0)

However, when using the split PostgreSQL ebuilds (tested here with dev-db/postgresql-server-8.2.17-r1), the binaries are actually installed in /usr/lib(64)?/postgresql-$VERSION/bin/, which is then not labeled with postgresql_exec_t, so the postgres processes run as initrc_t instead of postgresql_t.

I don't know much about SELinux, but I created a local module containing the following:

   postgresql-local # cat postgresql-local.fc
   /usr/lib(64)?/postgresql-.*/bin/.*      --      gen_context(system_u:object_r:postgresql_exec_t,s0)

and an empty .te file and it seems to work. I imagine adding that line to sec-policy/selinux-postgresql-2.20091215:{targeted,strict}/postgresql.fc will be the correct fix.

Reproducible: Always

Steps to Reproduce:
Comment 1 Sven Vermeulen 2011-02-13 16:00:25 UTC
There's a patch available in hardened-development overlay (cfr. http://git.overlays.gentoo.org/gitweb/?p=proj/hardened-dev.git;a=blob_plain;f=sec-policy/selinux-postgresql/files/fix-services-postgresql-r1.patch;hb=HEAD) which should at least help with this issue.
Comment 2 Sven Vermeulen 2011-03-11 18:06:02 UTC
The patch has been put in official Portage tree (still ~arch for the time being though).
Comment 3 Anthony Basile gentoo-dev 2011-06-03 09:22:05 UTC
This policy with the patch is now stable in the tree.