Bug 880100

Summary: After upgrade to F16, with unconfined off, can't start postgres
Product: [Fedora] Fedora Reporter: Robin Powell <rlpowell>
Component: selinux-policyAssignee: Miroslav Grepl <mgrepl>
Status: CLOSED CURRENTRELEASE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 16CC: dominick.grift, dwalsh, mgrepl
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-01-20 03:13:36 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 Robin Powell 2012-11-26 09:19:52 UTC
I believe the following will be all the info you need; let me know if not.

-Robin

----
time->Mon Nov 26 01:16:46 2012
type=PATH msg=audit(1353921406.748:8282): item=0 name=(null) inode=137007 dev=fc:02 mode=0140777 ouid=26 ogid=26 rdev=00:00 obj=system_u:object_r:postgresql_tmp_t:s0
type=SOCKADDR msg=audit(1353921406.748:8282): saddr=01002F746D702F2E732E504753514C2E35343332000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
type=SYSCALL msg=audit(1353921406.748:8282): arch=c000003e syscall=42 success=yes exit=0 a0=3 a1=ee4020 a2=6e a3=0 items=1 ppid=1 pid=7813 auid=4294967295 uid=26 gid=26 euid=26 suid=26 fsuid=26 egid=26 sgid=26 fsgid=26 tty=(none) ses=4294967295 comm="pg_ctl" exe="/usr/bin/pg_ctl" subj=system_u:system_r:initrc_t:s0 key=(null)
type=AVC msg=audit(1353921406.748:8282): avc:  denied  { connectto } for  pid=7813 comm="pg_ctl" path="/tmp/.s.PGSQL.5432" scontext=system_u:system_r:initrc_t:s0 tcontext=system_u:system_r:postgresql_t:s0 tclass=unix_stream_socket
type=AVC msg=audit(1353921406.748:8282): avc:  denied  { write } for  pid=7813 comm="pg_ctl" name=".s.PGSQL.5432" dev="vda2" ino=137007 scontext=system_u:system_r:initrc_t:s0 tcontext=system_u:object_r:postgresql_tmp_t:s0 tclass=sock_file
----
time->Mon Nov 26 01:16:45 2012
type=PATH msg=audit(1353921405.746:8262): item=0 name=(null) inode=137007 dev=fc:02 mode=0140777 ouid=26 ogid=26 rdev=00:00 obj=system_u:object_r:postgresql_tmp_t:s0
type=SOCKADDR msg=audit(1353921405.746:8262): saddr=01002F746D702F2E732E504753514C2E35343332000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
type=SYSCALL msg=audit(1353921405.746:8262): arch=c000003e syscall=42 success=no exit=-13 a0=3 a1=ee4020 a2=6e a3=0 items=1 ppid=1 pid=7813 auid=4294967295 uid=26 gid=26 euid=26 suid=26 fsuid=26 egid=26 sgid=26 fsgid=26 tty=(none) ses=4294967295 comm="pg_ctl" exe="/usr/bin/pg_ctl" subj=system_u:system_r:initrc_t:s0 key=(null)
type=AVC msg=audit(1353921405.746:8262): avc:  denied  { write } for  pid=7813 comm="pg_ctl" name=".s.PGSQL.5432" dev="vda2" ino=137007 scontext=system_u:system_r:initrc_t:s0 tcontext=system_u:object_r:postgresql_tmp_t:s0 tclass=sock_file


rlpowell@morji> sudo ls -lZ /tmp/.s.PGSQL.5432.lock /tmp/.s.PGSQL.5432
srwxrwxrwx. postgres postgres system_u:object_r:postgresql_tmp_t:s0 /tmp/.s.PGSQL.5432
-rw-------. postgres postgres system_u:object_r:postgresql_tmp_t:s0 /tmp/.s.PGSQL.5432.lock

rlpowell@morji> sudo ausearch -m avc -ts recent | grep AVC | audit2allow


#============= initrc_t ==============
allow initrc_t postgresql_t:unix_stream_socket connectto;
allow initrc_t postgresql_tmp_t:sock_file write;

Comment 1 Robin Powell 2012-11-26 09:21:51 UTC
Oh, yes: what I was actually trying to run was:

systemctl start postgresql.service

Comment 2 Miroslav Grepl 2012-11-26 14:29:22 UTC
Any chance you get anything from

# systemctl restart postgresql.service
# ps -eZ |grep initrc

Comment 3 Robin Powell 2012-11-26 19:09:02 UTC
Well, that command never returns without those fixes (well, it does, but it takes like 5+ minutes and it fails), so I'll be running those two commands in separate windows.  Which I'm sure is fine, but just to be clear.

system_u:system_r:initrc_t:s0   postgres 18701  0.0  0.0 169504  1716 ?        Ss   11:07   0:00 /usr/bin/pg_ctl start -D /var/lib/pgsql/data -s -o -p 5432 -w -t 300


(ps afuxZ, actually, but should have everything you need)

-Robin

Comment 4 Miroslav Grepl 2012-11-28 14:07:00 UTC
What does

# rpm -qf /usr/bin/pg_ctl

If you change the labeling to 

chcon -t postgresql_exec_t /usr/bin/pg_ctl

does it help?

Comment 5 Robin Powell 2012-11-29 11:40:12 UTC
rlpowell@morji> sudo rpm -qf /usr/bin/pg_ctl
postgresql-server-9.1.6-1.fc17.x86_64

And that change seems to do the trick!

-Robin

Comment 6 Miroslav Grepl 2012-12-10 10:15:18 UTC
I added labeling. Thank you for testing.

Comment 7 Fedora Update System 2013-01-04 18:32:24 UTC
selinux-policy-3.10.0-98.fc16 has been submitted as an update for Fedora 16.
https://admin.fedoraproject.org/updates/selinux-policy-3.10.0-98.fc16

Comment 8 Fedora Update System 2013-01-05 06:48:02 UTC
Package selinux-policy-3.10.0-98.fc16:
* should fix your issue,
* was pushed to the Fedora 16 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing selinux-policy-3.10.0-98.fc16'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2013-0230/selinux-policy-3.10.0-98.fc16
then log in and leave karma (feedback).

Comment 9 Fedora End Of Life 2013-01-17 02:11:48 UTC
This message is a reminder that Fedora 16 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 16. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as WONTFIX if it remains open with a Fedora 
'version' of '16'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version prior to Fedora 16's end of life.

Bug Reporter: Thank you for reporting this issue and we are sorry that 
we may not be able to fix it before Fedora 16 is end of life. If you 
would still like to see this bug fixed and are able to reproduce it 
against a later version of Fedora, you are encouraged to click on 
"Clone This Bug" and open it against that version of Fedora.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

The process we are following is described here: 
http://fedoraproject.org/wiki/BugZappers/HouseKeeping

Comment 10 Fedora Update System 2013-01-20 03:13:38 UTC
selinux-policy-3.10.0-98.fc16 has been pushed to the Fedora 16 stable repository.  If problems still persist, please make note of it in this bug report.