Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
For bugs related to Red Hat Enterprise Linux 5 product line. The current stable release is 5.10. For Red Hat Enterprise Linux 6 and above, please visit Red Hat JIRA https://issues.redhat.com/secure/CreateIssue!default.jspa?pid=12332745 to report new issues.

Bug 502190

Summary: SELinux is preventing perl (logwatch_t) "write" to ./services (etc_t).
Product: Red Hat Enterprise Linux 5 Reporter: Jay Turner <jturner>
Component: dmraidAssignee: LVM and device-mapper development team <lvm-team>
Status: CLOSED DUPLICATE QA Contact: Cluster QE <mspqa-list>
Severity: high Docs Contact:
Priority: medium    
Version: 5.4CC: agk, dwysocha, heinzm, mbroz, prockai, srevivo, syeghiay
Target Milestone: rcKeywords: Regression
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2009-06-11 10:56:09 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
'rpm -qa --last' output none

Description Jay Turner 2009-05-22 13:23:29 UTC
Description of problem:
Got the following in syslog after updating to dmraid-1.0.0.rc13-45.el5:

# sealert -l 6281ed61-5765-4149-bbf7-9a08d6c5db52

Summary:

SELinux is preventing perl (logwatch_t) "write" to ./services (etc_t).

Detailed Description:

SELinux is preventing perl (logwatch_t) "write" to ./services (etc_t). The
SELinux type etc_t, is a generic type for all files in the directory and very
few processes (SELinux Domains) are allowed to write to this SELinux type. This
type of denial usual indicates a mislabeled file. By default a file created in a
directory has the gets the context of the parent directory, but SELinux policy
has rules about the creation of directories, that say if a process running in
one SELinux Domain (D1) creates a file in a directory with a particular SELinux
File Context (F1) the file gets a different File Context (F2). The policy
usually allows the SELinux Domain (D1) the ability to write, unlink, and append
on (F2). But if for some reason a file (./services) was created with the wrong
context, this domain will be denied. The usual solution to this problem is to
reset the file context on the target file, restorecon -v './services'. If the
file context does not change from etc_t, then this is probably a bug in policy.
Please file a bug report (http://bugzilla.redhat.com/bugzilla/enter_bug.cgi)
against the selinux-policy package. If it does change, you can try your
application again to see if it works. The file context could have been
mislabeled by editing the file or moving the file from a different directory, if
the file keeps getting mislabeled, check the init scripts to see if they are
doing something to mislabel the file.

Allowing Access:

You can attempt to fix file context by executing restorecon -v './services'

The following command will allow this access:

restorecon './services'

Additional Information:

Source Context                system_u:system_r:logwatch_t:SystemLow-SystemHigh
Target Context                system_u:object_r:etc_t
Target Objects                ./services [ dir ]
Source                        perl
Source Path                   /usr/bin/perl
Port                          <Unknown>
Host                          dyno.devel.redhat.com
Source RPM Packages           perl-5.8.8-24.el5
Target RPM Packages           
Policy RPM                    selinux-policy-2.4.6-236.el5
Selinux Enabled               True
Policy Type                   targeted
MLS Enabled                   True
Enforcing Mode                Enforcing
Plugin Name                   mislabeled_file
Host Name                     dyno.devel.redhat.com
Platform                      Linux dyno.devel.redhat.com 2.6.18-150.el5 #1 SMP
                              Wed May 20 20:25:53 EDT 2009 x86_64 x86_64
Alert Count                   1
First Seen                    Fri May 22 07:24:38 2009
Last Seen                     Fri May 22 07:24:38 2009
Local ID                      6281ed61-5765-4149-bbf7-9a08d6c5db52
Line Numbers                  

Raw Audit Messages            

host=dyno.devel.redhat.com type=AVC msg=audit(1242991478.645:225): avc:  denied  { write } for  pid=5773 comm="perl" name="services" dev=dm-3 ino=3273683 scontext=system_u:system_r:logwatch_t:s0-s0:c0.c1023 tcontext=system_u:object_r:etc_t:s0 tclass=dir

host=dyno.devel.redhat.com type=SYSCALL msg=audit(1242991478.645:225): arch=c000003e syscall=2 success=no exit=-13 a0=1a9af930 a1=241 a2=1b6 a3=31da0f38f0 items=0 ppid=5770 pid=5773 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm="perl" exe="/usr/bin/perl" subj=system_u:system_r:logwatch_t:s0-s0:c0.c1023 key=(null)

Version-Release number of selected component (if applicable):
dmraid-1.0.0.rc13-45.el5.x86_64

How reproducible:
I suspect tomorrow morning it will happen again!

Additional info:
selinux-policy and logrotate haven't changed in weeks plus.  dmraid changed yesterday and furthermore, the dmraid files are the only contents of the /etc/logwatch/*/services directories so I'm guessing this is related to the dmraid changes (bug 481749.)

Comment 1 Jay Turner 2009-05-22 13:28:20 UTC
A bit more information.  Getting the following as well:

 Permission denied at /etc/logwatch/scripts/services/dmeventd line 46.

Comment 2 Heinz Mauelshagen 2009-05-25 13:54:40 UTC
(In reply to comment #1)
> A bit more information.  Getting the following as well:
> 
>  Permission denied at /etc/logwatch/scripts/services/dmeventd line 46.  

Indicating, that the script doesn't have proper credentials to open its log file 
"/etc/logwatch/scripts/services/dmeventd_syslogpattern.txt", which didn't change name and wasn't an issue in the 5.3 version.

I assume an SELinux policy change ?

Comment 3 Jay Turner 2009-05-26 12:26:47 UTC
selinux-policy last changed on my system May 15th.  These denials began on May 22nd (the first showing up at 07:24EDT.)  And indeed now that I'm looking at it, appears that dmraid-events wasn't updated until 09:50EDT.

rpm.log attached (output of 'rpm -qa --last')

audit2allow and audit2why output:

# cat /var/log/audit/audit.log | audit2allow 


#============= logwatch_t ==============
allow logwatch_t etc_t:dir write;
allow logwatch_t etc_t:file write;
[root@dyno ~]# audit2why < /var/log/audit/audit.log
type=AVC msg=audit(1242991478.645:225): avc:  denied  { write } for  pid=5773 comm="perl" name="services" dev=dm-3 ino=3273683 scontext=system_u:system_r:logwatch_t:s0-s0:c0.c1023 tcontext=system_u:object_r:etc_t:s0 tclass=dir
        Was caused by:
                Missing or disabled TE allow rule.
                Allow rules may exist but be disabled by boolean settings; check boolean settings.
                You can see the necessary allow rules by running audit2allow with this audit message as input.

type=AVC msg=audit(1243338724.872:29): avc:  denied  { write } for  pid=6407 comm="perl" name="dmeventd_syslogpattern.txt" dev=dm-3 ino=3273725 scontext=system_u:system_r:logwatch_t:s0-s0:c0.c1023 tcontext=user_u:object_r:etc_t:s0 tclass=file
        Was caused by:
                Missing or disabled TE allow rule.
                Allow rules may exist but be disabled by boolean settings; check boolean settings.
                You can see the necessary allow rules by running audit2allow with this audit message as input.

Comment 4 Jay Turner 2009-05-26 12:27:15 UTC
Created attachment 345457 [details]
'rpm -qa --last' output

Comment 5 Jay Turner 2009-06-05 11:14:09 UTC
I've done a relabel of the filesystem and have received several more of these denials.  We really need to get to the bottom of this for 5.4.

Comment 7 Jay Turner 2009-06-11 10:56:09 UTC

*** This bug has been marked as a duplicate of bug 475562 ***