Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1490956

Summary: PostgreSQL fails to start under SELinux MLS
Product: Red Hat Enterprise Linux 7 Reporter: Dustin C. Hatch <dustin>
Component: selinux-policyAssignee: Lukas Vrabec <lvrabec>
Status: CLOSED ERRATA QA Contact: Milos Malik <mmalik>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.3CC: lvrabec, mgrepl, mmalik, plautrba, ssekidde
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: selinux-policy-3.13.1-175.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-04-10 12:42:01 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Dustin C. Hatch 2017-09-12 15:04:28 UTC
Description of problem:
When the system is using the MSL SELinux policy, the postgresql.service unit fails to start:

ExecStartPre=/usr/bin/postgresql-check-db-dir ${PGDATA} (code=exited, status=1/FAILURE)

The problem is this AVC:

type=AVC msg=audit(1505225522.279:9675648): avc:  denied  { getattr } for  pid=14486 comm="postgresql-chec" path="/var/lib/pgsql/data/PG_VERSION" dev="dm-0" ino=135 scontext=system_u:system_r:init_t:s0-s15:c0.c1023 tcontext=system_u:object_r:postgresql_db_t:s0 tclass=file

Version-Release number of selected component (if applicable):
postgresql-9.2.18-1.el7.x86_64
selinux-policy-mls-3.13.1-102.el7_3.16.noarch

How reproducible:
Always


Steps to Reproduce:
1. Enable SELinux MLS
2. Start postgresql.service

Actual results:
PostgreSQL fails to start because postgresql-check-db-dir does not run

Expected results:
postgresql-check-db-dir should execute successfully even under SELinux MLS, and postgresql should start

Additional info:
Fixing this problem is trivial:
chcon -t postgresql_exec_t /usr/bin/postgresql-check-db-dir

Comment 3 Milos Malik 2018-02-14 09:34:37 UTC
# sestatus 
SELinux status:                 enabled
SELinuxfs mount:                /sys/fs/selinux
SELinux root directory:         /etc/selinux
Loaded policy name:             mls
Current mode:                   enforcing
Mode from config file:          permissive
Policy MLS status:              enabled
Policy deny_unknown status:     denied
Max kernel policy version:      31
# service postgresql start
Redirecting to /bin/systemctl start postgresql.service
# ps -efZ | grep postgres
system_u:system_r:postgresql_t:s0-s15:c0.c1023 postgres 1746 1  0 04:31 ? 00:00:00 /usr/bin/postgres -D /var/lib/pgsql/data -p 5432
system_u:system_r:postgresql_t:s0-s15:c0.c1023 postgres 1747 1746  0 04:31 ? 00:00:00 postgres: logger process   
system_u:system_r:postgresql_t:s0-s15:c0.c1023 postgres 1749 1746  0 04:31 ? 00:00:00 postgres: checkpointer process   
system_u:system_r:postgresql_t:s0-s15:c0.c1023 postgres 1750 1746  0 04:31 ? 00:00:00 postgres: writer process   
system_u:system_r:postgresql_t:s0-s15:c0.c1023 postgres 1751 1746  0 04:31 ? 00:00:00 postgres: wal writer process   
system_u:system_r:postgresql_t:s0-s15:c0.c1023 postgres 1752 1746  0 04:31 ? 00:00:00 postgres: autovacuum launcher process   
system_u:system_r:postgresql_t:s0-s15:c0.c1023 postgres 1753 1746  0 04:31 ? 00:00:00 postgres: stats collector process   
root:sysadm_r:sysadm_t:s0       root      1756  1296  0 04:31 pts/0    00:00:00 grep --color=auto postgres
# matchpathcon /usr/bin/postgresql-check-db-dir 
/usr/bin/postgresql-check-db-dir	system_u:object_r:postgresql_exec_t:s0
# rpm -qa selinux-policy\* | sort
selinux-policy-3.13.1-189.el7.noarch
selinux-policy-mls-3.13.1-189.el7.noarch
selinux-policy-targeted-3.13.1-189.el7.noarch
#

Comment 7 errata-xmlrpc 2018-04-10 12:42:01 UTC
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.

https://access.redhat.com/errata/RHBA-2018:0763