Bug 76017

Summary: Logics bug in ifup script when determining wireless devices
Product: [Retired] Red Hat Linux Reporter: Who Cares <redhat>
Component: hotplugAssignee: Bill Nottingham <notting>
Status: CLOSED NOTABUG QA Contact: Brock Organ <borgan>
Severity: medium Docs Contact:
Priority: medium    
Version: 8.0CC: rvokal
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2003-02-11 14:34:34 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 Who Cares 2002-10-15 20:16:47 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; de-AT; rv:1.2a) Gecko/20020910

Description of problem:
the function is_wireless_device in
/etc/services/network-scripts/network-functions is completely wrong. The way it
is, ifup-wireless will be executed for every net device that is NOT a wireless
device. As a consequence, ifup-wireless will NEVER be executed for wireless devices.
The reason is the usage of wrong return codes in lines 2 and 3 of the function.
Version as shipped reads:

function is_wireless_device ()
{
    if [ -x /sbin/iwconfig ] return 1;
    LC_ALL=C iwconfig $1 2>&1 | grep "no wireless extension" || return 0;
    return 1;
}

Completely wrong for two reasons:
The second line will execute the "return 0" part if and only if the result of
"iwconfig $1 2>&1 | grep "no wireless extensions" is not zero. Now, bash uses 0
to signal SUCCESS. Which means that if the search string is found, the "return
0" part won't be triggered.
Even if it was (which can be easily accomplished by changing the command to
"LC_ALL=C iwconfig $1 2>&1 | grep "no wireless extenstion" && return 0;" we win
nothing. The reason is the way the evaluation is done in the script ifup: Here
the commands "is_wireless_device(${DEVICE}) && . ./ifup-wireless" are issued.
This instructs bash to source ifup-wireless, if and only if the result of
is_wireless_device is ZERO. In short: is_wireless_device always returns the
wrong exit status if /sbin/iwconfig is installed on a given system.

Imho, is_wireless_device should look like this:

function is_wireless_device ()
{
    if [ -x /sbin/iwconfig ] return 1;
    LC_ALL=C iwconfig $1 2>&1 | grep "no wireless extension" && return 1;
    return 0;
}



Version-Release number of selected component (if applicable):


How reproducible:
Always

Steps to Reproduce:
1. Change the ESSID of a WLAN adapter or try to activate encryption
2. Insert the WLAN card to activate the hotplug system
3. Check whether your changes made it to the adapter configuration. They won't have.
	

Additional info:

Comment 1 Bill Nottingham 2003-02-11 14:34:34 UTC
You're reading it wrong.

> "iwconfig $1 2>&1 | grep "no wireless extensions" is not zero. Now, bash uses 0
> to signal SUCCESS. Which means that if the search string is found, the "return
> 0" part won't be triggered.

*Exactly*.

You only return 0 if the search string *isn't* found, which means there *are*
wireless extensions.