Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorC. Scott Ananian <cscott@laptop.org>2008-09-25 14:56:51 (GMT)
committer C. Scott Ananian <cscott@laptop.org>2008-09-25 18:45:55 (GMT)
commit783129d24ca7196accfcee38a8069623240e6784 (patch)
tree559d803df6cace09634175a9c4cd72cd29a6e55c /src
parent2b469d753287191c2c45b031252d3bd68b5d9afb (diff)
Trac #8642: bug in WPA key dialog prevents passwords with shell metacharacters
The use of commands.getstatusoutput is very sketchy. I've replaced this with subprocess.Popen, which is the preferred way to invoke other programs these days.
Diffstat (limited to 'src')
-rw-r--r--src/hardware/keydialog.py12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/hardware/keydialog.py b/src/hardware/keydialog.py
index 8c8c36a..781f77a 100644
--- a/src/hardware/keydialog.py
+++ b/src/hardware/keydialog.py
@@ -265,15 +265,13 @@ class WPAKeyDialog(KeyDialog):
real_key = key
elif len(key) >= 8 and len(key) <= 63:
# passphrase
- import commands
- command = "/usr/sbin/wpa_passphrase '%s' '%s'" % (ssid, key)
- (s, o) = commands.getstatusoutput(command)
- if s != 0:
- raise RuntimeError("Error hashing passphrase: %s" % o)
- lines = o.split("\n")
- for line in lines:
+ from subprocess import Popen, PIPE
+ p = Popen(['/usr/sbin/wpa_passphrase', ssid, key], stdout=PIPE)
+ for line in p.stdout:
if line.strip().startswith("psk="):
real_key = line.strip()[4:]
+ if p.wait() != 0:
+ raise RuntimeError("Error hashing passphrase")
if real_key and len(real_key) != 64:
real_key = None