1
0
mirror of https://github.com/gryf/wicd.git synced 2025-12-20 04:48:00 +01:00

Committed patch from Sabin Iacob to sanitize a user's psk, to prevent possible parsing errors and security risks.

This commit is contained in:
imdano
2008-01-24 10:36:22 +00:00
parent 9bd9605411
commit 7886051d87
2 changed files with 7 additions and 2 deletions

View File

@@ -23,6 +23,7 @@ import locale
import gettext import gettext
import time import time
import sys import sys
import re
from subprocess import * from subprocess import *
if __name__ == '__main__': if __name__ == '__main__':
@@ -260,6 +261,10 @@ def error(parent, message):
dialog.run() dialog.run()
dialog.destroy() dialog.destroy()
def shell_escape(data):
escape_re = re.compile('(?=[^a-zA-Z0-9_.\/\-\x7F-\xFF])')
print 'data is',data
return escape_re.sub("\\\\", data)
class LogWriter(): class LogWriter():
""" A class to provide timestamped logging. """ """ A class to provide timestamped logging. """
@@ -308,7 +313,6 @@ class LogWriter():
if self.eol: self.file.write('\n') if self.eol: self.file.write('\n')
self.file.close() self.file.close()
def get_time(self): def get_time(self):
""" Return a string with the current time nicely formatted. """ Return a string with the current time nicely formatted.

View File

@@ -446,7 +446,8 @@ class WirelessConnectThread(ConnectThread):
re.I | re.M | re.S) re.I | re.M | re.S)
self.network['psk'] = misc.RunRegex(key_pattern, self.network['psk'] = misc.RunRegex(key_pattern,
misc.Run('wpa_passphrase "' + self.network['essid'] + misc.Run('wpa_passphrase "' + self.network['essid'] +
'" "' + self.network['key'] + '"')) '" "' + misc.shell_escape(self.network['key'])
+ '"'))
# Generate the wpa_supplicant file... # Generate the wpa_supplicant file...
if self.network.get('enctype') is not None: if self.network.get('enctype') is not None:
self.SetStatus('generating_wpa_config') self.SetStatus('generating_wpa_config')