From 454770e5e99aada3d10f38b2977fff60b7e0156d Mon Sep 17 00:00:00 2001 From: Dan O'Reilly Date: Sat, 28 Feb 2009 16:01:26 -0500 Subject: [PATCH 01/15] Add support for using resolvconf instead of directly editing /etc/resolv.conf if it's available. --- wicd/misc.py | 8 +++-- wicd/networking.py | 26 ++++++++-------- wicd/wnettools.py | 77 +++++++++++++++++++++++++++++----------------- 3 files changed, 67 insertions(+), 44 deletions(-) diff --git a/wicd/misc.py b/wicd/misc.py index feafbf7..b0aaca5 100644 --- a/wicd/misc.py +++ b/wicd/misc.py @@ -96,6 +96,10 @@ def Run(cmd, include_stderr=False, return_pipe=False, return_obj=False): else: err = None fds = False + if return_obj: + std_in = PIPE + else: + std_in = None # We need to make sure that the results of the command we run # are in English, so we set up a temporary environment. @@ -106,8 +110,8 @@ def Run(cmd, include_stderr=False, return_pipe=False, return_obj=False): tmpenv["LANG"] = __LANG try: - f = Popen(cmd, shell=False, stdout=PIPE, stderr=err, close_fds=fds, - cwd='/', env=tmpenv) + f = Popen(cmd, shell=False, stdout=PIPE, stdin=std_in, stderr=err, + close_fds=fds, cwd='/', env=tmpenv) except OSError, e: print "Running command %s failed: %s" % (str(cmd), str(e)) return "" diff --git a/wicd/networking.py b/wicd/networking.py index efb62c5..52c52c7 100644 --- a/wicd/networking.py +++ b/wicd/networking.py @@ -420,7 +420,7 @@ class ConnectThread(threading.Thread): return @abortable - def set_dns_addresses(self): + def set_dns_addresses(self, iface): """ Set the DNS address(es). If static DNS servers or global DNS servers are specified, set them. @@ -428,19 +428,19 @@ class ConnectThread(threading.Thread): """ if self.network.get('use_global_dns'): - BACKEND.SetDNS(misc.Noneify(self.global_dns_1), - misc.Noneify(self.global_dns_2), - misc.Noneify(self.global_dns_3), - misc.Noneify(self.global_dns_dom), - misc.Noneify(self.global_search_dom)) + iface.SetDNS(misc.Noneify(self.global_dns_1), + misc.Noneify(self.global_dns_2), + misc.Noneify(self.global_dns_3), + misc.Noneify(self.global_dns_dom), + misc.Noneify(self.global_search_dom)) elif self.network.get('use_static_dns') and (self.network.get('dns1') or self.network.get('dns2') or self.network.get('dns3')): self.SetStatus('setting_static_dns') - BACKEND.SetDNS(self.network.get('dns1'), - self.network.get('dns2'), - self.network.get('dns3'), - self.network.get('dns_domain'), - self.network.get('search_domain')) + iface.SetDNS(self.network.get('dns1'), + self.network.get('dns2'), + self.network.get('dns3'), + self.network.get('dns_domain'), + self.network.get('search_domain')) @abortable def release_dhcp_clients(self, iface): @@ -799,7 +799,7 @@ class WirelessConnectThread(ConnectThread): # Set up gateway, IP address, and DNS servers. self.set_broadcast_address(wiface) self.set_ip_address(wiface) - self.set_dns_addresses() + self.set_dns_addresses(wiface) # Run post-connection script. self.run_script_if_needed(self.after_script, 'post-connection', @@ -985,7 +985,7 @@ class WiredConnectThread(ConnectThread): # Set gateway, IP adresses, and DNS servers. self.set_broadcast_address(liface) self.set_ip_address(liface) - self.set_dns_addresses() + self.set_dns_addresses(liface) # Run post-connection script. self.run_script_if_needed(self.after_script, 'post-connection', 'wired', diff --git a/wicd/wnettools.py b/wicd/wnettools.py index 774bb6d..fdffe5f 100644 --- a/wicd/wnettools.py +++ b/wicd/wnettools.py @@ -69,7 +69,7 @@ blacklist_strict = '!"#$%&\'()*+,./:;<=>?@[\\]^`{|}~ ' blacklist_norm = ";`$!*|><&\\" blank_trans = maketrans("", "") -__all__ = ["SetDNS", "GetDefaultGateway", "GetWiredInterfaces", +__all__ = ["GetDefaultGateway", "GetWiredInterfaces", "GetWirelessInterfaces", "IsValidWpaSuppDriver"] def _sanitize_string(string): @@ -84,33 +84,6 @@ def _sanitize_string_strict(string): else: return string -def SetDNS(dns1=None, dns2=None, dns3=None, dns_dom=None, search_dom=None): - """ Set the DNS of the system to the specified DNS servers. - - Opens up resolv.conf and writes in the nameservers. - - Keyword arguments: - dns1 -- IP address of DNS server 1 - dns2 -- IP address of DNS server 2 - dns3 -- IP address of DNS server 3 - dns_dom -- DNS domain - search_dom -- DNS search domain - - """ - resolv = open("/etc/resolv.conf", "w") - if dns_dom: - resolv.write("domain %s\n" % dns_dom) - if search_dom: - resolv.write('search %s\n' % search_dom) - for dns in [dns1, dns2, dns3]: - if dns: - if misc.IsValidIP(dns): - print 'Setting DNS : ' + dns - resolv.write('nameserver ' + dns + '\n') - else: - print 'DNS IP is not a valid IP address, not writing to resolv.conf' - resolv.close() - def GetDefaultGateway(): """ Attempts to determine the default gateway by parsing route -n. """ route_info = misc.Run("route -n") @@ -286,6 +259,11 @@ class BaseInterface(object): self.CheckWirelessTools() self.CheckSudoApplications() self.CheckRouteFlushTool() + self.CheckResolvConf() + + def CheckResolvConf(self): + """ Checks for the existence of resolvconf.""" + self.resolvconf_cmd = self._find_program_path("resolvconf") def CheckDHCP(self): """ Check for the existence of valid DHCP clients. @@ -513,7 +491,48 @@ class BaseInterface(object): return if self.verbose: print cmd misc.Run(cmd) - + + def SetDNS(self, dns1=None, dns2=None, dns3=None, + dns_dom=None, search_dom=None): + """ Set the DNS of the system to the specified DNS servers. + + Opens up resolv.conf and writes in the nameservers. + + Keyword arguments: + dns1 -- IP address of DNS server 1 + dns2 -- IP address of DNS server 2 + dns3 -- IP address of DNS server 3 + dns_dom -- DNS domain + search_dom -- DNS search domain + + """ + resolv_params = "" + if dns_dom: + resolv_params = ''.join([resolv_params, 'domain ', dns_dom, '\n']) + if search_dom: + resolv_params = ''.join([resolv_params, 'search ', search_dom, + '\n']) + valid_dns_list = ['nameserver'] + for dns in [dns1, dns2, dns3]: + if dns: + if misc.IsValidIP(dns): + print 'Setting DNS : ' + dns + valid_dns_list.append(dns) + else: + print 'DNS IP is not a valid IP address, skipping' + # Make sure we have more than just 'nameserver' in the list. + if len(valid_dns_list) > 1: + resolv_params += ' '.join(valid_dns_list) + '\n' + + if self.resolvconf_cmd: + print "running resolvconf" + p = misc.Run(' '.join([self.resolvconf_cmd, '-a', self.iface]), + include_stderr=True, return_obj=True) + p.communicate(input=resolv_params)[0] + else: + resolv = open("/etc/resolv.conf", "w") + resolv.write(resolv_params + "\n") + resolv.close() def FlushRoutes(self): """ Flush network routes for this device. """ From c23708b44443794b0ccdc10347202f6fae410f2a Mon Sep 17 00:00:00 2001 From: drf Date: Sun, 1 Mar 2009 16:01:21 +0100 Subject: [PATCH 02/15] Starting implementation of current bitrate retrieval --- wicd/backends/be-ioctl.py | 14 ++++++++++++++ wicd/networking.py | 11 +++++++++++ wicd/wicd-daemon.py | 5 +++++ wicd/wnettools.py | 17 +++++++++++++++++ 4 files changed, 47 insertions(+) diff --git a/wicd/backends/be-ioctl.py b/wicd/backends/be-ioctl.py index b4681a0..c799874 100644 --- a/wicd/backends/be-ioctl.py +++ b/wicd/backends/be-ioctl.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# -*- coding: utf-8 -*- """ ioctl Network interface control tools for wicd. @@ -479,6 +480,19 @@ class WirelessInterface(Interface, wnettools.BaseWirelessInterface): raw_addr = struct.unpack("xxBBBBBB", result[:8]) return "%02X:%02X:%02X:%02X:%02X:%02X" % raw_addr + def GetCurrentBitrate(self, iwconfig=None): + """ Get the current bitrate for the interface. """ + if not self.iface: return "" + data = (self.iface + '\0' * 32)[:32] + try: + result = fcntl.ioctl(self.sock.fileno(), SIOCGIWAP, data)[16:] + except IOError, e: + if self.verbose: + print "SIOCGIWAP failed: " + str(e) + return "" + raw_addr = struct.unpack("xxBBBBBB", result[:8]) + return "%02X:%02X:%02X:%02X:%02X:%02X" % raw_addr + def GetSignalStrength(self, iwconfig=None): """ Get the signal strength of the current network. diff --git a/wicd/networking.py b/wicd/networking.py index c308790..5f97455 100644 --- a/wicd/networking.py +++ b/wicd/networking.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# -*- coding: utf-8 -*- """ networking - Provides wrappers for common network operations @@ -624,6 +625,16 @@ class Wireless(Controller): """ return self.wiface.GetBSSID() + def GetCurrentBitrate(self): + """ Get the current bitrate of the interface. + + Returns: + The bitrate of the active access point as a string, or + None the bitrate can't be found. + + """ + return self.wiface.GetCurrentBitrate() + def GetIwconfig(self): """ Get the out of iwconfig. """ return self.wiface.GetIwconfig() diff --git a/wicd/wicd-daemon.py b/wicd/wicd-daemon.py index c4015ce..ecbf23f 100644 --- a/wicd/wicd-daemon.py +++ b/wicd/wicd-daemon.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# -*- coding: utf-8 -*- """ wicd - wireless connection daemon implementation. @@ -995,6 +996,10 @@ class WirelessDaemon(dbus.service.Object): def GetApBssid(self): return self.wifi.GetBSSID() + @dbus.service.method('org.wicd.daemon.wireless') + def GetCurrentBitrate(self): + return self.wifi.GetCurrentBitrate() + @dbus.service.method('org.wicd.daemon.wireless') def CreateAdHocNetwork(self, essid, channel, ip, enctype, key, encused, ics): diff --git a/wicd/wnettools.py b/wicd/wnettools.py index 774bb6d..c1ee8de 100644 --- a/wicd/wnettools.py +++ b/wicd/wnettools.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# -*- coding: utf-8 -*- """ Network interface control tools for wicd. @@ -59,6 +60,7 @@ wpa2_pattern = re.compile('(WPA2)', __re_mode) #iwconfig-only regular expressions. ip_pattern = re.compile(r'inet [Aa]d?dr[^.]*:([^.]*\.[^.]*\.[^.]*\.[0-9]*)',re.S) bssid_pattern = re.compile('.*Access Point: (([0-9A-Z]{2}:){5}[0-9A-Z]{2})', __re_mode) +bitrate_pattern = re.compile('.*Bit Rate=(.*?)s', __re_mode) # Regular expressions for wpa_cli output auth_pattern = re.compile('.*wpa_state=(.*?)\n', __re_mode) @@ -1056,6 +1058,9 @@ class BaseWirelessInterface(BaseInterface): freq = misc.RunRegex(freq_pattern, cell) ap['channel'] = self._FreqToChannel(freq) + # Bit Rate + ap['bitrate'] = misc.RunRegex(bitrate_pattern, cell) + # BSSID ap['bssid'] = misc.RunRegex(ap_mac_pattern, cell) @@ -1180,6 +1185,18 @@ class BaseWirelessInterface(BaseInterface): bssid = misc.RunRegex(bssid_pattern, output) return bssid + def GetCurrentBitrate(self, iwconfig=None): + """ Get the MAC address for the interface. """ + if not iwconfig: + cmd = 'iwconfig ' + self.iface + if self.verbose: print cmd + output = misc.Run(cmd) + else: + output = iwconfig + + bitrate = misc.RunRegex(bitrate_pattern, output) + return bitrate + 's' + def _get_link_quality(self, output): """ Parse out the link quality from iwlist scan or iwconfig output. """ try: From db80f31e03a22256e856f6eb643be3de531cbd64 Mon Sep 17 00:00:00 2001 From: Dario Freddi Date: Sun, 1 Mar 2009 16:46:58 +0100 Subject: [PATCH 03/15] Adding per-channel bitrate information as a string --- wicd/wnettools.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/wicd/wnettools.py b/wicd/wnettools.py index c1ee8de..49ae1af 100644 --- a/wicd/wnettools.py +++ b/wicd/wnettools.py @@ -50,6 +50,7 @@ channel_pattern = re.compile('.*Channel:? ?(\d\d?)', __re_mode) strength_pattern = re.compile('.*Quality:?=? ?(\d+)\s*/?\s*(\d*)', __re_mode) altstrength_pattern = re.compile('.*Signal level:?=? ?(\d+)\s*/?\s*(\d*)', __re_mode) signaldbm_pattern = re.compile('.*Signal level:?=? ?(-\d\d*)', __re_mode) +bitrates_pattern = re.compile('.*Bit Rates:(.*?)E', __re_mode) mode_pattern = re.compile('.*Mode:(.*?)\n', __re_mode) freq_pattern = re.compile('.*Frequency:(.*?)\n', __re_mode) wep_pattern = re.compile('.*Encryption key:(.*?)\n', __re_mode) @@ -1059,7 +1060,7 @@ class BaseWirelessInterface(BaseInterface): ap['channel'] = self._FreqToChannel(freq) # Bit Rate - ap['bitrate'] = misc.RunRegex(bitrate_pattern, cell) + ap['bitrates'] = misc.RunRegex(bitrates_pattern, cell).replace('\n', '; ').replace(' ', '')[:-2] # BSSID ap['bssid'] = misc.RunRegex(ap_mac_pattern, cell) From 2898adec48009abad58847d3c2b4d783a7672a3b Mon Sep 17 00:00:00 2001 From: Dario Freddi Date: Sun, 1 Mar 2009 19:22:30 +0100 Subject: [PATCH 04/15] Adding the possibility of a custom iwconfig --- wicd/networking.py | 4 ++-- wicd/wicd-daemon.py | 10 ++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/wicd/networking.py b/wicd/networking.py index 5f97455..c6b81ba 100644 --- a/wicd/networking.py +++ b/wicd/networking.py @@ -625,7 +625,7 @@ class Wireless(Controller): """ return self.wiface.GetBSSID() - def GetCurrentBitrate(self): + def GetCurrentBitrate(self, iwconfig): """ Get the current bitrate of the interface. Returns: @@ -633,7 +633,7 @@ class Wireless(Controller): None the bitrate can't be found. """ - return self.wiface.GetCurrentBitrate() + return self.wiface.GetCurrentBitrate(iwconfig) def GetIwconfig(self): """ Get the out of iwconfig. """ diff --git a/wicd/wicd-daemon.py b/wicd/wicd-daemon.py index ecbf23f..7d75a27 100644 --- a/wicd/wicd-daemon.py +++ b/wicd/wicd-daemon.py @@ -997,8 +997,8 @@ class WirelessDaemon(dbus.service.Object): return self.wifi.GetBSSID() @dbus.service.method('org.wicd.daemon.wireless') - def GetCurrentBitrate(self): - return self.wifi.GetCurrentBitrate() + def GetCurrentBitrate(self, iwconfig): + return self.wifi.GetCurrentBitrate(iwconfig) @dbus.service.method('org.wicd.daemon.wireless') def CreateAdHocNetwork(self, essid, channel, ip, enctype, key, encused, @@ -1130,6 +1130,12 @@ class WirelessDaemon(dbus.service.Object): ip = self.wifi.GetIP(ifconfig) return ip + @dbus.service.method('org.wicd.daemon.wireless') + def GetOperationalMode(self, ifconfig=""): + """ Returns the IP associated with the wireless interface. """ + ip = self.wifi.GetOperationalMode(ifconfig) + return ip + @dbus.service.method('org.wicd.daemon.wireless') def CheckWirelessConnectingMessage(self): """ Returns the wireless interface's status message. """ From 9213c7c333049e2b5a362fb1a3b9186d1426af46 Mon Sep 17 00:00:00 2001 From: Dario Freddi Date: Sun, 1 Mar 2009 19:31:34 +0100 Subject: [PATCH 05/15] Adding GetOperationalMode() to determine op mode of an interface --- wicd/networking.py | 10 ++++++++++ wicd/wicd-daemon.py | 5 +++++ wicd/wnettools.py | 13 +++++++++++++ 3 files changed, 28 insertions(+) diff --git a/wicd/networking.py b/wicd/networking.py index c6b81ba..609e50a 100644 --- a/wicd/networking.py +++ b/wicd/networking.py @@ -635,6 +635,16 @@ class Wireless(Controller): """ return self.wiface.GetCurrentBitrate(iwconfig) + def GetOperationalMode(self, iwconfig): + """ Get the current operational mode of the interface. + + Returns: + The operational mode of the interface as a string, or + None if the operational mode can't be found. + + """ + return self.wiface.GetOperationalMode(iwconfig) + def GetIwconfig(self): """ Get the out of iwconfig. """ return self.wiface.GetIwconfig() diff --git a/wicd/wicd-daemon.py b/wicd/wicd-daemon.py index 7d75a27..33958c3 100644 --- a/wicd/wicd-daemon.py +++ b/wicd/wicd-daemon.py @@ -1000,6 +1000,11 @@ class WirelessDaemon(dbus.service.Object): def GetCurrentBitrate(self, iwconfig): return self.wifi.GetCurrentBitrate(iwconfig) + @dbus.service.method('org.wicd.daemon.wireless') + def GetOperationalMode(self, iwconfig): + """ Returns the operational mode for the iwconfig parameter """ + return misc.to_unicode(self.wifi.GetOperationalMode()) + @dbus.service.method('org.wicd.daemon.wireless') def CreateAdHocNetwork(self, essid, channel, ip, enctype, key, encused, ics): diff --git a/wicd/wnettools.py b/wicd/wnettools.py index 49ae1af..8a7f3f0 100644 --- a/wicd/wnettools.py +++ b/wicd/wnettools.py @@ -62,6 +62,7 @@ wpa2_pattern = re.compile('(WPA2)', __re_mode) ip_pattern = re.compile(r'inet [Aa]d?dr[^.]*:([^.]*\.[^.]*\.[^.]*\.[0-9]*)',re.S) bssid_pattern = re.compile('.*Access Point: (([0-9A-Z]{2}:){5}[0-9A-Z]{2})', __re_mode) bitrate_pattern = re.compile('.*Bit Rate=(.*?)s', __re_mode) +opmode_pattern = re.compile('.*Mode:(.*?) ', __re_mode) # Regular expressions for wpa_cli output auth_pattern = re.compile('.*wpa_state=(.*?)\n', __re_mode) @@ -1198,6 +1199,18 @@ class BaseWirelessInterface(BaseInterface): bitrate = misc.RunRegex(bitrate_pattern, output) return bitrate + 's' + def GetOperationalMode(self, iwconfig=None): + """ Get the MAC address for the interface. """ + if not iwconfig: + cmd = 'iwconfig ' + self.iface + if self.verbose: print cmd + output = misc.Run(cmd) + else: + output = iwconfig + + opmode = misc.RunRegex(opmode_pattern, output) + return opmode + def _get_link_quality(self, output): """ Parse out the link quality from iwlist scan or iwconfig output. """ try: From 23cb084036998eb538e2a6ec1e79bd557a0b3361 Mon Sep 17 00:00:00 2001 From: Dario Freddi Date: Sun, 1 Mar 2009 20:19:16 +0100 Subject: [PATCH 06/15] Adding available auth methods --- wicd/networking.py | 10 ++++++++++ wicd/wicd-daemon.py | 7 ++++++- wicd/wnettools.py | 13 +++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/wicd/networking.py b/wicd/networking.py index 609e50a..ef4208e 100644 --- a/wicd/networking.py +++ b/wicd/networking.py @@ -645,6 +645,16 @@ class Wireless(Controller): """ return self.wiface.GetOperationalMode(iwconfig) + def GetAvailableAuthMethods(self, iwlistauth): + """ Get the available authentication methods for the interface. + + Returns: + The available authentication methods of the interface as a string, or + None if the auth methods can't be found. + + """ + return self.wiface.GetAvailableAuthMethods(iwlistauth) + def GetIwconfig(self): """ Get the out of iwconfig. """ return self.wiface.GetIwconfig() diff --git a/wicd/wicd-daemon.py b/wicd/wicd-daemon.py index 33958c3..0f4704a 100644 --- a/wicd/wicd-daemon.py +++ b/wicd/wicd-daemon.py @@ -1003,7 +1003,12 @@ class WirelessDaemon(dbus.service.Object): @dbus.service.method('org.wicd.daemon.wireless') def GetOperationalMode(self, iwconfig): """ Returns the operational mode for the iwconfig parameter """ - return misc.to_unicode(self.wifi.GetOperationalMode()) + return misc.to_unicode(self.wifi.GetOperationalMode(iwconfig)) + + @dbus.service.method('org.wicd.daemon.wireless') + def GetAvailableAuthMethods(self, iwlistauth): + """ Returns the operational mode for the iwlistauth parameter """ + return misc.to_unicode(self.wifi.GetAvailableAuthMethods(iwlistauth)) @dbus.service.method('org.wicd.daemon.wireless') def CreateAdHocNetwork(self, essid, channel, ip, enctype, key, encused, diff --git a/wicd/wnettools.py b/wicd/wnettools.py index 8a7f3f0..3bf22d0 100644 --- a/wicd/wnettools.py +++ b/wicd/wnettools.py @@ -63,6 +63,7 @@ ip_pattern = re.compile(r'inet [Aa]d?dr[^.]*:([^.]*\.[^.]*\.[^.]*\.[0-9]*)',re.S bssid_pattern = re.compile('.*Access Point: (([0-9A-Z]{2}:){5}[0-9A-Z]{2})', __re_mode) bitrate_pattern = re.compile('.*Bit Rate=(.*?)s', __re_mode) opmode_pattern = re.compile('.*Mode:(.*?) ', __re_mode) +authmethods_pattern = re.compile('.*Authentication capabilities :\n(.*?)Current', __re_mode) # Regular expressions for wpa_cli output auth_pattern = re.compile('.*wpa_state=(.*?)\n', __re_mode) @@ -1211,6 +1212,18 @@ class BaseWirelessInterface(BaseInterface): opmode = misc.RunRegex(opmode_pattern, output) return opmode + def GetAvailableAuthMethods(self, iwlistauth=None): + """ Get the MAC address for the interface. """ + if not iwlistauth: + cmd = 'iwlist ' + self.iface + ' auth' + if self.verbose: print cmd + output = misc.Run(cmd) + else: + output = iwlistauth + + authm = misc.RunRegex(authmethods_pattern, output).replace(' ', '').replace('\t', '').replace('\n', '; ')[:-2] + return authm + def _get_link_quality(self, output): """ Parse out the link quality from iwlist scan or iwconfig output. """ try: From 1e65babbd91a128171b8b012ccfd017dab3b717f Mon Sep 17 00:00:00 2001 From: Dario Freddi Date: Tue, 3 Mar 2009 11:40:34 +0100 Subject: [PATCH 07/15] Removing placeholders, and fixing issues pointed out by Dan --- wicd/backends/be-ioctl.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/wicd/backends/be-ioctl.py b/wicd/backends/be-ioctl.py index bce0986..3d03c64 100644 --- a/wicd/backends/be-ioctl.py +++ b/wicd/backends/be-ioctl.py @@ -485,27 +485,26 @@ class WirelessInterface(Interface, wnettools.BaseWirelessInterface): """ Get the current bitrate for the interface. """ if not self.iface: return "" data = (self.iface + '\0' * 32)[:32] - s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) fmt = "ihbb" size = struct.calcsize(fmt) try: - data = fcntl.ioctl(s, 0x8B21, ifreq)[16:]  # 0x8B21 is SIOCGIWRATE in /usr/include/linux/wireless.h + result = fcntl.ioctl(self.sock.fileno(), SIOCGIWRATE, data)[16:] except IOError, e: if self.verbose: - print "SIOCGIWAP failed: " + str(e) + print "SIOCGIWRATE failed: " + str(e) return "" - f, e, x, x = struct.unpack(fmt, data[:size]) + f, e, x, x = struct.unpack(fmt, result[:size]) return (f / 1000000) + ' Mb/s' - def GetOperationalMode(self, iwconfig=None): + #def GetOperationalMode(self, iwconfig=None): """ Get the MAC address for the interface. """ # TODO: implement me - return '' + # return '' - def GetAvailableAuthMethods(self, iwlistauth=None): + #def GetAvailableAuthMethods(self, iwlistauth=None): """ Get the MAC address for the interface. """ # TODO: Implement me - return '' + # return '' def GetSignalStrength(self, iwconfig=None): """ Get the signal strength of the current network. From 1efa36014f5b2aa13d086d6db37806343d669ea6 Mon Sep 17 00:00:00 2001 From: Dario Freddi Date: Sat, 7 Mar 2009 12:16:45 +0100 Subject: [PATCH 08/15] Forgot to add a definition --- wicd/backends/be-ioctl.py | 1 + 1 file changed, 1 insertion(+) diff --git a/wicd/backends/be-ioctl.py b/wicd/backends/be-ioctl.py index 3d03c64..1d2ad9e 100644 --- a/wicd/backends/be-ioctl.py +++ b/wicd/backends/be-ioctl.py @@ -67,6 +67,7 @@ SIOCGIWESSID = 0x8B1B SIOCGIWRANGE = 0x8B0B SIOCGIWAP = 0x8B15 SIOCGIWSTATS = 0x8B0F +SIOCGIWRATE = 0x8B21 # Got these from /usr/include/sockios.h SIOCGIFADDR = 0x8915 From 4365a8406bb6c1582535298d7241075fc1480dee Mon Sep 17 00:00:00 2001 From: Dan O'Reilly Date: Sun, 8 Mar 2009 15:58:44 -0400 Subject: [PATCH 09/15] Fix suse init script. --- in/init=suse=wicd.in | 1 + wicd/networking.py | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/in/init=suse=wicd.in b/in/init=suse=wicd.in index 6a5812a..2dec20d 100755 --- a/in/init=suse=wicd.in +++ b/in/init=suse=wicd.in @@ -3,6 +3,7 @@ ### BEGIN INIT INFO # Provides: wicd-daemon # Required-Start: dbus +# Required-Stop: # Default-Start: 3 4 5 # Default-Stop: # Description: wicd, a wired and wireless connection manager. diff --git a/wicd/networking.py b/wicd/networking.py index 25ece03..8593496 100644 --- a/wicd/networking.py +++ b/wicd/networking.py @@ -131,7 +131,7 @@ def expand_script_macros(script, msg, bssid, essid): print "Expanded '%s' to '%s'" % (script, expanded) return expanded - + class Controller(object): """ Parent class for the different interface types. """ def __init__(self, debug=False): @@ -335,7 +335,6 @@ class ConnectThread(threading.Thread): finally: self.lock.release() - def GetStatus(self): """ Get the threads current status message in a thread-safe way. From 1327bfcc32880acb48d0fad94cb057c61d6f6ae7 Mon Sep 17 00:00:00 2001 From: Andrew Psaltis Date: Sun, 8 Mar 2009 17:38:47 -0400 Subject: [PATCH 10/15] Added an init script for Lunar Linux. --- in/init=lunar=wicd.in | 13 +++++++++++++ setup.py | 3 +++ 2 files changed, 16 insertions(+) create mode 100644 in/init=lunar=wicd.in diff --git a/in/init=lunar=wicd.in b/in/init=lunar=wicd.in new file mode 100644 index 0000000..2045aef --- /dev/null +++ b/in/init=lunar=wicd.in @@ -0,0 +1,13 @@ +#!/bin/bash +# +# Startup script for wicd +# +# chkconfig: 345 99 01 +# +# description: wicd wireless/wired internet connection daemon +# +# processname: wicd +# pidfile: %PIDFILE% +# + +. /lib/lsb.init_functions $1 diff --git a/setup.py b/setup.py index f7c6e3a..b96de8d 100755 --- a/setup.py +++ b/setup.py @@ -162,6 +162,9 @@ class configure(Command): self.initfile = 'init/pld/wicd' elif os.path.exists('/usr/bin/crux'): self.init = '/etc/rc.d/' + elif os.path.exists('/etc/lunar.release'): + self.init='/etc/init.d/' + self.initfile = 'init/lunar/wicd' else: self.init = 'FAIL' self.no_install_init = True From 98277aafb28366224bea564e85053b1a491331ad Mon Sep 17 00:00:00 2001 From: Andrew Psaltis Date: Sun, 8 Mar 2009 18:02:44 -0400 Subject: [PATCH 11/15] Fixed the Lunar init script. --- in/init=lunar=wicd.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100644 => 100755 in/init=lunar=wicd.in diff --git a/in/init=lunar=wicd.in b/in/init=lunar=wicd.in old mode 100644 new mode 100755 index 2045aef..83698ff --- a/in/init=lunar=wicd.in +++ b/in/init=lunar=wicd.in @@ -10,4 +10,4 @@ # pidfile: %PIDFILE% # -. /lib/lsb.init_functions $1 +. /lib/lsb/init_functions $1 From d336a0f42dad899b35d264b1f13b1241f8fc1bef Mon Sep 17 00:00:00 2001 From: Andrew Psaltis Date: Sun, 8 Mar 2009 18:31:36 -0400 Subject: [PATCH 12/15] Fixed the fix. --- in/init=lunar=wicd.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/in/init=lunar=wicd.in b/in/init=lunar=wicd.in index 83698ff..b16ff30 100755 --- a/in/init=lunar=wicd.in +++ b/in/init=lunar=wicd.in @@ -10,4 +10,4 @@ # pidfile: %PIDFILE% # -. /lib/lsb/init_functions $1 +. /lib/lsb/init-functions $1 From 5170411595738d2e8047863c790d269d10fd0958 Mon Sep 17 00:00:00 2001 From: Dan O'Reilly Date: Sun, 8 Mar 2009 20:38:54 -0400 Subject: [PATCH 13/15] Create an error dialog when we get a DBus access denied error. --- wicd/translations.py | 1 + wicd/wicd-client.py | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/wicd/translations.py b/wicd/translations.py index 397236c..98c3ac7 100644 --- a/wicd/translations.py +++ b/wicd/translations.py @@ -160,6 +160,7 @@ language['cannot_start_daemon'] = _('Unable to connect to wicd daemon DBus inter "This typically means there was a problem starting the daemon. " + \ "Check the wicd log for more info') language['lost_dbus'] = _('The wicd daemon has shut down, the UI will not function properly until it is restarted.') +language['access_denied'] = _("Unable to contact the wicd dameon due to an access denied error from DBus. Please check your DBus configuration.") language['configuring_wireless'] = _('Configuring preferences for wireless network "$A" ($B)') language['configuring_wired'] = _('Configuring preferences for wired profile "$A"') language['scan'] = _('Scan') diff --git a/wicd/wicd-client.py b/wicd/wicd-client.py index f82dd08..8cac87e 100755 --- a/wicd/wicd-client.py +++ b/wicd/wicd-client.py @@ -79,7 +79,11 @@ def catchdbus(func): try: return func(*args, **kwargs) except DBusException, e: - print "warning: ignoring exception %s" % e + if "DBus.Error.AccessDenied" in e: + error(None, language['access_denied']) + raise DBusException(e) + else: + print "warning: ignoring exception %s" % e return None wrapper.__name__ = func.__name__ wrapper.__module__ = func.__module__ @@ -693,6 +697,7 @@ def handle_no_dbus(): block=False)) return False +@catchdbus def main(argv): """ The main frontend program. From 79f64e4180a06c1b7c851ecebb6cfe9ee5750e39 Mon Sep 17 00:00:00 2001 From: Dan O'Reilly Date: Sun, 8 Mar 2009 23:03:04 -0400 Subject: [PATCH 14/15] Undoing accidental commit. From f4fc8ae949a8c9cb82428965cdc79a98a46d3f36 Mon Sep 17 00:00:00 2001 From: Dan O'Reilly Date: Mon, 9 Mar 2009 01:46:31 -0400 Subject: [PATCH 15/15] Add lunar init directory.