1
0
mirror of https://github.com/gryf/wicd.git synced 2026-03-25 21:23:34 +01:00

Fix bug where interface name was being passed to the dhcp client executable twice.

Tweak connect/disconnect to not kill any processes.  Instead it releases leases and terminates the wpa_supplicant instance through its ctrl interface.  This should make wicd handle multiple connections better.
This commit is contained in:
Dan O'Reilly
2009-02-06 19:26:09 -05:00
parent cbbf438f34
commit 450677c83d
5 changed files with 66 additions and 45 deletions

View File

@@ -444,6 +444,12 @@ class WirelessInterface(Interface, wnettools.BaseWirelessInterface):
print 'wpa_supplicant rescan forced...'
cmd = 'wpa_cli -i' + self.iface + ' scan'
misc.Run(cmd)
def StopWPA(self):
""" Terminates wpa using wpa_cli"""
cmd = 'wpa_cli -i %s terminate' % self.iface
if self.verbose: print cmd
misc.Run(cmd)
def GetBSSID(self, iwconfig=None):
""" Get the MAC address for the interface. """

View File

@@ -273,7 +273,11 @@ class WirelessInterface(Interface, wnettools.BaseWirelessInterface):
print "GetNetworks caught an exception: %s" % e
return []
results = self.scan_iface.Scan()
try:
results = self.scan_iface.Scan()
except iwscan.error, e:
print "ERROR: %s"
return []
return filter(None, [self._parse_ap(cell) for cell in results])
def _parse_ap(self, cell):
@@ -334,6 +338,18 @@ class WirelessInterface(Interface, wnettools.BaseWirelessInterface):
return ap
def _connect_to_wpa_ctrl_iface(self):
""" Connect to the wpa ctrl interface. """
ctrl_iface = '/var/run/wpa_supplicant'
try:
socket = [os.path.join(ctrl_iface, s) \
for s in os.listdir(ctrl_iface) if s == self.iface][0]
except OSError, error:
print error
return None
return wpactrl.WPACtrl(socket)
def ValidateAuthentication(self, auth_time):
""" Validate WPA authentication.
@@ -359,15 +375,10 @@ class WirelessInterface(Interface, wnettools.BaseWirelessInterface):
if self.wpa_driver == RALINK_DRIVER:
return True
ctrl_iface = '/var/run/wpa_supplicant'
try:
socket = [os.path.join(ctrl_iface, s) \
for s in os.listdir(ctrl_iface) if s == self.iface][0]
except OSError:
print error
return True
wpa = wpactrl.WPACtrl(socket)
wpa = self._connect_to_wpa_ctrl_iface()
if not wpa:
print "Failed to open ctrl interface"
return False
MAX_TIME = 35
MAX_DISCONNECTED_TIME = 3
@@ -402,6 +413,13 @@ class WirelessInterface(Interface, wnettools.BaseWirelessInterface):
print 'wpa_supplicant authentication may have failed.'
return False
def StopWPA(self):
""" Terminates wpa_supplicant using its ctrl interface. """
wpa = self._connect_to_wpa_ctrl_iface()
if not wpa:
return
wpa.request("TERMINATE")
def _AuthenticateRalinkLegacy(self, network):
""" Authenticate with the specified wireless network.