mirror of
https://github.com/gryf/wicd.git
synced 2026-02-03 23:05:54 +01:00
Implement WEP key index specification
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
name = WEP (Hex [0-9/A-F])
|
||||
author = Adam Blackburn
|
||||
version = 1
|
||||
version = 2
|
||||
require key *Key
|
||||
optional key_index *Key_Index
|
||||
protected key *Key
|
||||
-----
|
||||
ctrl_interface=/var/run/wpa_supplicant
|
||||
@@ -9,7 +10,7 @@ network={
|
||||
ssid="$_ESSID"
|
||||
scan_ssid=$_SCAN
|
||||
key_mgmt=NONE
|
||||
wep_key0=$_KEY
|
||||
wep_tx_keyidx=0
|
||||
wep_key$_KEY_INDEX=$_KEY
|
||||
wep_tx_keyidx=$_KEY_INDEX
|
||||
priority=5
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
name = WEP (Passphrase)
|
||||
author = Adam Blackburn
|
||||
version = 1
|
||||
version = 2
|
||||
require passphrase *Passphrase
|
||||
optional key_index *Key_Index
|
||||
protected passphrase *Passphrase
|
||||
-----
|
||||
ctrl_interface=/var/run/wpa_supplicant
|
||||
@@ -9,7 +10,7 @@ network={
|
||||
ssid="$_ESSID"
|
||||
scan_ssid=$_SCAN
|
||||
key_mgmt=NONE
|
||||
wep_key0="$_PASSPHRASE"
|
||||
wep_tx_keyidx=0
|
||||
wep_key$_KEY_INDEX="$_PASSPHRASE"
|
||||
wep_tx_keyidx=$_KEY_INDEX
|
||||
priority=5
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
name = WEP Shared/Restricted
|
||||
author = Dan O'Reilly
|
||||
version = 1
|
||||
version = 2
|
||||
require key *Key
|
||||
optional key_index *Key_Index
|
||||
protected key *Key
|
||||
-----
|
||||
ctrl_interface=/var/run/wpa_supplicant
|
||||
@@ -10,7 +11,7 @@ network={
|
||||
scan_ssid=$_SCAN
|
||||
key_mgmt=NONE
|
||||
auth_alg=SHARED
|
||||
wep_key0=$_KEY
|
||||
wep_tx_keyidx=0
|
||||
wep_key$_KEY_INDEX=$_KEY
|
||||
wep_tx_keyidx=$_KEY_INDEX
|
||||
priority=5
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\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"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
@@ -360,6 +360,10 @@ msgstr ""
|
||||
msgid "Key"
|
||||
msgstr ""
|
||||
|
||||
#: wicd/translations.py:81
|
||||
msgid "Key index"
|
||||
msgstr ""
|
||||
|
||||
#: curses/netentry_curses.py:51 gtk/netentry.py:76
|
||||
msgid "Netmask"
|
||||
msgstr ""
|
||||
|
||||
@@ -84,6 +84,12 @@ class TestMisc(unittest.TestCase):
|
||||
def test_noneify_11(self):
|
||||
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):
|
||||
self.assertEquals(misc.noneToString(None), 'None')
|
||||
|
||||
|
||||
31
wicd/misc.py
31
wicd/misc.py
@@ -252,15 +252,16 @@ def to_bool(var):
|
||||
var = bool(var)
|
||||
return var
|
||||
|
||||
def Noneify(variable):
|
||||
def Noneify(variable, to_bool=True):
|
||||
""" Convert string types to either None or booleans"""
|
||||
#set string Nones to real Nones
|
||||
if variable in ("None", "", None):
|
||||
return None
|
||||
if variable in ("False", "0"):
|
||||
return False
|
||||
if variable in ("True", "1"):
|
||||
return True
|
||||
if to_bool:
|
||||
if variable in ("False", "0"):
|
||||
return False
|
||||
if variable in ("True", "1"):
|
||||
return True
|
||||
return variable
|
||||
|
||||
def ParseEncryption(network):
|
||||
@@ -288,18 +289,18 @@ def ParseEncryption(network):
|
||||
elif "$_" in line:
|
||||
cur_val = re.findall('\$_([A-Z0-9_]+)', line)
|
||||
if cur_val:
|
||||
if cur_val[0] == 'SCAN':
|
||||
#TODO should this be hardcoded?
|
||||
line = line.replace("$_SCAN", "1")
|
||||
rep_val = network.get(cur_val[0].lower())
|
||||
if not rep_val:
|
||||
# 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])
|
||||
else:
|
||||
rep_val = network.get(cur_val[0].lower())
|
||||
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
|
||||
print "Ignoring template line: '%s'" % line
|
||||
else:
|
||||
print "Weird parsing error occurred"
|
||||
else: # Just a regular entry.
|
||||
|
||||
@@ -78,6 +78,7 @@ language['authentication'] = _('Authentication')
|
||||
language['domain'] = _('Domain')
|
||||
language['identity'] = _('Identity')
|
||||
language['key'] = _('Key')
|
||||
language['key_index'] = _('Key index')
|
||||
language['passphrase'] = _('Passphrase')
|
||||
language['password'] = _('Password')
|
||||
language['path_to_ca_cert'] = _('Path to CA cert')
|
||||
|
||||
@@ -1069,7 +1069,11 @@ class WirelessDaemon(dbus.service.Object):
|
||||
print 'Setting script properties through the daemon' \
|
||||
+ ' is not permitted.'
|
||||
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')
|
||||
def DetectWirelessInterface(self):
|
||||
|
||||
Reference in New Issue
Block a user