Bug 137755

Summary: /etc/hotplug/blacklist matches when it shouldn't
Product: [Fedora] Fedora Reporter: Jonathan Kamens <jik>
Component: initscriptsAssignee: Bill Nottingham <notting>
Status: CLOSED RAWHIDE QA Contact: Brock Organ <borgan>
Severity: medium Docs Contact:
Priority: medium    
Version: rawhideCC: rvokal
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: 7.95-1 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2004-11-01 22:40:40 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 Jonathan Kamens 2004-11-01 02:03:37 UTC
The comment in /etc/hotplug/blacklist claims that only lines
containing a single name of a module are obeyed, everything else is
ignored.  In fact, the load_module function in /etc/rc.d/rc.sysinit
believes any line with the relevant module's name anywhere on it. 
This is bad.

Here's a better load_module function.  I used awk rather than grep
because that way you don't have to worry about special
regular-expression characters in the module name -- you can't use
fgrep because you would need to anchor the expression, but if you use
grep you would need to worry about regexp chars.

load_module () {
	LC_ALL=C awk 'BEGIN {stat=1} NF==1 && $1=="'"$1"'" {stat=0; exit} END
{exit stat}' /etc/hotplug/blacklist || modprobe $1 >/dev/null 2>&1
}

Comment 1 Bill Nottingham 2004-11-01 20:22:50 UTC
Do modules actually use regexp characters? The awk solution is rather
more inefficient.


Comment 2 Bill Nottingham 2004-11-01 20:34:27 UTC
fgrep -xq seems simpler (and faster). Added, will be in later releases.
(7.95-1, at least)

Comment 3 Jonathan Kamens 2004-11-01 21:35:31 UTC
Concerning the speed of awk: There aren't enough modules to make the 
speed terribly relevant, not to mention the fact that this only 
happens once, at boot.

Concerning whether the module names may contain regexp chars: Unless 
you can be 100% certain that the input into this function will never 
contain regexp chars (remember, e.g., that even "." is a regexp 
charge, and I don't think it's unimaginable for a module name to have 
a period in it), I think you need to write the code to be resistent 
to them.

Concerning fgrep -xq: It is not forgiving of lines with extra 
whitespace at the beginning or end, which I believe it should be, 
whereas the awk code is.  I don't think this is the best 
implementation.


Comment 4 Bill Nottingham 2004-11-01 22:40:40 UTC
From the upstream blacklist file:

# Syntax:  driver name alone (without any spaces) on a line. Other
# lines are ignored.

Ergo, space is not an issue. At this point, the rc.sysinit is at least
bug-compatible with upstream hotplug.