1
0
mirror of https://github.com/gryf/wicd.git synced 2026-03-28 23:13:33 +01:00

Merged wired-encryption implementation by Joe MacMahon. Thanks!

This commit is contained in:
David Paleino
2012-02-02 17:40:20 +01:00
9 changed files with 289 additions and 110 deletions

View File

@@ -183,15 +183,82 @@ class AdvancedSettingsDialog(urwid.WidgetWrap):
def ready_widgets(self,ui,body): def ready_widgets(self,ui,body):
pass pass
def combo_on_change(self,combobox,new_index,user_data=None):
self.change_encrypt_method()
# More or less ripped from netentry.py
def change_encrypt_method(self):
#self.lbox_encrypt = urwid.ListBox()
self.encryption_info = {}
wid,ID = self.encryption_combo.get_focus()
methods = self.encrypt_types
if self._w.body.body.__contains__(self.pile_encrypt):
self._w.body.body.pop(self._w.body.body.__len__()-1)
# If nothing is selected, select the first entry.
if ID == -1:
self.encryption_combo.set_focus(0)
ID = 0
theList = []
for type_ in ['required', 'optional']:
fields = methods[ID][type_]
for field in fields:
try:
edit = MaskingEdit(('editcp',language[field[1].lower().replace(' ','_')]+': '))
except KeyError:
edit = MaskingEdit(('editcp',field[1].replace(' ','_')+': '))
edit.set_mask_mode('no_focus')
theList.append(edit)
# Add the data to any array, so that the information
# can be easily accessed by giving the name of the wanted
# data.
self.encryption_info[field[0]] = [edit, type_]
if self.wired:
edit.set_edit_text(noneToBlankString(
wired.GetWiredProperty(field[0])))
else:
edit.set_edit_text(noneToBlankString(
wireless.GetWirelessProperty(self.networkid, field[0])))
#FIXME: This causes the entire pile to light up upon use.
# Make this into a listbox?
self.pile_encrypt = DynWrap(urwid.Pile(theList),attrs=('editbx','editnfc'))
self.pile_encrypt.set_sensitive(self.encryption_chkbox.get_state())
self._w.body.body.insert(self._w.body.body.__len__(),self.pile_encrypt)
#self._w.body.body.append(self.pile_encrypt)
def encryption_toggle(self,chkbox,new_state,user_data=None):
self.encryption_combo.set_sensitive(new_state)
self.pile_encrypt.set_sensitive(new_state)
class WiredSettingsDialog(AdvancedSettingsDialog): class WiredSettingsDialog(AdvancedSettingsDialog):
def __init__(self,name): def __init__(self,name,parent):
global wired, daemon global wired, daemon
AdvancedSettingsDialog.__init__(self) AdvancedSettingsDialog.__init__(self)
self.wired = True
self.set_default = urwid.CheckBox(_('Use as default profile (overwrites any previous default)')) self.set_default = urwid.CheckBox(_('Use as default profile (overwrites any previous default)'))
#self.cur_default = #self.cur_default =
# Add widgets to listbox # Add widgets to listbox
self._w.body.body.append(self.set_default) self._w.body.body.append(self.set_default)
self.parent = parent
encryption_t = _('Use Encryption')
self.encryption_chkbox = urwid.CheckBox(encryption_t,on_state_change=self.encryption_toggle)
self.encryption_combo = ComboBox(callback=self.combo_on_change)
self.pile_encrypt = None
# _w is a Frame, _w.body is a ListBox, _w.body.body is the ListWalker :-)
self._listbox.body.append(self.encryption_chkbox)
self._listbox.body.append(self.encryption_combo)
self.encrypt_types = misc.LoadEncryptionMethods(wired = True)
self.set_values()
self.prof_name = name self.prof_name = name
title = _('Configuring preferences for wired profile "$A"').replace('$A',self.prof_name) title = _('Configuring preferences for wired profile "$A"').replace('$A',self.prof_name)
self._w.header = urwid.Text( ('header',title),align='right' ) self._w.header = urwid.Text( ('header',title),align='right' )
@@ -218,6 +285,26 @@ class WiredSettingsDialog(AdvancedSettingsDialog):
self.set_default.set_state(to_bool(wired.GetWiredProperty("default"))) self.set_default.set_state(to_bool(wired.GetWiredProperty("default")))
# Throw the encryption stuff into a list
list = []
activeID = -1 # Set the menu to this item when we are done
for x, enc_type in enumerate(self.encrypt_types):
list.append(enc_type['name'])
if enc_type['type'] == wired.GetWiredProperty("enctype"):
activeID = x
self.encryption_combo.set_list(list)
self.encryption_combo.set_focus(activeID)
if wired.GetWiredProperty("encryption_enabled"):
self.encryption_chkbox.set_state(True,do_callback=False)
self.encryption_combo.set_sensitive(True)
#self.lbox_encrypt_info.set_sensitive(True)
else:
self.encryption_combo.set_focus(0)
self.encryption_combo.set_sensitive(False)
self.change_encrypt_method()
dhcphname = wired.GetWiredProperty("dhcphostname") dhcphname = wired.GetWiredProperty("dhcphostname")
if dhcphname is None: if dhcphname is None:
dhcphname = os.uname()[1] dhcphname = os.uname()[1]
@@ -227,6 +314,30 @@ class WiredSettingsDialog(AdvancedSettingsDialog):
self.dhcp_h.set_edit_text(unicode(dhcphname)) self.dhcp_h.set_edit_text(unicode(dhcphname))
def save_settings(self): def save_settings(self):
# Check encryption info
if self.encryption_chkbox.get_state():
encrypt_info = self.encryption_info
encrypt_methods = self.encrypt_types
self.set_net_prop("enctype",
encrypt_methods[self.encryption_combo.get_focus()[1] ]['type'])
self.set_net_prop("encryption_enabled", True)
# Make sure all required fields are filled in.
for entry_info in encrypt_info.itervalues():
if entry_info[0].get_edit_text() == "" \
and entry_info[1] == 'required':
error(self.ui, self.parent,"%s (%s)" \
% (_('Required encryption information is missing.'),
entry_info[0].get_caption()[0:-2] )
)
return False
for entry_key, entry_info in encrypt_info.iteritems():
self.set_net_prop(entry_key, noneToString(entry_info[0].
get_edit_text()))
else:
self.set_net_prop("enctype", "None")
self.set_net_prop("encryption_enabled", False)
AdvancedSettingsDialog.save_settings(self) AdvancedSettingsDialog.save_settings(self)
if self.set_default.get_state(): if self.set_default.get_state():
wired.UnsetWiredDefault() wired.UnsetWiredDefault()
@@ -250,6 +361,8 @@ class WirelessSettingsDialog(AdvancedSettingsDialog):
def __init__(self,networkID,parent): def __init__(self,networkID,parent):
global wireless, daemon global wireless, daemon
AdvancedSettingsDialog.__init__(self) AdvancedSettingsDialog.__init__(self)
self.wired = False
self.networkid = networkID self.networkid = networkID
self.parent = parent self.parent = parent
global_settings_t = _('Use these settings for all networks sharing this essid') global_settings_t = _('Use these settings for all networks sharing this essid')
@@ -271,13 +384,6 @@ class WirelessSettingsDialog(AdvancedSettingsDialog):
title = _('Configuring preferences for wireless network "$A" ($B)').replace('$A',wireless.GetWirelessProperty(networkID,'essid')).replace('$B',wireless.GetWirelessProperty(networkID,'bssid')) title = _('Configuring preferences for wireless network "$A" ($B)').replace('$A',wireless.GetWirelessProperty(networkID,'essid')).replace('$B',wireless.GetWirelessProperty(networkID,'bssid'))
self._w.header = urwid.Text(('header',title),align='right' ) self._w.header = urwid.Text(('header',title),align='right' )
def encryption_toggle(self,chkbox,new_state,user_data=None):
self.encryption_combo.set_sensitive(new_state)
self.pile_encrypt.set_sensitive(new_state)
def combo_on_change(self,combobox,new_index,user_data=None):
self.change_encrypt_method()
def set_values(self): def set_values(self):
""" Set the various network settings to the right values. """ """ Set the various network settings to the right values. """
@@ -384,45 +490,6 @@ class WirelessSettingsDialog(AdvancedSettingsDialog):
wireless.SaveWirelessNetworkProfile(self.networkid) wireless.SaveWirelessNetworkProfile(self.networkid)
return True return True
# More or less ripped from netentry.py
def change_encrypt_method(self):
#self.lbox_encrypt = urwid.ListBox()
self.encryption_info = {}
wid,ID = self.encryption_combo.get_focus()
methods = misc.LoadEncryptionMethods()
if self._w.body.body.__contains__(self.pile_encrypt):
self._w.body.body.pop(self._w.body.body.__len__()-1)
# If nothing is selected, select the first entry.
if ID == -1:
self.encryption_combo.set_focus(0)
ID = 0
theList = []
for type_ in ['required', 'optional']:
fields = methods[ID][type_]
for field in fields:
try:
edit = MaskingEdit(('editcp',language[field[1].lower().replace(' ','_')]+': '))
except KeyError:
edit = MaskingEdit(('editcp',field[1].replace(' ','_')+': '))
edit.set_mask_mode('no_focus')
theList.append(edit)
# Add the data to any array, so that the information
# can be easily accessed by giving the name of the wanted
# data.
self.encryption_info[field[0]] = [edit, type_]
edit.set_edit_text(noneToBlankString(
wireless.GetWirelessProperty(self.networkid, field[0])))
#FIXME: This causes the entire pile to light up upon use.
# Make this into a listbox?
self.pile_encrypt = DynWrap(urwid.Pile(theList),attrs=('editbx','editnfc'))
self._w.body.body.insert(self._w.body.body.__len__(),self.pile_encrypt)
#self._w.body.body.append(self.pile_encrypt)
def ready_widgets(self,ui,body): def ready_widgets(self,ui,body):
self.ui = ui self.ui = ui
self.body = body self.body = body

View File

@@ -827,7 +827,7 @@ class appGUI():
focus = self.thePile.get_focus() focus = self.thePile.get_focus()
self.frame.set_footer(urwid.Pile([self.confCols,self.footer2])) self.frame.set_footer(urwid.Pile([self.confCols,self.footer2]))
if focus == self.wiredCB: if focus == self.wiredCB:
self.diag = WiredSettingsDialog(self.wiredCB.get_body().get_selected_profile()) self.diag = WiredSettingsDialog(self.wiredCB.get_body().get_selected_profile(),self.frame)
self.frame.set_body(self.diag) self.frame.set_body(self.diag)
else: else:
# wireless list only other option # wireless list only other option

View File

@@ -0,0 +1 @@
wired_8021x

View File

@@ -0,0 +1,17 @@
name = 802.1x
author = Joe MacMahon
version = 1
require identity *Identity password *Password
protected password *Password
-----
ctrl_interface=/var/run/wpa_supplicant
eapol_version=1
fast_reauth=0
network={
key_mgmt=IEEE8021X
eap=PEAP
phase1="peaplabel=1"
phase2="auth=MSCHAPV2"
identity="$_IDENTITY"
password="$_PASSWORD"
}

View File

@@ -236,6 +236,12 @@ class AdvancedSettingsDialog(gtk.Dialog):
for w in [self.txt_dns_1, self.txt_dns_2, self.txt_dns_3, for w in [self.txt_dns_1, self.txt_dns_2, self.txt_dns_3,
self.txt_domain, self.txt_search_dom]: self.txt_domain, self.txt_search_dom]:
w.set_sensitive(not self.chkbox_global_dns.get_active()) w.set_sensitive(not self.chkbox_global_dns.get_active())
def toggle_encryption(self, widget=None):
""" Toggle the encryption combobox based on the encryption checkbox. """
active = self.chkbox_encryption.get_active()
self.vbox_encrypt_info.set_sensitive(active)
self.combo_encryption.set_sensitive(active)
def destroy_called(self, *args): def destroy_called(self, *args):
""" Clean up everything. """ """ Clean up everything. """
@@ -279,11 +285,80 @@ class AdvancedSettingsDialog(gtk.Dialog):
self.chkbox_use_dhcp_hostname.get_active()) self.chkbox_use_dhcp_hostname.get_active())
self.set_net_prop("dhcphostname",noneToString(self.txt_dhcp_hostname.get_text())) self.set_net_prop("dhcphostname",noneToString(self.txt_dhcp_hostname.get_text()))
def change_encrypt_method(self, widget=None):
""" Load all the entries for a given encryption method. """
for z in self.vbox_encrypt_info:
z.destroy() # Remove stuff in there already
ID = self.combo_encryption.get_active()
methods = self.encrypt_types
self.encryption_info = {}
# If nothing is selected, select the first entry.
if ID == -1:
self.combo_encryption.set_active(0)
ID = 0
for type_ in ['required', 'optional']:
fields = methods[ID][type_]
for field in fields:
try:
field_text = language[field[1].lower().replace(' ','_')]
except KeyError:
field_text = field[1].replace(' ','_')
if field in methods[ID]['protected']:
box = ProtectedLabelEntry(field_text)
else:
box = LabelEntry(field_text)
self.vbox_encrypt_info.pack_start(box)
# Add the data to a dict, so that the information
# can be easily accessed by giving the name of the wanted
# data.
self.encryption_info[field[0]] = [box, type_]
if self.wired:
box.entry.set_text(noneToBlankString(
wired.GetWiredProperty(field[0])))
else:
box.entry.set_text(noneToBlankString(
wireless.GetWirelessProperty(self.networkID, field[0])))
self.vbox_encrypt_info.show_all()
class WiredSettingsDialog(AdvancedSettingsDialog): class WiredSettingsDialog(AdvancedSettingsDialog):
def __init__(self, name): def __init__(self, name):
""" Build the wired settings dialog. """ """ Build the wired settings dialog. """
AdvancedSettingsDialog.__init__(self, _('Wired Network')) AdvancedSettingsDialog.__init__(self, _('Wired Network'))
# So we can test if we are wired or wireless (for change_encrypt_method())
self.wired = True
## This section is largely copied from WirelessSettingsDialog, but with some changes
# Set up encryption stuff
self.combo_encryption = gtk.combo_box_new_text()
self.chkbox_encryption = gtk.CheckButton(_('Use Encryption'))
# Make the vbox to hold the encryption stuff.
self.vbox_encrypt_info = gtk.VBox(False, 0)
self.chkbox_encryption.set_active(bool(wired.GetWiredProperty('encryption_enabled')))
self.combo_encryption.set_sensitive(False)
self.encrypt_types = misc.LoadEncryptionMethods(wired = True)
# Build the encryption menu
for x, enc_type in enumerate(self.encrypt_types):
self.combo_encryption.append_text(enc_type['name'])
self.combo_encryption.set_active(0)
self.change_encrypt_method()
self.toggle_encryption()
self.cvbox.pack_start(self.chkbox_encryption, False, False)
self.cvbox.pack_start(self.combo_encryption, False, False)
self.cvbox.pack_start(self.vbox_encrypt_info, False, False)
# Connect signals.
self.chkbox_encryption.connect("toggled", self.toggle_encryption)
self.combo_encryption.connect("changed", self.change_encrypt_method)
self.des = self.connect("destroy", self.destroy_called) self.des = self.connect("destroy", self.destroy_called)
self.script_button.connect("clicked", self.edit_scripts) self.script_button.connect("clicked", self.edit_scripts)
self.prof_name = name self.prof_name = name
@@ -329,7 +404,39 @@ class WiredSettingsDialog(AdvancedSettingsDialog):
self.txt_dhcp_hostname.set_text(dhcphname) self.txt_dhcp_hostname.set_text(dhcphname)
self.reset_static_checkboxes() self.reset_static_checkboxes()
self.chkbox_encryption.set_active(bool(wired.GetWiredProperty('encryption_enabled')))
self.change_encrypt_method()
self.toggle_encryption()
def save_settings(self): def save_settings(self):
# Check encryption info
encrypt_info = self.encryption_info
self.set_net_prop("encryption_enabled", self.chkbox_encryption.get_active())
if self.chkbox_encryption.get_active():
print "setting encryption info..."
encrypt_methods = self.encrypt_types
self.set_net_prop("enctype",
encrypt_methods[self.combo_encryption.get_active()]['type'])
# Make sure all required fields are filled in.
for entry_info in encrypt_info.itervalues():
if entry_info[0].entry.get_text() == "" and \
entry_info[1] == 'required':
error(self, "%s (%s)" % (_('Required encryption information is missing.'),
entry_info[0].label.get_label())
)
return False
# Now save all the entries.
for entry_key, entry_info in encrypt_info.iteritems():
self.set_net_prop(entry_key,
noneToString(entry_info[0].entry.get_text()))
elif not wired and not self.chkbox_encryption.get_active() and \
wireless.GetWirelessProperty(networkid, "encryption"):
# Encrypt checkbox is off, but the network needs it.
error(self, _('This network requires encryption to be enabled.'))
return False
else:
print "no encryption specified..."
self.set_net_prop("enctype", "None")
AdvancedSettingsDialog.save_settings(self) AdvancedSettingsDialog.save_settings(self)
wired.SaveWiredNetworkProfile(self.prof_name) wired.SaveWiredNetworkProfile(self.prof_name)
return True return True
@@ -350,6 +457,9 @@ class WirelessSettingsDialog(AdvancedSettingsDialog):
def __init__(self, networkID): def __init__(self, networkID):
""" Build the wireless settings dialog. """ """ Build the wireless settings dialog. """
AdvancedSettingsDialog.__init__(self, wireless.GetWirelessProperty(networkID, 'essid')) AdvancedSettingsDialog.__init__(self, wireless.GetWirelessProperty(networkID, 'essid'))
# So we can test if we are wired or wireless (for change_encrypt_method())
self.wired = False
# Set up encryption stuff # Set up encryption stuff
self.networkID = networkID self.networkID = networkID
self.combo_encryption = gtk.combo_box_new_text() self.combo_encryption = gtk.combo_box_new_text()
@@ -513,48 +623,6 @@ class WirelessSettingsDialog(AdvancedSettingsDialog):
def format_entry(self, networkid, label): def format_entry(self, networkid, label):
""" Helper method for fetching/formatting wireless properties. """ """ Helper method for fetching/formatting wireless properties. """
return noneToBlankString(wireless.GetWirelessProperty(networkid, label)) return noneToBlankString(wireless.GetWirelessProperty(networkid, label))
def toggle_encryption(self, widget=None):
""" Toggle the encryption combobox based on the encryption checkbox. """
active = self.chkbox_encryption.get_active()
self.vbox_encrypt_info.set_sensitive(active)
self.combo_encryption.set_sensitive(active)
def change_encrypt_method(self, widget=None):
""" Load all the entries for a given encryption method. """
for z in self.vbox_encrypt_info:
z.destroy() # Remove stuff in there already
ID = self.combo_encryption.get_active()
methods = self.encrypt_types
self.encryption_info = {}
# If nothing is selected, select the first entry.
if ID == -1:
self.combo_encryption.set_active(0)
ID = 0
for type_ in ['required', 'optional']:
fields = methods[ID][type_]
for field in fields:
try:
field_text = language[field[1].lower().replace(' ','_')]
except KeyError:
field_text = field[1].replace(' ','_')
if field in methods[ID]['protected']:
box = ProtectedLabelEntry(field_text)
else:
box = LabelEntry(field_text)
self.vbox_encrypt_info.pack_start(box)
# Add the data to a dict, so that the information
# can be easily accessed by giving the name of the wanted
# data.
self.encryption_info[field[0]] = [box, type_]
box.entry.set_text(noneToBlankString(
wireless.GetWirelessProperty(self.networkID, field[0])))
self.vbox_encrypt_info.show_all()
class NetworkEntry(gtk.HBox): class NetworkEntry(gtk.HBox):

View File

@@ -271,7 +271,10 @@ def ParseEncryption(network):
""" """
enctemplate = open(wpath.encryption + network["enctype"]) enctemplate = open(wpath.encryption + network["enctype"])
template = enctemplate.readlines() template = enctemplate.readlines()
config_file = "ap_scan=1\n" if network.get('essid'):
config_file = "ap_scan=1\n"
else:
config_file = "ap_scan=0\n"
should_replace = False should_replace = False
for index, line in enumerate(template): for index, line in enumerate(template):
if not should_replace: if not should_replace:
@@ -303,8 +306,11 @@ def ParseEncryption(network):
# Write the data to the files then chmod them so they can't be read # Write the data to the files then chmod them so they can't be read
# by normal users. # by normal users.
file_loc = os.path.join(wpath.networks, if network.get('bssid'):
network['bssid'].replace(":", "").lower()) file_name = network['bssid'].replace(":", "").lower()
else:
file_name = 'wired'
file_loc = os.path.join(wpath.networks, file_name)
f = open(file_loc, "w") f = open(file_loc, "w")
os.chmod(file_loc, 0600) os.chmod(file_loc, 0600)
os.chown(file_loc, 0, 0) os.chown(file_loc, 0, 0)
@@ -313,7 +319,7 @@ def ParseEncryption(network):
f.write(config_file) f.write(config_file)
f.close() f.close()
def LoadEncryptionMethods(): def LoadEncryptionMethods(wired = False):
""" Load encryption methods from configuration files """ Load encryption methods from configuration files
Loads all the encryption methods from the template files Loads all the encryption methods from the template files
@@ -321,8 +327,12 @@ def LoadEncryptionMethods():
loaded, the template must be listed in the "active" file. loaded, the template must be listed in the "active" file.
""" """
if wired:
active_fname = "active_wired"
else:
active_fname = "active"
try: try:
enctypes = open(wpath.encryption + "active","r").readlines() enctypes = open(wpath.encryption + active_fname,"r").readlines()
except IOError, e: except IOError, e:
print "Fatal Error: template index file is missing." print "Fatal Error: template index file is missing."
raise IOError(e) raise IOError(e)

View File

@@ -518,6 +518,12 @@ class ConnectThread(threading.Thread):
finally: finally:
self.lock.release() self.lock.release()
@abortable
def stop_wpa(self, iface):
""" Stops wpa_supplicant. """
print 'Stopping wpa_supplicant'
iface.StopWPA()
@abortable @abortable
def put_iface_up(self, iface): def put_iface_up(self, iface):
""" Bring up given interface. """ """ Bring up given interface. """
@@ -968,13 +974,6 @@ class WirelessConnectThread(ConnectThread):
self.abort_connection('association_failed') self.abort_connection('association_failed')
else: else:
print 'not verifying' print 'not verifying'
@abortable
def stop_wpa(self, wiface):
""" Stops wpa_supplicant. """
print 'Stopping wpa_supplicant'
wiface.StopWPA()
@abortable @abortable
def generate_psk_and_authenticate(self, wiface): def generate_psk_and_authenticate(self, wiface):
@@ -1073,6 +1072,10 @@ class Wired(Controller):
def Disconnect(self): def Disconnect(self):
Controller.Disconnect(self, 'wired', 'wired', 'wired') Controller.Disconnect(self, 'wired', 'wired', 'wired')
self.StopWPA()
def StopWPA(self):
self.liface.StopWPA()
def DetectWiredInterface(self): def DetectWiredInterface(self):
""" Attempts to automatically detect a wired interface. """ """ Attempts to automatically detect a wired interface. """
@@ -1143,11 +1146,16 @@ class WiredConnectThread(ConnectThread):
self.put_iface_down(liface) self.put_iface_down(liface)
self.release_dhcp_clients(liface) self.release_dhcp_clients(liface)
self.reset_ip_addresses(liface) self.reset_ip_addresses(liface)
self.stop_wpa(liface)
self.flush_routes(liface) self.flush_routes(liface)
# Bring up interface. # Bring up interface.
self.put_iface_up(liface) self.put_iface_up(liface)
# Manage encryption.
if self.network.get('encryption_enabled'):
liface.Authenticate(self.network)
# Set gateway, IP adresses, and DNS servers. # Set gateway, IP adresses, and DNS servers.
self.set_broadcast_address(liface) self.set_broadcast_address(liface)
self.set_ip_address(liface) self.set_ip_address(liface)

View File

@@ -1492,7 +1492,7 @@ class WiredDaemon(dbus.service.Object):
for option in ["ip", "broadcast", "netmask", "gateway", "search_domain", for option in ["ip", "broadcast", "netmask", "gateway", "search_domain",
"dns_domain", "dns1", "dns2", "dns3", "beforescript", "dns_domain", "dns1", "dns2", "dns3", "beforescript",
"afterscript", "predisconnectscript", "afterscript", "predisconnectscript",
"postdisconnectscript"]: "postdisconnectscript", "encryption_enabled"]:
self.config.set(profilename, option, None) self.config.set(profilename, option, None)
self.config.set(profilename, "default", default) self.config.set(profilename, "default", default)
self.config.set(profilename,"dhcphostname",os.uname()[1]) self.config.set(profilename,"dhcphostname",os.uname()[1])
@@ -1580,6 +1580,7 @@ class WiredDaemon(dbus.service.Object):
profile[x] = misc.Noneify(self.config.get(profilename, x)) profile[x] = misc.Noneify(self.config.get(profilename, x))
profile['use_global_dns'] = bool(profile.get('use_global_dns')) profile['use_global_dns'] = bool(profile.get('use_global_dns'))
profile['use_static_dns'] = bool(profile.get('use_static_dns')) profile['use_static_dns'] = bool(profile.get('use_static_dns'))
profile['encryption_enabled'] = bool(profile.get('encryption_enabled'))
profile['profilename'] = profilename profile['profilename'] = profilename
self.WiredNetwork = profile self.WiredNetwork = profile
self._cur_wired_prof_name = profilename self._cur_wired_prof_name = profilename

View File

@@ -768,6 +768,13 @@ class BaseInterface(object):
print "Could not open %s, using ifconfig to determine status" % flags_file print "Could not open %s, using ifconfig to determine status" % flags_file
return self._slow_is_up(ifconfig) return self._slow_is_up(ifconfig)
return bool(int(flags, 16) & 1) return bool(int(flags, 16) & 1)
@neediface(False)
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 _slow_is_up(self, ifconfig=None): def _slow_is_up(self, ifconfig=None):
@@ -892,6 +899,13 @@ class BaseWiredInterface(BaseInterface):
else: else:
return False return False
def Authenticate(self, network):
misc.ParseEncryption(network)
cmd = ['wpa_supplicant', '-B', '-i', self.iface, '-c',
os.path.join(wpath.networks, 'wired'),
'-Dwired']
if self.verbose: print cmd
misc.Run(cmd)
class BaseWirelessInterface(BaseInterface): class BaseWirelessInterface(BaseInterface):
""" Control a wireless network interface. """ """ Control a wireless network interface. """
@@ -1385,13 +1399,6 @@ class BaseWirelessInterface(BaseInterface):
print 'wpa_supplicant rescan forced...' print 'wpa_supplicant rescan forced...'
cmd = 'wpa_cli -i' + self.iface + ' scan' cmd = 'wpa_cli -i' + self.iface + ' scan'
misc.Run(cmd) misc.Run(cmd)
@neediface(False)
def StopWPA(self):
""" Terminates wpa using wpa_cli"""
cmd = 'wpa_cli -i %s terminate' % self.iface
if self.verbose: print cmd
misc.Run(cmd)
@neediface("") @neediface("")
def GetBSSID(self, iwconfig=None): def GetBSSID(self, iwconfig=None):