Bug 76017 - Logics bug in ifup script when determining wireless devices
Summary: Logics bug in ifup script when determining wireless devices
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: hotplug
Version: 8.0
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Bill Nottingham
QA Contact: Brock Organ
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2002-10-15 20:16 UTC by Who Cares
Modified: 2014-03-17 02:31 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2003-02-11 14:34:34 UTC
Embargoed:


Attachments (Terms of Use)

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.



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