Bug 240911

Summary: SELinux is preventing /usr/sbin/ntpd (ntpd_t) "write" to /var/log/pm-suspend.log (var_log_t).
Product: [Fedora] Fedora Reporter: Mauri Korkeala <mauri.korkeala>
Component: pm-utilsAssignee: Phil Knirsch <pknirsch>
Status: CLOSED DUPLICATE QA Contact:
Severity: low Docs Contact:
Priority: medium    
Version: rawhideCC: opensource, rvokal
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2007-09-20 00:18:15 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:

Description Mauri Korkeala 2007-05-22 20:08:50 UTC
Description of problem:
While suspending and resuming the computer, I found following entry in the
SELinux Troubleshooter:
SELinux is preventing /usr/sbin/ntpd (ntpd_t) "write" to /var/log/pm-suspend.log
(var_log_t). The SELinux type %TARGET_TYPE, 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 or append on (F2). But if for some reason a file
(/var/log/pm-suspend.log) 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 /var/log/pm-suspend.log. If the file context does
not change from var_log_t, then this is probably a bug in policy. Please file a
bug report 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
/var/log/pm-suspend.logThe following command will allow this access:restorecon
/var/log/pm-suspend.log

Additional Information
Source Context:  root:system_r:ntpd_t
Target Context:  root:object_r:var_log_t
Target Objects:  /var/log/pm-suspend.log [ file ]
Affected RPM Packages:  ntp-4.2.4p0-2.fc7 [application]pm-utils-0.99.3-5.fc7
[target]
Policy RPM:  selinux-policy-2.6.4-6.fc7
Selinux Enabled:  True
Policy Type:  targeted
MLS Enabled:  True
Enforcing Mode:  Enforcing
Plugin Name:  plugins.mislabeled_file
Host Name:  localhost.localdomain
Platform:  Linux localhost.localdomain 2.6.21-1.3167.fc7 #1 SMP Thu May 17
23:05:53 EDT 2007 i686 i686
Alert Count:  1
First Seen:  Tue 22 May 2007 10:00:58 PM EEST
Last Seen:  Tue 22 May 2007 10:31:27 PM EEST
Local ID:  d2d966c6-60c5-4876-9c6c-b13f1efe69ab
Line Numbers:  

Raw Audit Messages :avc: denied { write } for comm="ntpd" dev=dm-0 egid=0 euid=0
exe="/usr/sbin/ntpd" exit=0 fsgid=0 fsuid=0 gid=0 items=0 name="pm-suspend.log"
path="/var/log/pm-suspend.log" pid=3118 scontext=root:system_r:ntpd_t:s0 sgid=0
subj=root:system_r:ntpd_t:s0 suid=0 tclass=file
tcontext=root:object_r:var_log_t:s0 tty=(none) uid=0 

Version-Release number of selected component (if applicable):
Running current rawhide, kernel-2.6.21-1.3167.fc7

Comment 1 Daniel Walsh 2007-05-23 13:33:58 UTC
restorecon -R -v /var/run/pm-suspend.log will fix the context on this file.  The
problem is in pm-utils and is being fixed in the next update to pm-utils.

pm-utils currently removes the file and then recreates it loosing the file
context.  If the script does not remove it but only zeroes it out the
file_context will be maintained.  This way hal,ntpd will be able to write to it
whether it was executed by hal, ntp or an unconfined domain,

Comment 2 Till Maas 2007-09-20 00:18:15 UTC
(In reply to comment #1)
> restorecon -R -v /var/run/pm-suspend.log will fix the context on this file.  The
> problem is in pm-utils and is being fixed in the next update to pm-utils.

Hm, I did not see that this bug was fixed in an earlier release of pm-utils, but
it should be fixed now. In case I oversaw that it was already fixed, please tell me.



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