Bug 137755 - /etc/hotplug/blacklist matches when it shouldn't
/etc/hotplug/blacklist matches when it shouldn't
Status: CLOSED RAWHIDE
Product: Fedora
Classification: Fedora
Component: initscripts (Show other bugs)
rawhide
All Linux
medium Severity medium
: ---
: ---
Assigned To: Bill Nottingham
Brock Organ
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2004-10-31 21:03 EST by Jonathan Kamens
Modified: 2014-03-16 22:50 EDT (History)
1 user (show)

See Also:
Fixed In Version: 7.95-1
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2004-11-01 17:40:40 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Jonathan Kamens 2004-10-31 21:03:37 EST
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 15:22:50 EST
Do modules actually use regexp characters? The awk solution is rather
more inefficient.
Comment 2 Bill Nottingham 2004-11-01 15:34:27 EST
fgrep -xq seems simpler (and faster). Added, will be in later releases.
(7.95-1, at least)
Comment 3 Jonathan Kamens 2004-11-01 16:35:31 EST
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 17:40:40 EST
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.

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