Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
How do I avoid wpa_supplicant backgrounding [solved]
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
Jykke
Apprentice
Apprentice


Joined: 31 Mar 2006
Posts: 246

PostPosted: Sun Jun 03, 2007 7:56 pm    Post subject: How do I avoid wpa_supplicant backgrounding [solved] Reply with quote

I have this problem when trying to use wpa_supplicant that it backgrounds and is not "up" fast
enough. So consequently network dependent services mysql (mainly) fail to start.
RC_PLUG_SERVICES="!net.*" in /etc/conf.d/rc is of no help since it also seems to get ignored
by backgrounded supplicant with iwconfig I have no such probs but I'd like to use that WPA...

Am I the only one having this problem?


Last edited by Jykke on Tue Jun 19, 2007 11:13 pm; edited 1 time in total
Back to top
View user's profile Send private message
PaulBredbury
Watchman
Watchman


Joined: 14 Jul 2005
Posts: 7310

PostPosted: Sun Jun 03, 2007 9:20 pm    Post subject: Reply with quote

One option is to create a custom service, like mine. I have a udev script to rename the interface to wlan.

/etc/init.d/net.wlan

Code:
#!/sbin/runscript

opts="start stop restart"

depend() {
   need net.lo
}

start() {
   ebegin "Starting ndiswrapper wireless"
   modprobe ndiswrapper || exit 1
   ifconfig wlan up

   ifconfig wlan 192.168.1.5
   iwconfig wlan mode managed
   iwconfig wlan channel 1
   iwconfig wlan essid 1 || eend 1

   # WPA
   /sbin/wpa_supplicant -B -c /etc/wpa_supplicant/wpa_supplicant.conf -i wlan -D wext
   local timer=0
   while [[ -n $(iwconfig wlan | grep "Not-Associated") ]] ; do
      timer=$[${timer}+1]
      if [[ ${timer} -gt 25 ]] ; then
         echo
         eerror "Timed out."
         return 1
      fi
      echo -n "."
      sleep 2
   done
   echo

   eend 0
}

stop() {
   ebegin "Stopping ndiswrapper wireless"
   ifconfig wlan down
   killall wpa_supplicant

   modprobe -r ndiswrapper
   eend 0
}

restart() {
   svc_stop
   echo "Sleeping before restarting, for udev."
   sleep 10
   svc_start
}

# vim:ts=4


Setup:
Code:
$ rc-update show | grep net
net.lo | boot
net.wlan | boot
Back to top
View user's profile Send private message
Jykke
Apprentice
Apprentice


Joined: 31 Mar 2006
Posts: 246

PostPosted: Mon Jun 04, 2007 6:59 pm    Post subject: Reply with quote

Ok this sounds all fine and so on but
1) I don't get why I should "rename" the interface ath0 is ok for me

2) I tried to chance it to ath0 but not much of a success there...

I got something like:

#!/sbin/runscript

opts="start stop restart"

depend() {
need net.lo
}

start() {
ifconfig ath0 up
ifconfig ath0 192.178.168.22
iwconfig ath0 mode managed
iwconfig ath0 channel 1
iwconfig ath0 essid 1 || eend 1

# WPA
/sbin/wpa_supplicant -B -c /etc/wpa_supplicant/wpa_supplicant.conf -i ath0 -D wext
local timer=0
while [[ -n $(iwconfig ath0 | grep "Not-Associated") ]] ; do
timer=$[${timer}+1]
if [[ ${timer} -gt 25 ]] ; then
echo
eerror "Timed out."
return 1
fi
echo -n "."
sleep 2
done
echo

eend 0
}

stop() {
ebegin "Stopping ndiswrapper wireless"
ifconfig ath0 down
killall wpa_supplicant

eend 0
}

restart() {
svc_stop
echo "Sleeping before restarting, for udev."
sleep 10
svc_start
}

# vim:ts=4


Don't need the ndiswrapper bits I suppose - should replace with modprobe
ath_pci and ath_hal and maybe ath_rate_sample...

Does this also ignore contents of /etc/conf.d/net ?
I am not sure about the channels and essid and that
ip you have in the beginning?

I suppose your essid is not "1" and it gets later assigned in wpa_supplicant.conf?

I have to admit I am a bit lost...
Back to top
View user's profile Send private message
Jykke
Apprentice
Apprentice


Joined: 31 Mar 2006
Posts: 246

PostPosted: Mon Jun 04, 2007 7:50 pm    Post subject: Reply with quote

Ok added few modprobes for atheros but and now I got this when trying to start

./net.ath0 start
ctrl_iface exists and seems to be in use - cannot override it
Delete '/var/run/wpa_supplicant/ath0' manually if it is not used anymore
Failed to initialize control interface '/var/run/wpa_supplicant'.
You may have another wpa_supplicant process already running or the file was
left by an unclean termination of wpa_supplicant in which case you will need
to manually remove this file before starting wpa_supplicant again.

./net.ath0: line 9: 11852 Segmentation fault /sbin/wpa_supplicant -B -c /etc/wpa_supplicant/wpa_supplicant.conf -i ath0 -D wext
.........................
* Timed out.



Now my script start part:
start() {
modprobe ath_hal || exit 1
modprobe wlan || exit 1
modprobe ath_rate_sample || exit 1
modprobe ath_pci || exit 1
ifconfig ath0 192.168.178.22 netmask 255.255.255.0 up
route add default gw 192.168.178.1
iwconfig ath0 essid "myEssid" key "s:my_wep_key" || eend 1
# WPA
/sbin/wpa_supplicant -B -c /etc/wpa_supplicant/wpa_supplicant.conf -i ath0 -D wext
local timer=0
while [[ -n $(iwconfig ath0 | grep "Not-Associated") ]] ; do
timer=$[${timer}+1]
if [[ ${timer} -gt 25 ]] ; then
echo
eerror "Timed out."
return 1
fi
echo -n "."
sleep 2
done
echo

eend 0
}



in wpa_supplicant.conf I have:

# This is a network block that connects to any unsecured access point.
# # We give it a low priority so any defined blocks are preferred.
# # The below line not be changed otherwise we refuse to work
ctrl_interface=/var/run/wpa_supplicant
# #
# # # Ensure that only root can read the WPA configuration
ctrl_interface_group=0


network={
ssid="myEssid"
key_mgmt=NONE
wep_key0="my_wep_key"
wep_tx_keyidx=0
priority=5
}


I am trying to get wpa_supplicant to run with wep first...should be possible, right?
Back to top
View user's profile Send private message
PaulBredbury
Watchman
Watchman


Joined: 14 Jul 2005
Posts: 7310

PostPosted: Mon Jun 04, 2007 10:21 pm    Post subject: Reply with quote

"ath0" is a meaningless name. The zero is meaningless. "wlan" would actually mean something. But whatever.

WEP is pathetic, so concentrate your efforts on WPA.
Back to top
View user's profile Send private message
Jykke
Apprentice
Apprentice


Joined: 31 Mar 2006
Posts: 246

PostPosted: Thu Jun 07, 2007 4:24 am    Post subject: Reply with quote

WPA is actually my goal but I have two machines running and I am only able to use
iwconfig reliably at the moment. Before I switch router to WPA I want to have a working
solution ready for the remote machine for getting wpa running on it with wpa_supplicant
on one shot.
Back to top
View user's profile Send private message
Jykke
Apprentice
Apprentice


Joined: 31 Mar 2006
Posts: 246

PostPosted: Mon Jun 18, 2007 7:35 pm    Post subject: Reply with quote

I am still struggling with this crap - I am not one inch close of getting it to run.
I can't believe I am only one having this issue. It is simply that with wpa_supplicant
the start of net dependent services fail (regardless WEP or WPA).

Later once the machine is up I can manually bring up mysql or mythbackend or stuff
and then it runs - only during the boot the starting fails. With iwconfig it works
just right...
Back to top
View user's profile Send private message
Jykke
Apprentice
Apprentice


Joined: 31 Mar 2006
Posts: 246

PostPosted: Tue Jun 19, 2007 11:13 pm    Post subject: Reply with quote

I've been banging my head on the wall with this issue for
a fairly long time...Finally today NightKhaos pointed me to the right direction on IRC...

I already tried adding net.ath0 to boot (of course removing it from "default")
Problem with mysql was solved but network died after awhile.
Adding net.ath0 simultaneously to boot AND default gave a working solution with
wpa_supplicant (and consequently wep).

This works and I get no warning about netmount or other stuff anymore...
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum