mirror of
https://github.com/gryf/wicd.git
synced 2026-03-03 15:25:50 +01:00
experimental:
- Use the full path to wpa_passphrase. - Fix some crashing bugs in the daemon and configscript.py - Port a few changes/fixes from trunk. - Some minor refactoring.
This commit is contained in:
@@ -12,8 +12,8 @@ network={
|
|||||||
group=CCMP TKIP
|
group=CCMP TKIP
|
||||||
key-mgmt=WPA-EAP
|
key-mgmt=WPA-EAP
|
||||||
eap=FAST
|
eap=FAST
|
||||||
identity=$_USERNAME
|
identity="$_USERNAME"
|
||||||
password=$_PASSWORD
|
password="$_PASSWORD"
|
||||||
phase1="fast_provisioning=1"
|
phase1="fast_provisioning=1"
|
||||||
pac-file="$_PAC_FILE"
|
pac-file="$_PAC_FILE"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,6 +55,12 @@ class BackendManager(object):
|
|||||||
if self._valid_backend_file(os.path.join(self.backend_dir, f)):
|
if self._valid_backend_file(os.path.join(self.backend_dir, f)):
|
||||||
be_list.append(f[3:-3])
|
be_list.append(f[3:-3])
|
||||||
return be_list
|
return be_list
|
||||||
|
|
||||||
|
def get_update_interval(self):
|
||||||
|
if self.__loaded_backend:
|
||||||
|
return self.__loaded_backend.UPDATE_INTERVAL
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
def load_backend(self, backend_name):
|
def load_backend(self, backend_name):
|
||||||
""" Load and return a backend module.
|
""" Load and return a backend module.
|
||||||
|
|||||||
@@ -30,11 +30,11 @@ import sys
|
|||||||
import os
|
import os
|
||||||
import gtk
|
import gtk
|
||||||
import ConfigParser
|
import ConfigParser
|
||||||
import dbus
|
|
||||||
import gtk.glade
|
import gtk.glade
|
||||||
|
|
||||||
import wicd.wpath as wpath
|
from wicd import wpath
|
||||||
import wicd.misc as misc
|
from wicd import misc
|
||||||
|
from wicd import dbusmanager
|
||||||
|
|
||||||
_ = misc.get_gettext()
|
_ = misc.get_gettext()
|
||||||
|
|
||||||
@@ -44,20 +44,11 @@ language['before_script'] = _("Pre-connection Script")
|
|||||||
language['after_script'] = _("Post-connection Script")
|
language['after_script'] = _("Post-connection Script")
|
||||||
language['disconnect_script'] = _("Disconnection Script")
|
language['disconnect_script'] = _("Disconnection Script")
|
||||||
|
|
||||||
bus = dbus.SystemBus()
|
dbus = dbusmanager.DBusManager()
|
||||||
|
dbus.connect_to_dbus()
|
||||||
|
|
||||||
# Connect to the daemon
|
wireless = dbus.get_interface("wireless")
|
||||||
try:
|
wired = dbus.get_interface("wired")
|
||||||
print 'Attempting to connect tray to daemon...'
|
|
||||||
proxy_obj = bus.get_object('org.wicd.daemon', '/org/wicd/daemon')
|
|
||||||
print 'Success.'
|
|
||||||
except Exception:
|
|
||||||
print 'Daemon not running...'
|
|
||||||
misc.PromptToStartDaemon()
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
wireless = dbus.Interface(proxy_obj, 'org.wicd.daemon.wireless')
|
|
||||||
wired = dbus.Interface(proxy_obj, 'org.wicd.daemon.wired')
|
|
||||||
|
|
||||||
wireless_conf = wpath.etc + 'wireless-settings.conf'
|
wireless_conf = wpath.etc + 'wireless-settings.conf'
|
||||||
wired_conf = wpath.etc + 'wired-settings.conf'
|
wired_conf = wpath.etc + 'wired-settings.conf'
|
||||||
|
|||||||
@@ -34,6 +34,9 @@ class DBusManager(object):
|
|||||||
""" Returns a dict of dbus interfaces. """
|
""" Returns a dict of dbus interfaces. """
|
||||||
return self._dbus_ifaces
|
return self._dbus_ifaces
|
||||||
|
|
||||||
|
def get_interface(self, iface):
|
||||||
|
return self._dbus_ifaces[iface]
|
||||||
|
|
||||||
def get_bus(self):
|
def get_bus(self):
|
||||||
""" Returns the loaded SystemBus. """
|
""" Returns the loaded SystemBus. """
|
||||||
return self._bus
|
return self._bus
|
||||||
|
|||||||
16
wicd/misc.py
16
wicd/misc.py
@@ -1,8 +1,8 @@
|
|||||||
""" Misc - miscellaneous functions for wicd """
|
""" Misc - miscellaneous functions for wicd """
|
||||||
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2007 Adam Blackburn
|
# Copyright (C) 2007 - 2008 Adam Blackburn
|
||||||
# Copyright (C) 2007 Dan O'Reilly
|
# Copyright (C) 2007 - 2008 Dan O'Reilly
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License Version 2 as
|
# it under the terms of the GNU General Public License Version 2 as
|
||||||
@@ -109,7 +109,7 @@ def IsValidIP(ip):
|
|||||||
|
|
||||||
def PromptToStartDaemon():
|
def PromptToStartDaemon():
|
||||||
""" Prompt the user to start the daemon """
|
""" Prompt the user to start the daemon """
|
||||||
daemonloc = wpath.bin + 'launchdaemon.sh'
|
daemonloc = wpath.sbin + 'wicd'
|
||||||
sudo_prog = choose_sudo_prog()
|
sudo_prog = choose_sudo_prog()
|
||||||
if sudo_prog.endswith("gksu") or sudo_prog.endswith("ktsuss"):
|
if sudo_prog.endswith("gksu") or sudo_prog.endswith("ktsuss"):
|
||||||
msg = '--message'
|
msg = '--message'
|
||||||
@@ -275,8 +275,7 @@ def get_gettext():
|
|||||||
""" Set up gettext for translations. """
|
""" Set up gettext for translations. """
|
||||||
# Borrowed from an excellent post on how to do this at
|
# Borrowed from an excellent post on how to do this at
|
||||||
# http://www.learningpython.com/2006/12/03/translating-your-pythonpygtk-application/
|
# http://www.learningpython.com/2006/12/03/translating-your-pythonpygtk-application/
|
||||||
local_path = os.path.realpath(os.path.dirname(sys.argv[0])) + \
|
local_path = wpath.translations
|
||||||
'/translations'
|
|
||||||
langs = []
|
langs = []
|
||||||
lc, encoding = locale.getdefaultlocale()
|
lc, encoding = locale.getdefaultlocale()
|
||||||
if (lc):
|
if (lc):
|
||||||
@@ -350,6 +349,13 @@ def choose_sudo_prog():
|
|||||||
|
|
||||||
raise WicdError("Couldn't find graphical sudo program.")
|
raise WicdError("Couldn't find graphical sudo program.")
|
||||||
|
|
||||||
|
def find_path(cmd):
|
||||||
|
paths = os.getenv("PATH", default=["/usr/bin", "/usr/local/bin"]).split(':')
|
||||||
|
for path in paths:
|
||||||
|
if os.access(os.path.join(path, cmd), os.F_OK):
|
||||||
|
return os.path.join(path, cmd)
|
||||||
|
return None
|
||||||
|
|
||||||
def get_language_list_gui():
|
def get_language_list_gui():
|
||||||
""" Returns a dict of translatable strings used by the GUI.
|
""" Returns a dict of translatable strings used by the GUI.
|
||||||
|
|
||||||
|
|||||||
@@ -284,8 +284,7 @@ def main():
|
|||||||
""" Starts the connection monitor.
|
""" Starts the connection monitor.
|
||||||
|
|
||||||
Starts a ConnectionStatus instance, sets the status to update
|
Starts a ConnectionStatus instance, sets the status to update
|
||||||
every two seconds, and sets a wireless scan to be called every
|
an amount of time determined by the active backend.
|
||||||
two minutes.
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
monitor = ConnectionStatus()
|
monitor = ConnectionStatus()
|
||||||
|
|||||||
@@ -18,9 +18,9 @@ class WiredConnectThread() -- Connection thread for wired
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2007 Adam Blackburn
|
# Copyright (C) 2007 - 2008 Adam Blackburn
|
||||||
# Copyright (C) 2007 Dan O'Reilly
|
# Copyright (C) 2007 - 2008 Dan O'Reilly
|
||||||
# Copyright (C) 2007 Byron Hillis
|
# Copyright (C) 2007 - 2008 Byron Hillis
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License Version 2 as
|
# it under the terms of the GNU General Public License Version 2 as
|
||||||
@@ -58,22 +58,22 @@ BACKEND = None
|
|||||||
BACKEND_MGR = BackendManager()
|
BACKEND_MGR = BackendManager()
|
||||||
|
|
||||||
def get_backend_list():
|
def get_backend_list():
|
||||||
if not BACKEND_MGR:
|
if BACKEND_MGR:
|
||||||
return [""]
|
|
||||||
else:
|
|
||||||
return BACKEND_MGR.get_available_backends()
|
return BACKEND_MGR.get_available_backends()
|
||||||
|
else:
|
||||||
|
return [""]
|
||||||
|
|
||||||
def get_backend_update_interval():
|
def get_backend_update_interval():
|
||||||
if not BACKEND_MGR:
|
if BACKEND_MGR:
|
||||||
return 4
|
return BACKEND_MGR.get_update_interval()
|
||||||
else:
|
else:
|
||||||
return BACKEND_MGR.UPDATE_INTERVAL
|
return 4 # seconds, this should never happen though.
|
||||||
|
|
||||||
def get_current_backend():
|
def get_current_backend():
|
||||||
if not BACKEND_MGR:
|
if BACKEND_MGR:
|
||||||
return None
|
|
||||||
else:
|
|
||||||
return BACKEND_MGR.get_current_backend()
|
return BACKEND_MGR.get_current_backend()
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
class Controller(object):
|
class Controller(object):
|
||||||
""" Parent class for the different interface types. """
|
""" Parent class for the different interface types. """
|
||||||
@@ -776,14 +776,15 @@ class WirelessConnectThread(ConnectThread):
|
|||||||
self.SetStatus('generating_psk')
|
self.SetStatus('generating_psk')
|
||||||
|
|
||||||
print 'Generating psk...'
|
print 'Generating psk...'
|
||||||
key_pattern = re.compile('network={.*?\spsk=(.*?)\n}.*',
|
wpa_pass_path = misc.find_path('wpa_passphrase')
|
||||||
re.I | re.M | re.S)
|
if wpa_pass_path:
|
||||||
self.network['psk'] = misc.RunRegex(key_pattern,
|
key_pattern = re.compile('network={.*?\spsk=(.*?)\n}.*',
|
||||||
misc.Run(''.join(['wpa_passphrase "',
|
re.I | re.M | re.S)
|
||||||
self.network['essid'], '" "',
|
cmd = ''.join([wpa_pass_path, ' "', self.network['essid'],
|
||||||
_sanitize(self.network['key']), '"'])))
|
'" "', _sanitize(self.network['key']), '"'])
|
||||||
|
self.network['psk'] = misc.RunRegex(key_pattern, misc.Run(cmd))
|
||||||
|
|
||||||
if not self.network['psk']:
|
if not self.network.get('psk'):
|
||||||
self.network['psk'] = self.network['key']
|
self.network['psk'] = self.network['key']
|
||||||
print 'WARNING: PSK generation failed! Falling back to ' + \
|
print 'WARNING: PSK generation failed! Falling back to ' + \
|
||||||
'wireless key.\nPlease report this error to the wicd ' + \
|
'wireless key.\nPlease report this error to the wicd ' + \
|
||||||
|
|||||||
@@ -227,7 +227,7 @@ class PreferencesDialog(object):
|
|||||||
daemon.SetAlwaysShowWiredInterface(self.wiredcheckbox.get_active())
|
daemon.SetAlwaysShowWiredInterface(self.wiredcheckbox.get_active())
|
||||||
daemon.SetAutoReconnect(self.reconnectcheckbox.get_active())
|
daemon.SetAutoReconnect(self.reconnectcheckbox.get_active())
|
||||||
daemon.SetDebugMode(self.debugmodecheckbox.get_active())
|
daemon.SetDebugMode(self.debugmodecheckbox.get_active())
|
||||||
wireless.SetSignalDisplayType(self.displaytypecheckbox.get_active())
|
daemon.SetSignalDisplayType(self.displaytypecheckbox.get_active())
|
||||||
if self.showlistradiobutton.get_active():
|
if self.showlistradiobutton.get_active():
|
||||||
wired.SetWiredAutoConnectMethod(2)
|
wired.SetWiredAutoConnectMethod(2)
|
||||||
elif self.lastusedradiobutton.get_active():
|
elif self.lastusedradiobutton.get_active():
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ else:
|
|||||||
from wicd import wpath
|
from wicd import wpath
|
||||||
from wicd import networking
|
from wicd import networking
|
||||||
from wicd import misc
|
from wicd import misc
|
||||||
|
from wicd.misc import noneToBlankString
|
||||||
from wicd.logfile import ManagedStdio
|
from wicd.logfile import ManagedStdio
|
||||||
from wicd.configmanager import ConfigManager
|
from wicd.configmanager import ConfigManager
|
||||||
|
|
||||||
@@ -131,8 +132,8 @@ class WicdDaemon(dbus.service.Object):
|
|||||||
def SetWiredInterface(self, interface):
|
def SetWiredInterface(self, interface):
|
||||||
""" Sets the wired interface for the daemon to use. """
|
""" Sets the wired interface for the daemon to use. """
|
||||||
print "setting wired interface %s" % (str(interface))
|
print "setting wired interface %s" % (str(interface))
|
||||||
self.wired.wired_interface = interface
|
self.wired.wired_interface = noneToBlankString(interface)
|
||||||
self.wifi.wired_interface = interface
|
self.wifi.wired_interface = noneToBlankString(interface)
|
||||||
self.config.set("Settings", "wired_interface", interface, True)
|
self.config.set("Settings", "wired_interface", interface, True)
|
||||||
|
|
||||||
@dbus.service.method('org.wicd.daemon')
|
@dbus.service.method('org.wicd.daemon')
|
||||||
@@ -193,8 +194,8 @@ class WicdDaemon(dbus.service.Object):
|
|||||||
""" Returns the currently loaded backend. """
|
""" Returns the currently loaded backend. """
|
||||||
return networking.get_current_backend()
|
return networking.get_current_backend()
|
||||||
|
|
||||||
@dbus.server.method('org.wicd.daemon')
|
@dbus.service.method('org.wicd.daemon')
|
||||||
def GetBackendUpdateInterval('org.wicd.daemon'):
|
def GetBackendUpdateInterval(self):
|
||||||
""" Returns status update interval for the loaded backend. """
|
""" Returns status update interval for the loaded backend. """
|
||||||
return networking.get_backend_update_interval()
|
return networking.get_backend_update_interval()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user