mirror of
https://github.com/gryf/wicd.git
synced 2026-03-10 03:25:46 +01:00
Preliminary work on wired encryption. Implemented necessary infrastructure, bugfixing to follow.
This commit is contained in:
20
wicd/misc.py
20
wicd/misc.py
@@ -271,7 +271,10 @@ def ParseEncryption(network):
|
||||
"""
|
||||
enctemplate = open(wpath.encryption + network["enctype"])
|
||||
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
|
||||
for index, line in enumerate(template):
|
||||
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
|
||||
# by normal users.
|
||||
file_loc = os.path.join(wpath.networks,
|
||||
network['bssid'].replace(":", "").lower())
|
||||
if network.get('bssid'):
|
||||
file_name = network['bssid'].replace(":", "").lower()
|
||||
else:
|
||||
file_name = 'wired'
|
||||
file_loc = os.path.join(wpath.networks, file_name)
|
||||
f = open(file_loc, "w")
|
||||
os.chmod(file_loc, 0600)
|
||||
os.chown(file_loc, 0, 0)
|
||||
@@ -313,7 +319,7 @@ def ParseEncryption(network):
|
||||
f.write(config_file)
|
||||
f.close()
|
||||
|
||||
def LoadEncryptionMethods():
|
||||
def LoadEncryptionMethods(wired = False):
|
||||
""" Load encryption methods from configuration 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.
|
||||
|
||||
"""
|
||||
if wired:
|
||||
active_fname = "active_wired"
|
||||
else:
|
||||
active_fname = "active"
|
||||
try:
|
||||
enctypes = open(wpath.encryption + "active","r").readlines()
|
||||
enctypes = open(wpath.encryption + active_fname,"r").readlines()
|
||||
except IOError, e:
|
||||
print "Fatal Error: template index file is missing."
|
||||
raise IOError(e)
|
||||
|
||||
@@ -1148,6 +1148,10 @@ class WiredConnectThread(ConnectThread):
|
||||
# Bring up interface.
|
||||
self.put_iface_up(liface)
|
||||
|
||||
# Manage encryption.
|
||||
if self.network.get('encryption'):
|
||||
liface.Authenticate(self.network)
|
||||
|
||||
# Set gateway, IP adresses, and DNS servers.
|
||||
self.set_broadcast_address(liface)
|
||||
self.set_ip_address(liface)
|
||||
|
||||
@@ -892,6 +892,13 @@ class BaseWiredInterface(BaseInterface):
|
||||
else:
|
||||
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):
|
||||
""" Control a wireless network interface. """
|
||||
|
||||
Reference in New Issue
Block a user