Bug 76017 - Logics bug in ifup script when determining wireless devices
Logics bug in ifup script when determining wireless devices
Status: CLOSED NOTABUG
Product: Red Hat Linux
Classification: Retired
Component: hotplug (Show other bugs)
8.0
All Linux
medium Severity medium
: ---
: ---
Assigned To: Bill Nottingham
Brock Organ
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2002-10-15 16:16 EDT by Who Cares
Modified: 2014-03-16 22:31 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2003-02-11 09:34:34 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 Who Cares 2002-10-15 16:16:47 EDT
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 09:34:34 EST
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.