Bug 891860 - The /var/lib/pgsql/.*\.log rule is never used
Summary: The /var/lib/pgsql/.*\.log rule is never used
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Fedora
Classification: Fedora
Component: selinux-policy-targeted
Version: 16
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Miroslav Grepl
QA Contact: Ben Levenson
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-01-04 09:08 UTC by Jan Pazdziora (Red Hat)
Modified: 2013-01-20 03:13 UTC (History)
2 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2013-01-20 03:13:26 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Jan Pazdziora (Red Hat) 2013-01-04 09:08:21 UTC
Description of problem:

While working on investigation of bug 891547, I also checked Fedora 16 and I found it strange that the

restorecon -rvv /var/lib/pgsql/data/pg_log

does not report anything and that the log file stays of the type postgresql_db_t.

# ls -laZ /var/lib/pgsql/data/pg_log/
drwx------. postgres postgres unconfined_u:object_r:postgresql_db_t:s0 .
drwx------. postgres postgres system_u:object_r:postgresql_db_t:s0 ..
-rw-------. postgres postgres system_u:object_r:postgresql_db_t:s0 postgresql-Thu.log

I thought maybe the postgresql_log_t type is not there in Fedora at all, but grep showed otherwise:

# grep pgsql /etc/selinux/targeted/contexts/files/file_contexts | grep log
/var/lib/pgsql/.*\.log	system_u:object_r:postgresql_log_t:s0
/var/lib/pgsql/logfile(/.*)?	system_u:object_r:postgresql_log_t:s0
/var/lib/sepgsql/pgstartup\.log	--	system_u:object_r:postgresql_log_t:s0

Alas, there is also

/var/lib/pgsql/data(/.*)?	system_u:object_r:postgresql_db_t:s0

which presumably takes precedence.

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

# rpm -qf /etc/selinux/targeted/contexts/files/file_contexts
selinux-policy-targeted-3.10.0-96.fc16.noarch

How reproducible:

Deterministic.

Steps to Reproduce:
1. ls -laZ /var/lib/pgsql/data/pg_log
2. restorecon -rvv /var/lib/pgsql/data/pg_log
3. ls -laZ /var/lib/pgsql/data/pg_log
  
Actual results:

# ls -laZ /var/lib/pgsql/data/pg_log
drwx------. postgres postgres unconfined_u:object_r:postgresql_db_t:s0 .
drwx------. postgres postgres system_u:object_r:postgresql_db_t:s0 ..
-rw-------. postgres postgres system_u:object_r:postgresql_db_t:s0 postgresql-Thu.log
# restorecon -rvv /var/lib/pgsql/data/pg_log
# ls -laZ /var/lib/pgsql/data/pg_log
drwx------. postgres postgres unconfined_u:object_r:postgresql_db_t:s0 .
drwx------. postgres postgres system_u:object_r:postgresql_db_t:s0 ..
-rw-------. postgres postgres system_u:object_r:postgresql_db_t:s0 postgresql-Thu.log
#

Expected results:

# ls -laZ /var/lib/pgsql/data/pg_log
drwx------. postgres postgres unconfined_u:object_r:postgresql_db_t:s0 .
drwx------. postgres postgres system_u:object_r:postgresql_db_t:s0 ..
-rw-------. postgres postgres system_u:object_r:postgresql_db_t:s0 postgresql-Thu.log
# restorecon -rvv /var/lib/pgsql/data/pg_log
restorecon reset /var/lib/pgsql/data/pg_log/postgresql-Thu.log context system_u:object_r:postgresql_db_t:s0->system_u:object_r:postgresql_log_t:s0
# ls -laZ /var/lib/pgsql/data/pg_log
drwx------. postgres postgres unconfined_u:object_r:postgresql_db_t:s0 .
drwx------. postgres postgres system_u:object_r:postgresql_db_t:s0 ..
-rw-------. postgres postgres system_u:object_r:postgresql_log_t:s0 postgresql-Thu.log
#

or

# ls -laZ /var/lib/pgsql/data/pg_log
drwx------. postgres postgres unconfined_u:object_r:postgresql_db_t:s0 .
drwx------. postgres postgres system_u:object_r:postgresql_db_t:s0 ..
-rw-------. postgres postgres system_u:object_r:postgresql_db_t:s0 postgresql-Thu.log
# restorecon -rvv /var/lib/pgsql/data/pg_log
restorecon reset /var/lib/pgsql/data/pg_log context system_u:object_r:postgresql_db_t:s0->system_u:object_r:postgresql_log_t:s0
restorecon reset /var/lib/pgsql/data/pg_log/postgresql-Thu.log context system_u:object_r:postgresql_db_t:s0->system_u:object_r:postgresql_log_t:s0
# ls -laZ /var/lib/pgsql/data/pg_log
drwx------. postgres postgres unconfined_u:object_r:postgresql_log_t:s0 .
drwx------. postgres postgres system_u:object_r:postgresql_db_t:s0 ..
-rw-------. postgres postgres system_u:object_r:postgresql_log_t:s0 postgresql-Thu.log
#

Additional info:

Comment 1 Miroslav Grepl 2013-01-04 13:23:45 UTC
Added fixes from F18.

commit 222eed0a61307b58c91aeb4f58041fe84f86af53
Author: Miroslav Grepl <mgrepl>
Date:   Fri Jan 4 09:27:48 2013 +0100

    Add interface for postgesql_filetrans_name_content to make sure log directories get created with the correct label.

Comment 2 Fedora Update System 2013-01-04 18:32:18 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 3 Fedora Update System 2013-01-05 06:47:54 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 4 Fedora End Of Life 2013-01-17 02:12:00 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 5 Jan Pazdziora (Red Hat) 2013-01-17 13:02:43 UTC
# ls -laZ /var/lib/pgsql/data/pg_log
drwx------. postgres postgres unconfined_u:object_r:postgresql_log_t:s0 .
drwx------. postgres postgres system_u:object_r:postgresql_db_t:s0 ..
-rw-------. postgres postgres system_u:object_r:postgresql_log_t:s0 postgresql-Thu.log

VERIFIED.

Comment 6 Miroslav Grepl 2013-01-17 22:06:05 UTC
Thank you for testing.

Comment 7 Fedora Update System 2013-01-20 03:13:28 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.


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