Bug 1282543 - Confined users cannot run postgresql-setup
Confined users cannot run postgresql-setup
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: selinux-policy (Show other bugs)
All Linux
medium Severity medium
: rc
: ---
Assigned To: Lukas Vrabec
Jan Zarsky
: FutureFeature
Depends On:
  Show dependency treegraph
Reported: 2015-11-16 12:18 EST by Dustin C. Hatch
Modified: 2016-11-03 22:24 EDT (History)
8 users (show)

See Also:
Fixed In Version: selinux-policy-3.13.1-81.el7
Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2016-11-03 22:24:36 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Dustin C. Hatch 2015-11-16 12:18:26 EST
Description of problem:
SELinux prevents confined users from initializing a PostgreSQL instance. It seems there is nothing in the policy that allows users to execute files labeled postgresql_exec_t.

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
1. semanage login -a -s staff_u user
2. yum install postgresql-server
3. sudo -r sysadm_r postgresql-setup

Actual results:
SELinux prevents the user from executing /usr/bin/initdb

Expected results:
The user should be allowed to execute initdb in order to create the database instance.

Additional info:
[root@c7-264e57 ~]# semanage login -l

Login Name           SELinux User         MLS/MCS Range        Service

__default__          unconfined_u         s0-s0:c0.c1023       *
user                 staff_u              s0-s0:c0.c1023       *
root                 unconfined_u         s0-s0:c0.c1023       *
system_u             system_u             s0-s0:c0.c1023       *

[user@c7-264e57 ~]$ id -Z
[user@c7-264e57 ~]$ sudo id -Z
[user@c7-264e57 ~]$ sudo -r sysadm_r id -Z
[user@c7-264e57 ~]$ sudo postgresql-setup initdb
Failed to issue method call: Access denied
failed to find PGDATA setting in postgresql.service
[user@c7-264e57 ~]$ sudo -r sysadm_r postgresql-setup initdb
Initializing database ... failed, see /var/lib/pgsql/initdb.log

[user@c7-264e57 ~]$ sudo -r sysadm_r cat /var/lib/pgsql/initdb.log
-bash: /usr/bin/initdb: Permission denied

Note: No AVC denial is logged unless "don't audit" is disabled (i.e. `semodule -DB`). Afterward, this denial is logged:

type=AVC msg=audit(1447694151.916:305): avc:  denied  { execute } for  pid=1258 comm="bash" name="initdb" dev="dm-1" ino=25684747 scontext=staff_u:sysadm_r:sysadm_t:s0-s0:c0.c1023 tcontext=system_u:object_r:postgresql_exec_t:s0 tclass=file
Comment 7 errata-xmlrpc 2016-11-03 22:24:36 EDT
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.


Note You need to log in before you can comment on or make changes to this bug.