Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1066139

Summary: cachefilesd initscript calls restorecon for non-existant /dev/cachefiles, causes service not to start unless cachefiles module is loaded
Product: Red Hat Enterprise Linux 6 Reporter: Kyle Squizzato <ksquizza>
Component: cachefilesdAssignee: David Howells <dhowells>
Status: CLOSED ERRATA QA Contact: JianHong Yin <jiyin>
Severity: high Docs Contact:
Priority: high    
Version: 6.5CC: albertczyk, christian.gall, dmoessne, eguan, initscripts-maint-list, mussulma, yanwang
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-05-11 01:28:10 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:
Bug Depends On:    
Bug Blocks: 1075802, 1172231, 1268411    
Attachments:
Description Flags
modified /etc/init.d/cachefilesd none

Description Kyle Squizzato 2014-02-17 19:57:25 UTC
Description of problem:
If the cachefiles module is not loaded the /dev/cachefiles device does not exist.  This causes the cachefiles initscript to fail at line 60 when setting security contexts for selinux. 

Version-Release number of selected component (if applicable):
cachefilesd-0.10.2-1.el6.x86_64
initscripts-9.03.40-2.el6.x86_64

How reproducible:
Always

Steps to Reproduce:
1. Set SELinux to enforcing mode 
2. Unload the cachefiles module or ensure it's unloaded
3. Start cachefilesd: 

 # service cachefilesd start  


Actual results:
Cachefilesd fails to start with the following error:

# service cachefilesd start
Starting cachefilesd: /sbin/restorecon:  lstat(/dev/cachefiles) failed:  No such file or directory

Expected results:
cachefilesd starts successfully 


Additional info:
 - Can easily be worked around by loading the module manually before starting. 

 - I've attached a modified initscript file which re-orders the security context settings and the module loading so that the module is loaded before selinux contexts are set.  This appears to fix the issue: 

 [root@scooby ~]# modprobe -r cachefiles  
 [root@scooby ~]# setenforce 1
 [root@scooby ~]# service cachefilesd start
 Starting cachefilesd:                                      [  OK  ]

Relevant lines:

	57	+ 
58	+     # Set security contexts
59	+     /sbin/restorecon /sbin/cachefilesd || return 1
60	+     /sbin/restorecon /dev/cachefiles || return 1
61	+     /sbin/restorecon -R `awk -- '/^dir/ { print $2 }' $CONFFILE` || return 1
57	62	  
58	63	      # Load the cachefiles module if needed
59	64	      [ -x "$MODPROBE" ] && {
60	65	  	if ! /sbin/lsmod | grep cachefiles > /dev/null ; then
61	66	  	    $MODPROBE cachefiles $MODPROBE_ARGS || return 1
62	67	  	fi
63	68	      }
64		- 
65		-     # Set security contexts
66		-     /sbin/restorecon /sbin/cachefilesd || return 1
67		-     /sbin/restorecon /dev/cachefiles || return 1
68		-     /sbin/restorecon -R `awk -- '/^dir/ { print $2 }' $CONFFILE` || return 1

Comment 1 Kyle Squizzato 2014-02-17 19:58:49 UTC
Created attachment 864265 [details]
modified /etc/init.d/cachefilesd

Comment 9 Alberto 2016-02-09 13:32:18 UTC
I think it's not working... I've just installed in CentOS 6 (2.6.32-573.8.1.el6.x86_64), the fix is present in /etc/init.d/cachefilesd, but still gives the error. 

The code should be like this:

    # Set security contexts
    /sbin/restorecon /sbin/cachefilesd || return 1
    /sbin/restorecon -R `awk -- '/^dir/ { print $2 }' $CONFFILE` || return 1

    # Load the cachefiles module if needed
    [ -x "$MODPROBE" ] && {
        if ! /sbin/lsmod | grep cachefiles > /dev/null ; then
            $MODPROBE cachefiles $MODPROBE_ARGS || return 1
        fi
    }

    /sbin/restorecon /dev/cachefiles || return 1



because /dev/cachefiles will not appear until the module is loaded.

Comment 10 David Howells 2016-02-18 16:18:20 UTC
Moving those two restorecon lines up should make no difference since the things being labelled aren't used till after the third restorecon line.

Comment 11 David Howells 2016-02-18 16:26:41 UTC
The error you say is still happening is:

   Starting cachefilesd: /sbin/restorecon:  lstat(/dev/cachefiles) failed:  No
   such file or directory

right?  Can you stick set -x / set +x around the section of the script in question?

Comment 12 JianHong Yin 2016-03-18 02:01:45 UTC
Verified:

[root@pogolinux-02 ~]# rmmod cachefiles
[root@pogolinux-02 ~]# lsmod|grep cachefiles
[root@pogolinux-02 ~]# service cachefilesd start
Starting cachefilesd: [  OK  ]
[root@pogolinux-02 ~]# lsmod|grep cachefiles
cachefiles             36893  1 
fscache                55636  1 cachefiles
[root@pogolinux-02 ~]# rpm -q cachefilesd
cachefilesd-0.10.2-2.el6.x86_64

Comment 14 errata-xmlrpc 2016-05-11 01:28:10 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2016-0975.html