Description of Problem: WIRELESS test in /etc/hotplug/net.agent is broken How Reproducible: add to /etc/hotplug/net.agent exec 2>/tmp/asdf set -x Then plug in a wireless and wired pcmcia/cardbus cards alternately and look at /tmp/asdf each time There are at least two bugs in the line iwconfig $INTERFACE | grep -q "no wireless extensions" || WIRELESS=1 The first is that if grep wants to write, it will error out instead of writing with "bad file descriptor" because stdout does not exist. The second, and most critical, is that "no wireless extensions" is printed on iwconfig's *standard error* not standard out, so grep can never see it. Please change to iwconfig $INTERFACE 2>&1 | \ grep "no wireless extensions" >/dev/null 2>&1 || WIRELESS=1 That will fix both bugs at once.
Well, I did say at least two bugs. The | actually causes the WIRELESS=1 to be evaluated in a subshell. Because iwconfig is broken and doesn't know how to just look to see if there are any wireless extensions, we have to use eval. Yes, this is ugly, but it is also now tested more... eval $(iwconfig $INTERFACE 2>&1 | grep -q "no wireless extensions" >/dev/null 2>&1 || echo WIRELESS=1) That I've tested enough times to have reasonable confidence that it is right.
It could also load the network-functions file and use the is_wireless test there. Of course, that would tie it to having at least a particular version of initscripts.
I'll do what notting suggests.
Make that four bugs in the script. You forgot: - uses completely bogus variable ${REALDEVICE} - doesn't normalize output of 'ip' commmand case wise Wheeeeeeeee. Also fixed the original, just using a simple if !iwconfig ... ; then <do stuff>; seems simpler to read, at least. Fixed in 2001-04-24-7.
I just installed 7.2, and this is NOT all fixed. grep NEEDS A FILE DESCRIPTOR and it kills the script if you don't have one. EVERY SINGLE ethernet card you insert has the wireless bits run because grep complains with grep: writing output: Bad file descriptor All you have to do to test this is add exec 2>> /tmp/netagent.log set -x to the top of /etc/hotplug/net.agent and then insert a card with no wireless extensions.
(just installed 7.2 on the machine I noticed this on originally, that is; the only machine where I have a setup that shows up this bug.) To make this clear, you ABSOLUTELY MUST give grep file descriptors to write on, or it aborts. The hotplug daemon does not do so. Either add exec >/dev/null exec 2>/dev/null in hotplug.functions, or go through and fix every instance in the hotplug scripts AND all the networking scripts that get called through hotplug to explicitly redirect output, or modify the hotplug daemon to open /dev/null for stdout and stderr. Using the "-q" argument to grep is not enough here. I know it looks prettier than ">/dev/null 2>&1" but the two are not synonyms.
Is this still a problem in skipjack2 or later? Some grep issues have been adresses, and a new hotplug is in...
As I wrote before: >EVERY SINGLE ethernet card you >insert has the wireless bits run because grep complains with >grep: writing output: Bad file descriptor >All you have to do to test this is add >exec 2>> /tmp/netagent.log >set -x >to the top of /etc/hotplug/net.agent and then insert a card with no >wireless extensions. Have you done that? I'm out of range of a skipjack machine right now.
Hotplug no longer handles wireless cards at all, in the latest limbo beta.