Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 96080

Summary: Baselayout, nasty bugs in parsing /etc/conf.d/wireless
Product: Gentoo Linux Reporter: tomas charvat <tc>
Component: [OLD] baselayoutAssignee: Roy Marples (RETIRED) <uberlord>
Status: RESOLVED TEST-REQUEST    
Severity: major CC: henrik
Priority: High    
Version: unspecified   
Hardware: x86   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Attachments: Apply user defaults on success

Description tomas charvat 2005-06-14 07:57:40 UTC
sys-apps/baselayout-1.11.12-r4

Since we have new way how to set up wireless devices i decide to check it out.
But it seems, that some of my iwpriv commands from /etc/conf.d/wireless are not
executed and some iwconfig commands work only in some special order, while in
commandline everythings works well.

Please note that this could cause security hole to whom, who use gentoo as AP
and didnt check his AP from outside.

Reproducible: Always
Steps to Reproduce:
1. run iwevent (to check whats happening with your wireless card)

2. here is my /etc/conf.d/wireless
essid_wlan0="bird"
mode_wlan0="master"
channel_wlan0="13"

iwconfig_wlan0="enc 2580-afdd retry 30"

iwpriv_wlan0="reset 0"
iwpriv_wlan0="reset 1"
iwpriv_wlan0="reset 2"
iwpriv_wlan0="maccmd 3"
iwpriv_wlan0="maccmd 4"
iwpriv_wlan0="maccmd 1"
iwpriv_wlan0="addmac 00:60:B3:6B:6F:25" # ddddd
iwpriv_wlan0="addmac 00:60:B3:6D:79:99" # sssss
iwpriv_wlan0="addmac 00:60:B3:6E:10:E4" # aaaa

3. now i run /etc/init.d/net.wlan0 restart
   And check actual result, then continue

4. here is what happen if i will setup same things via bash script
   execute this  [
        #/bin/bash
        iwpriv wlan0 reset 0
        iwpriv wlan0 reset 1
        iwpriv wlan0 reset 2
        iwpriv wlan0 maccmd 3
        iwpriv wlan0 maccmd 4
        iwpriv wlan0 maccmd 1
        iwconfig wlan0 enc 2580-aaaa
        iwconfig wlan0 mode master essid bird channel 13 rate 5.5M retry 30
        iwpriv wlan0 addmac 00:60:B3:6B:6F:25 # bird
        iwpriv wlan0 addmac 00:60:B3:6D:79:99 # Neratovice
        iwpriv wlan0 addmac 00:60:B3:6E:10:E4 # Mrzilek

      You will find output in Expected result.

5. Compare Actual and Expected(old fashion) output
   As you can see, Expiration of nodes and re-registration parts are missing.
   So maccmd commands are not executed from /etc/conf.d/wireless neither any
error is printed. Please note multiple Encryption messages in iwevent output,
when i use /etc/conf.d/wireless


Another bug is with iwconfig_wlan0="retry 30 enc 2580-aaaa" If retry 30 is at
the first place, sometimes i got error like, encryption problem. If i put enc
first, it works  fine. It might be also related to cards. It sometime happen
that some iw* commands are somehow rejected.

Actual Results:  
14:41:58.794687    wlan0    Set Encryption key:off
14:41:58.828204    wlan0    Set Encryption key:****-****
14:41:58.882070    wlan0    Set Encryption key:off
14:41:58.915267    wlan0    Set ESSID:"bird"
14:41:58.981461    wlan0    Set Frequency=2.472 GHz (Channel 13)
14:41:59.015057    wlan0    Set Encryption key:****-****


Expected Results:  
14:44:57.480721    wlan0    Expired node:00:60:B3:6D:79:99
14:44:57.480814    wlan0    Expired node:00:60:B3:6B:6F:25
14:44:57.480826    wlan0    Expired node:00:60:B3:6E:10:E4
14:44:57.506432    wlan0    Tx packet dropped:00:60:B3:6D:79:99
14:44:57.529212    wlan0    Set Encryption key:****-****
14:44:57.530728    wlan0    Set Mode:Master
14:44:57.563144    wlan0    Set ESSID:"bird"
14:44:57.596152    wlan0    Set Frequency=2.472 GHz (Channel 13)
14:44:58.912739    wlan0    Registered node:00:60:B3:6E:10:E4
14:44:59.319591    wlan0    Registered node:00:60:B3:6D:79:99
14:45:04.696473    wlan0    Registered node:00:60:B3:6B:6F:25


Portage 2.0.51.19 (default-linux/x86/2005.0/2.4, gcc-3.3.5-20050130,
glibc-2.3.4.20041102-r1, 2.4.25_pre7-gss-r11 i686)
=================================================================
System uname: 2.4.25_pre7-gss-r11 i686 AMD Athlon(TM) XP 1800+
Gentoo Base System version 1.6.12
Python:              dev-lang/python-2.2.3-r5,dev-lang/python-2.3.5 [2.3.5 (#1,
Jun 10 2005, 11:41:01)]
distcc 2.16 i686-pc-linux-gnu (protocols 1 and 2) (default port 3632) [disabled]
dev-lang/python:     2.2.3-r5, 2.3.5
sys-apps/sandbox:    [Not Present]
sys-devel/autoconf:  2.13, 2.59-r6
sys-devel/automake:  1.4_p6, 1.5, 1.7.9-r1, 1.6.3, 1.8.5-r3, 1.9.5
sys-devel/binutils:  2.15.92.0.2-r10
sys-devel/libtool:   1.5.16
virtual/os-headers:  2.4.19-r1, 2.4.22-r1
ACCEPT_KEYWORDS="x86"
AUTOCLEAN="yes"
CFLAGS="-O3 -mcpu=athlon-xp -funroll-loops -pipe"
CHOST="i686-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/kde/2/share/config /usr/kde/3/share/config
/usr/share/config /var/qmail/control"
CONFIG_PROTECT_MASK="/etc/gconf /etc/terminfo /etc/env.d"
CXXFLAGS="-O3 -mcpu=athlon-xp -funroll-loops -pipe"
DISTDIR="/usr/portage/distfiles"
FEATURES="autoaddcvs autoconfig ccache distlocks sandbox sfperms strict"
GENTOO_MIRRORS="http://ftp.gentoo.skynet.be/pub/gentoo/"
MAKEOPTS="-j2"
PKGDIR="/usr/portage/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
USE="x86 apm arts avi berkdb bitmap-fonts crypt cups emboss encode foomaticdb
fortran gd gdbm gif gpm gtk2 imlib jpeg kde libg++ libwww mad mikmod motif mp3
mpeg ncurses nls oggvorbis opengl oss pam pdflib perl png python qt quicktime
readline sdl slang spell ssl suidperl svga tcltk tcpd tiff truetype
truetype-fonts type1-fonts xml2 xmms xv zlib userland_GNU kernel_linux elibc_glibc"
Unset:  ASFLAGS, CBUILD, CTARGET, LANG, LC_ALL, LDFLAGS, LINGUAS, PORTDIR_OVERLAY
Comment 1 Roy Marples (RETIRED) gentoo-dev 2005-06-14 08:15:50 UTC
Try this

iwpriv_wlan0="reset 0 reset 1 reset 2 maccmd 3 maccmd 4 maccmd 1 addmac
00:60:B3:6B:6F:25 addmac 00:60:B3:6D:79:99 addmac 00:60:B3:6E:10:E4"

Basically, the last iwpriv_wlan0 statements overwrites all the others.
Comment 2 tomas charvat 2005-06-14 08:36:57 UTC
(In reply to comment #1)
> Try this
> 
> iwpriv_wlan0="reset 0 reset 1 reset 2 maccmd 3 maccmd 4 maccmd 1 addmac
> 00:60:B3:6B:6F:25 addmac 00:60:B3:6D:79:99 addmac 00:60:B3:6E:10:E4"
> 
> Basically, the last iwpriv_wlan0 statements overwrites all the others.

Waiting for Wireless Events from interfaces...
15:35:12.848251    wlan0    Set Encryption key:off
15:35:12.876728    wlan0    Set Encryption key:****-****
15:35:13.028356    wlan0    Set Encryption key:off
15:35:13.062053    wlan0    Set ESSID:"bird"
15:35:13.134473    wlan0    Set Frequency=2.472 GHz (Channel 13)
15:35:13.169089    wlan0    Set Encryption key:****-****
15:35:31.479683    wlan0    Tx packet dropped:00:60:B3:6B:6F:25


seems to me as same result.
 
I forgot to mention, that i tried this before ;)
Comment 3 Roy Marples (RETIRED) gentoo-dev 2005-06-14 09:19:20 UTC
Created attachment 61213 [details, diff]
Apply user defaults on success

Try this patch
Comment 4 tomas charvat 2005-06-14 12:00:36 UTC
(In reply to comment #3)
> Created an attachment (id=61213) [edit]
> Apply user defaults on success
> 
> Try this patch

shall patch /etc/init.d/net.wlan0 ?
Comment 5 tomas charvat 2005-06-14 12:09:08 UTC
(In reply to comment #3)
> Created an attachment (id=61213) [edit]
> Apply user defaults on success
> 
> Try this patch

shall patch /etc/init.d/net.wlan0 ?(In reply to comment #3)
> Created an attachment (id=61213) [edit]
> Apply user defaults on success
> 
> Try this patch

Waiting for Wireless Events from interfaces...
19:06:01.908107    wlan0    Tx packet dropped:00:60:B3:6B:6F:25
19:06:12.737920    wlan0    Set Encryption key:off
19:06:12.771761    wlan0    Set Encryption key:****-****
19:06:12.817045    wlan0    Set Encryption key:off
19:06:12.850257    wlan0    Set ESSID:"bird"
19:06:12.919406    wlan0    Set Frequency=2.472 GHz (Channel 13)
19:06:12.953150    wlan0    Set Encryption key:****-****
19:06:13.025742    wlan0    Set Encryption key:****-****

Something is still wrong... specialy about setting encryption.

i patched /lib/rcscripts/net.modules.d/iwconfig
Comment 6 Roy Marples (RETIRED) gentoo-dev 2005-06-15 01:52:58 UTC
the iwconfig module is mainly for attaching to other networks - it appears that
you are trying to add mac validation to it? Are you using hostapd?

I suspect that you are as I found a post of yours on Google relating to this -
infact it's the exact same script where you posted that it's unreliable unless
done in this order. Well, my script is never going to do it in the order you want.

However, you can do what you need like so

predown() {
   if [[ $( type -t wireless_check_extensions ) == "function" ]]; then
      if wireless_check_extensions ${IFACE} ; then
         iwpriv ${IFACE} reset 0
         iwpriv ${IFACE} reset 1
         iwpriv ${IFACE} reset 2
      fi
   fi
}

postup() {
   if [[ ${ESSID} == "bird" ]]; then
      iwpriv ${IFACE} maccmd 3
      iwpriv ${IFACE} maccmd 4
      iwpriv ${IFACE} maccmd 1
      iwpriv ${IFACE} addmac 00:60:B3:6B:6F:25
      iwpriv ${IFACE} addmac 00:60:B3:6D:79:99
      iwpriv ${IFACE} addmac 00:60:B3:6E:10:E4
   fi
}
Comment 7 tomas charvat 2005-06-15 04:57:20 UTC
So if i understand correctly, your script can handle only basic setup for
wireless interface and if i wanna use some advanced setup i have to do in old way.
Well ok.

But there is still something wrong, when encryption is turn off/on/off/on.

Even if i delete everything but essid, channel and mode i still see this.

11:53:46.890958    wlan0    Set Encryption key:off
11:53:46.935240    wlan0    Set Encryption key:off
11:53:46.968553    wlan0    Set ESSID:"bird"
11:53:47.035330    wlan0    Set Frequency=2.472 GHz (Channel 13)

Why should be Encryption turned of twice, while i do not specify any additional
iwconfig param nor iwpriv param. my wireless file was:

essid_wlan0="bird"
mode_wlan0="master"
channel_wlan0="13"

Something is wrong isnt it ?
Comment 8 tomas charvat 2005-06-15 05:06:53 UTC
(In reply to comment #6)
> the iwconfig module is mainly for attaching to other networks - it appears that
> you are trying to add mac validation to it? Are you using hostapd?

Yup its MAC validation. I use hostap driver but not Hostapd.

 
> I suspect that you are as I found a post of yours on Google relating to this -
> infact it's the exact same script where you posted that it's unreliable unless
> done in this order. Well, my script is never going to do it in the order you want.

Yeep if you are talking about order of my commands, it has to be done in that
way. (turn on ACL, Flush Acl list, Kick all Clients, then we are adding valid
clients)

Umm well i will just keep old script and simply call it from net.wlan0 .

Comment 9 Roy Marples (RETIRED) gentoo-dev 2005-06-15 05:10:04 UTC
you forgot

key_bird="aaaa-bbbb"

And yes, I do a few things more than once - this is to try and support every
silly wireless driver.

And lastly, this *is* an advanced wireless interface setup - it's not an Access
Point setup which is what you're trying to accomplish.
Comment 10 tomas charvat 2005-06-15 05:46:58 UTC
(In reply to comment #9)
> you forgot
> 
> key_bird="aaaa-bbbb"
> 
> And yes, I do a few things more than once - this is to try and support every
> silly wireless driver.
> 
> And lastly, this *is* an advanced wireless interface setup - it's not an Access
> Point setup which is what you're trying to accomplish.

No i didnt forget encryoption key. I removed that encryption for testing.
I made it as simple as possible, to show you that script play with encryption
settings even if you do not specify any enc option. (if you do not setup ENC,
script still attempt to turn of ENC 2x during interface startup)

Well you probably didnt get it, coz of my crappy language.
My driver is quite ok, it support WE(13 and later) w/o any problem.
When i simply pass options via iwpriv/iwconfig commands it works fine.
When your script trying to parse wireless configuration file, it do some things,
whitch should not be done and it parse "only something" from /etc/conf.d/wireless.

Would you be so kind and explain me, how is it related to my driver ?


It is not possible to use this script for advanced setup, because it can not 
handle more that one non-standart iwpriv/iwconfig command.

Instead of giving oportunity to user to setup their card by valid WE commands,
functions, you just created some pseudo parameters (/etc/conf.d/wireless),
whitch are parsed by init script and then interpreted to WE extension. Im not
sure if this will help wireless users with setup of their network. They have to
go trough another "private" labeling of functions and hope, that author consider
their function as "normal". 

Your script is usefull just for client setup, insecure AP setup and some  basic
Monitor setup.
Please note that Monitor,AP, IClient, AD-HOC are modes of 1 card, 1 driver. (no
im not talking about hostap.. im talking about all drivers whitch support WE)

I would rather suggest to spend time on script, whitch will be usefull interface
for WE, that some limited sort of commands, whitch has been choosen by somebody.

Does it make sense ?
Comment 11 Roy Marples (RETIRED) gentoo-dev 2005-06-15 08:06:39 UTC
By drivers I mean all drivers not just your drivers for your card. There's code
in there to make ndiswrapper, ratech and prism54 and play nicely with each
other. Those drivers are all WE16 compliant and yet ndiswrapper sometimes does
not support scanning, prism54 needs to be up before you can check if wireless
works or not - just because they are WE compliant does not mean they work the
same way. Hope that clears my driver comment up a bit!

And yes, the script does alter encryption settings more than once. This is how
it was designed to work as some drivers/cards require it to be removed before
scanning works - yours may not but *some do*, hence that is why it does this.

Basically if you set key_bird="aaaa-bbbb" and then run the script and it works
then good. If - when the script has completed - iwconfig reports the correct key
then it is good and does not matter how many times the script changed it. It
only (or should only) matter how it ends up and not how it got there.

Is the hostap-driver making those entires into syslog or are you using some
other kind of wireless event logger?
Comment 12 tomas charvat 2005-06-15 08:24:25 UTC
> Is the hostap-driver making those entires into syslog or are you using some
> other kind of wireless event logger?
Thanks for your explaining it made few things clear for me ;)

Output is from iwevent, whitch is part of wirelesstools. 

I will try more tests with multiple parameters on one line.

Comment 13 Roy Marples (RETIRED) gentoo-dev 2005-06-17 11:37:50 UTC
I am unable to replicate those wireless events (monitored using iwevent)
independantly of net.xxx on prism54 or madwifi which are the only wireless
devices I have :(

I'm going to have to leave this bug open util someone can fix it with the right
hardware.
Comment 14 Roy Marples (RETIRED) gentoo-dev 2006-01-13 05:03:55 UTC
baselayout-1.12.0_pre14 may fix this issue as it can now do seperate ipwriv calls, so this may work

iwpriv_wlan0=(
  "reset 0"
  "reset 1"
  "reset 2"
  "maccmd 3"
  "maccmd 4"
  "maccmd 1"
)

iwpriv_bird=(
  "addmac 00:60:B3:6B:6F:25"
  "addmac 00:60:B3:6D:79:99"
  "addmac 00:60:B3:6E:10:E4"
)