1
0
mirror of https://github.com/gryf/wicd.git synced 2026-03-07 01:55:49 +01:00

Implement WEP key index specification

This commit is contained in:
David Paleino
2012-05-04 19:39:04 +02:00
parent bca11618be
commit 63460113b8
8 changed files with 45 additions and 26 deletions

View File

@@ -1,7 +1,8 @@
name = WEP (Hex [0-9/A-F]) name = WEP (Hex [0-9/A-F])
author = Adam Blackburn author = Adam Blackburn
version = 1 version = 2
require key *Key require key *Key
optional key_index *Key_Index
protected key *Key protected key *Key
----- -----
ctrl_interface=/var/run/wpa_supplicant ctrl_interface=/var/run/wpa_supplicant
@@ -9,7 +10,7 @@ network={
ssid="$_ESSID" ssid="$_ESSID"
scan_ssid=$_SCAN scan_ssid=$_SCAN
key_mgmt=NONE key_mgmt=NONE
wep_key0=$_KEY wep_key$_KEY_INDEX=$_KEY
wep_tx_keyidx=0 wep_tx_keyidx=$_KEY_INDEX
priority=5 priority=5
} }

View File

@@ -1,7 +1,8 @@
name = WEP (Passphrase) name = WEP (Passphrase)
author = Adam Blackburn author = Adam Blackburn
version = 1 version = 2
require passphrase *Passphrase require passphrase *Passphrase
optional key_index *Key_Index
protected passphrase *Passphrase protected passphrase *Passphrase
----- -----
ctrl_interface=/var/run/wpa_supplicant ctrl_interface=/var/run/wpa_supplicant
@@ -9,7 +10,7 @@ network={
ssid="$_ESSID" ssid="$_ESSID"
scan_ssid=$_SCAN scan_ssid=$_SCAN
key_mgmt=NONE key_mgmt=NONE
wep_key0="$_PASSPHRASE" wep_key$_KEY_INDEX="$_PASSPHRASE"
wep_tx_keyidx=0 wep_tx_keyidx=$_KEY_INDEX
priority=5 priority=5
} }

View File

@@ -1,7 +1,8 @@
name = WEP Shared/Restricted name = WEP Shared/Restricted
author = Dan O'Reilly author = Dan O'Reilly
version = 1 version = 2
require key *Key require key *Key
optional key_index *Key_Index
protected key *Key protected key *Key
----- -----
ctrl_interface=/var/run/wpa_supplicant ctrl_interface=/var/run/wpa_supplicant
@@ -10,7 +11,7 @@ network={
scan_ssid=$_SCAN scan_ssid=$_SCAN
key_mgmt=NONE key_mgmt=NONE
auth_alg=SHARED auth_alg=SHARED
wep_key0=$_KEY wep_key$_KEY_INDEX=$_KEY
wep_tx_keyidx=0 wep_tx_keyidx=$_KEY_INDEX
priority=5 priority=5
} }

View File

@@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2011-12-07 23:04+0100\n" "POT-Creation-Date: 2012-05-04 00:29+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -360,6 +360,10 @@ msgstr ""
msgid "Key" msgid "Key"
msgstr "" msgstr ""
#: wicd/translations.py:81
msgid "Key index"
msgstr ""
#: curses/netentry_curses.py:51 gtk/netentry.py:76 #: curses/netentry_curses.py:51 gtk/netentry.py:76
msgid "Netmask" msgid "Netmask"
msgstr "" msgstr ""

View File

@@ -84,6 +84,12 @@ class TestMisc(unittest.TestCase):
def test_noneify_11(self): def test_noneify_11(self):
self.assertEquals(misc.Noneify(5), 5) self.assertEquals(misc.Noneify(5), 5)
def test_noneify_12(self):
self.assertEquals(misc.Noneify(1, False), 1)
def test_noneify_13(self):
self.assertEquals(misc.Noneify(0, False), 0)
def test_none_to_string_1(self): def test_none_to_string_1(self):
self.assertEquals(misc.noneToString(None), 'None') self.assertEquals(misc.noneToString(None), 'None')

View File

@@ -252,15 +252,16 @@ def to_bool(var):
var = bool(var) var = bool(var)
return var return var
def Noneify(variable): def Noneify(variable, to_bool=True):
""" Convert string types to either None or booleans""" """ Convert string types to either None or booleans"""
#set string Nones to real Nones #set string Nones to real Nones
if variable in ("None", "", None): if variable in ("None", "", None):
return None return None
if variable in ("False", "0"): if to_bool:
return False if variable in ("False", "0"):
if variable in ("True", "1"): return False
return True if variable in ("True", "1"):
return True
return variable return variable
def ParseEncryption(network): def ParseEncryption(network):
@@ -288,18 +289,18 @@ def ParseEncryption(network):
elif "$_" in line: elif "$_" in line:
cur_val = re.findall('\$_([A-Z0-9_]+)', line) cur_val = re.findall('\$_([A-Z0-9_]+)', line)
if cur_val: if cur_val:
if cur_val[0] == 'SCAN': rep_val = network.get(cur_val[0].lower())
#TODO should this be hardcoded? if not rep_val:
line = line.replace("$_SCAN", "1") # hardcode some default values
if cur_val[0] == 'SCAN':
rep_val = '1'
elif cur_val[0] == 'KEY_INDEX':
rep_val = '0'
if rep_val:
line = line.replace("$_%s" % cur_val[0], str(rep_val))
config_file = ''.join([config_file, line]) config_file = ''.join([config_file, line])
else: else:
rep_val = network.get(cur_val[0].lower()) print "Ignoring template line: '%s'" % line
if rep_val:
line = line.replace("$_%s" % cur_val[0],
str(rep_val))
config_file = ''.join([config_file, line])
else:
print "Ignoring template line: '%s'" % line
else: else:
print "Weird parsing error occurred" print "Weird parsing error occurred"
else: # Just a regular entry. else: # Just a regular entry.

View File

@@ -78,6 +78,7 @@ language['authentication'] = _('Authentication')
language['domain'] = _('Domain') language['domain'] = _('Domain')
language['identity'] = _('Identity') language['identity'] = _('Identity')
language['key'] = _('Key') language['key'] = _('Key')
language['key_index'] = _('Key index')
language['passphrase'] = _('Passphrase') language['passphrase'] = _('Passphrase')
language['password'] = _('Password') language['password'] = _('Password')
language['path_to_ca_cert'] = _('Path to CA cert') language['path_to_ca_cert'] = _('Path to CA cert')

View File

@@ -1069,7 +1069,11 @@ class WirelessDaemon(dbus.service.Object):
print 'Setting script properties through the daemon' \ print 'Setting script properties through the daemon' \
+ ' is not permitted.' + ' is not permitted.'
return False return False
self.LastScan[netid][prop] = misc.to_unicode(misc.Noneify(value)) # whitelist some props that need different handling
if prop in ('key_index', ):
self.LastScan[netid][prop] = misc.to_unicode(misc.Noneify(value, False))
else:
self.LastScan[netid][prop] = misc.to_unicode(misc.Noneify(value))
@dbus.service.method('org.wicd.daemon.wireless') @dbus.service.method('org.wicd.daemon.wireless')
def DetectWirelessInterface(self): def DetectWirelessInterface(self):