Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.
Bug 1066139 - cachefilesd initscript calls restorecon for non-existant /dev/cachefiles, causes service not to start unless cachefiles module is loaded
Summary: cachefilesd initscript calls restorecon for non-existant /dev/cachefiles, cau...
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: cachefilesd
Version: 6.5
Hardware: All
OS: Linux
Target Milestone: rc
: ---
Assignee: David Howells
QA Contact: Yin.JianHong
Depends On:
TreeView+ depends on / blocked
Reported: 2014-02-17 19:57 UTC by Kyle Squizzato
Modified: 2018-12-04 17:32 UTC (History)
7 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2016-05-11 01:28:10 UTC
Target Upstream Version:

Attachments (Terms of Use)
modified /etc/init.d/cachefilesd (deleted)
2014-02-17 19:58 UTC, Kyle Squizzato
no flags Details

System ID Priority Status Summary Last Updated
Red Hat Knowledge Base (Solution) 721823 None None None Never
Red Hat Product Errata RHBA-2016:0975 normal SHIPPED_LIVE cachefilesd bug fix update 2016-05-10 22:59:17 UTC

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):

How reproducible:

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

    /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 Yin.JianHong 2016-03-18 02:01:45 UTC

[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

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.

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