Bug 698257 - named cannot update logs in chroot
named cannot update logs in chroot
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: selinux-policy (Show other bugs)
5.6
All Linux
medium Severity low
: rc
: ---
Assigned To: Miroslav Grepl
BaseOS QE Security Team
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2011-04-20 10:21 EDT by Orion Poplawski
Modified: 2012-10-15 10:51 EDT (History)
4 users (show)

See Also:
Fixed In Version: selinux-policy-2.4.6-306.el5
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2011-07-21 05:20:07 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Orion Poplawski 2011-04-20 10:21:27 EDT
Description of problem:

Running named in a chroot.  Have some additional logging enabled.  Getting:

type=AVC msg=audit(1303259145.889:20250): avc:  denied  { append } for  pid=5672 comm="named" name="update-debug.log" dev=dm-5 ino=935425 scontext=system_u:system_r:named_t:s0 tcontext=system_u:object_r:named_conf_t:s0 tclass=file

# ls -lZ /var/named/chroot/var/log
-rw-r--r--  named named system_u:object_r:named_log_t    named-auth.info
-rw-r--r--  named named system_u:object_r:named_conf_t   update-debug.log
# restorecon -r -v /var/named/chroot/var/log
#

Version-Release number of selected component (if applicable):
selinux-policy-2.4.6-300.el5
Comment 1 Daniel Walsh 2011-04-20 10:29:00 EDT
In Fedora we have

matchpathcon /var/named/chroot/var/log
/var/named/chroot/var/log	system_u:object_r:var_log_t:s0
Comment 2 Orion Poplawski 2011-04-20 10:44:45 EDT
But:

$ matchpathcon /var/named/chroot/var/log/blah
/var/named/chroot/var/log/blah  system_u:object_r:named_conf_t:s0

in fact, both seem the same in F15/EL5.

Looks like only /var/named/chroot/var/log/named* is marked named_log_t.  Seems like everything in /var/naemd/chroot/var/log/ should get marked that way though.
Comment 4 Miroslav Grepl 2011-05-19 11:28:03 EDT
Fixed in selinux-policy-2.4.6-306.el5
Comment 7 errata-xmlrpc 2011-07-21 05:20:07 EDT
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2011-1069.html
Comment 8 errata-xmlrpc 2011-07-21 07:56:37 EDT
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2011-1069.html
Comment 9 Brian Epstein 2011-08-11 17:03:52 EDT
We use the query.log for troubleshooting and ran into this error again.  We rotate the query logs and keep the last four.

        channel query {
                file "/var/log/query.log" size 10m versions 3;
                severity info;
                print-severity yes;
                print-time yes;
        };

[root@ns1 log]# pwd
/var/named/chroot/var/log
[root@ns1 log]# restorecon *
[root@ns1 log]# ls -laZ
drwxrwx---  named named system_u:object_r:var_log_t      .
drwxr-x---  root  named system_u:object_r:named_conf_t   ..
-rw-rw----  named named system_u:object_r:named_log_t    named.log
-rw-r--r--  named named system_u:object_r:named_log_t    query.log
-rw-r--r--  named named system_u:object_r:named_conf_t   query.log.0
-rw-r--r--  named named system_u:object_r:named_conf_t   query.log.1
-rw-r--r--  named named system_u:object_r:named_conf_t   query.log.2

The rule apparently looks for anything in that directory starting with named or anything ending in log.

[root@ns1 log]# semanage fcontext -l | grep named | grep log
/var/log/named.*                                   regular file       system_u:object_r:named_log_t:s0 
/var/named/chroot/var/log/(named.*|.*\.log)        regular file       system_u:object_r:named_log_t:s0 
/var/named/chroot/var/log                          directory          system_u:object_r:var_log_t:s0 

I put this in my /etc/selinux/targeted/contexts/files/file_contexts.local file

/var/named/chroot/var/log/(named.*|.*\.log.*)	system_u:object_r:named_log_t:s0

And then tried again.

[root@ns1 log]# pwd
/var/named/chroot/var/log
[root@ns1 log]# restorecon *
[root@ns1 log]# ls -laZ
drwxrwx---  named named system_u:object_r:var_log_t      .
drwxr-x---  root  named system_u:object_r:named_conf_t   ..
-rw-rw----  named named system_u:object_r:named_log_t    named.log
-rw-r--r--  named named system_u:object_r:named_log_t    query.log
-rw-r--r--  named named system_u:object_r:named_log_t    query.log.0
-rw-r--r--  named named system_u:object_r:named_log_t    query.log.1
-rw-r--r--  named named system_u:object_r:named_log_t    query.log.2

Seems to be much better.

Thanks,
Brian
Comment 10 Daniel Walsh 2011-08-29 13:01:08 EDT
RHEL6 we have

/var/named/chroot/var/log/named.*	--	gen_context(system_u:object_r:named_log_t,s0)

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