Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 86820 - WEP settings fail with strong WEP keys in ascii format
Summary: WEP settings fail with strong WEP keys in ascii format
Status: RESOLVED TEST-REQUEST
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] baselayout (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Roy Marples (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-03-26 19:11 UTC by patrick
Modified: 2005-06-22 00:07 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description patrick 2005-03-26 19:11:19 UTC
if you have a wep key like this HtCkO$m?Aq2]& then the init script will fail to set the key because it tries to expand the $ sign for example. various other strings are passed to the shell, too.

Reproducible: Always
Steps to Reproduce:
1.set a wep key like HtCkO$m?Aq2]& in /etc/conf.d/wireless
2.start /etc/init.d/net.yourwlaninterface
3.
Actual Results:  
 * Caching service dependencies ...                                           
[ ok ]   
 * Starting ath0   
 *    Configuring wireless network for ath0   
/lib/rcscripts/net.modules.d/iwconfig: eval: line 344: syntax error near   
unexpected token `)'   
/lib/rcscripts/net.modules.d/iwconfig: eval: line 344: `iwconfig ath0 key   
HtCkO$m?Aq2]& 2>&1'   
   

Expected Results:  
quote the wep key before passing it to iwconfig  

with baselayout version baselayout-1.11.10-r4 you can fix this bug by changing      
the line 344 in /lib/rcscripts/net.modules.d/iwconfig from :     
e=$( eval "iwconfig ${iface} key ${key} 2>&1" )    
to    
e=$( eval "iwconfig ${iface} key '${key}' 2>&1" )
Comment 1 Roy Marples (RETIRED) gentoo-dev 2005-05-24 07:53:24 UTC
Try this

key_ESSID="'s:HtCkO$m?Aq2]&'"
Comment 2 patrick 2005-06-21 03:40:20 UTC
this solution might work, but i didn't test it, since i think it should be the
job of the module to escape or handle the key in an appropriate way. if i can
manage to get write access to this file i can insert any command that i want to
and it gets executed with root permissions as soon as the init script is
restarted. so i really think you should add the quotes in the module.
Comment 3 Roy Marples (RETIRED) gentoo-dev 2005-06-21 05:07:26 UTC
key_ESSID="'s:HtCkO$ ?Aq2]&' enc open"

Is valid and there's a space in the key.
AFAIK that is the only way of handling this
Comment 4 patrick 2005-06-21 06:23:35 UTC
"HtCkO$m?Aq2]&" this is the original key. there is no space in it. if it is, its
not meant to be there.
the problem is this line in the iwconfig module :

e=$( eval "iwconfig ${iface} key ${key} 2>&1" )

it just uses the ${key} variable without quoting it. and thats the whole problem
causing it. just fix that line and everybody is able to use
key_ESSID="s:HtCkO$m?Aq2]&" in wireless.conf. and remeber to use single quotes
if you will fix it, otherwise the same will happen again. and there is
absolutely no need in using variables in the wep key itself, so its save to just
quote the string in the module.
Comment 5 Roy Marples (RETIRED) gentoo-dev 2005-06-21 06:59:40 UTC
After a quick test, the string does need to be escaped in the configuartion as
we need to acccess it via an eval statement. bash will evaluate the $m part of
the key as variable m - unless you can demonstrate a way to get the variable
without eval expanding it.

eval key=\"\$\{key_${essid}\}\"
Comment 6 Roy Marples (RETIRED) gentoo-dev 2005-06-21 07:03:56 UTC
Futher comment - you need to specify the key in single quotes anyway otherwise
bash will expand the $m by default.
Comment 7 patrick 2005-06-21 07:30:18 UTC
all i did to make it work is change this line :

e=$( eval "iwconfig ${iface} key ${key} 2>&1" )

into that :

e=$( eval "iwconfig ${iface} key '${key}' 2>&1" )

thats how it will work, and is the most secure way to pass the key to iwconfig.
Comment 8 Roy Marples (RETIRED) gentoo-dev 2005-06-22 00:07:23 UTC
You code fails to work with

key_Uber_NET="[2] s:uberlordrules key [2] enc open"

You may want to see bug #74053 as that details with the space problem